本文整理汇总了C#中DotNet.Highcharts.Highcharts.ToHtmlString方法的典型用法代码示例。如果您正苦于以下问题:C# Highcharts.ToHtmlString方法的具体用法?C# Highcharts.ToHtmlString怎么用?C# Highcharts.ToHtmlString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNet.Highcharts.Highcharts
的用法示例。
在下文中一共展示了Highcharts.ToHtmlString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllGoalsByMonthNet
public string AllGoalsByMonthNet()
{
var now = DateTime.Now;
var currentMonth = new DateTime(now.Year, now.Month, 1);
var startDate = currentMonth.AddYears(-1);
var highchart = new Highcharts("AllGoalsMonth");
var chart = new Chart()
{
Type = ChartTypes.Column
};
highchart.InitChart(chart);
highchart.SetTitle(new Title() {Text = "Goals by Month"});
var yaxis = new YAxis {Max = 2};
highchart.SetYAxis(yaxis);
var series = new Series {Name = "Steps"};
var xaxis = new XAxis();
var categories = new List<string>();
var data = new List<object>();
for (var i = startDate; i <= currentMonth; i = i.AddMonths(1))
{
categories.Add(i.Month.ToString() + "-" + i.Year.ToString());
data.Add(pedometerCalcService.MonthPct(i.Month, i.Year));
}
xaxis.Categories = categories.ToArray();
series.Data = new Data(data.ToArray());
highchart.SetXAxis(xaxis);
highchart.SetSeries(series);
return highchart.ToHtmlString();
}
示例2: GetAreaChart
private void GetAreaChart()
{
DashboardViewModel dashboard = new DashboardViewModel();
dashboard.ViewModelEvent += dashboard_ViewModelEvent;
// Get statistics
List<Dictionary<string, object>> values = dashboard.GetAreaChart();
if (values != null)
{
Highcharts areaChart = new Highcharts("areaChart");
areaChart.InitChart(new Chart()
{
DefaultSeriesType = ChartTypes.Area,
BackgroundColor = new DotNet.Highcharts.Helpers.BackColorOrGradient(Color.Transparent),
Height = 300
});
areaChart.SetPlotOptions(new PlotOptions()
{
Series = new PlotOptionsSeries()
{
ConnectNulls = true,
ConnectEnds = true
}
});
areaChart.SetLegend(new DotNet.Highcharts.Options.Legend()
{
Align = DotNet.Highcharts.Enums.HorizontalAligns.Center,
Layout = DotNet.Highcharts.Enums.Layouts.Horizontal,
VerticalAlign = DotNet.Highcharts.Enums.VerticalAligns.Bottom,
BorderWidth = 0
});
areaChart.SetCredits(new DotNet.Highcharts.Options.Credits() { Enabled = false });
areaChart.SetTitle(new DotNet.Highcharts.Options.Title() { Text = "" });
YAxis yAxis = new YAxis();
yAxis.Title = new DotNet.Highcharts.Options.YAxisTitle() { Text = "" };
yAxis.Min = 0;
XAxis xAxis = new XAxis();
xAxis.Categories = values[0].Keys.ToArray();
List<Series> seriesCollection = new List<Series>();
Series seriesUsers = new Series();
seriesUsers.Data = new DotNet.Highcharts.Helpers.Data(values[0].Values.ToArray());
seriesUsers.Name = "Users";
seriesCollection.Add(seriesUsers);
Series seriesMailbox = new Series();
seriesMailbox.Data = new DotNet.Highcharts.Helpers.Data(values[1].Values.ToArray());
seriesMailbox.Name = "Mailbox";
seriesCollection.Add(seriesMailbox);
if (StaticSettings.CitrixEnabled)
{
Series seriesCitrix = new Series();
seriesCitrix.Data = new DotNet.Highcharts.Helpers.Data(values[2].Values.ToArray());
seriesCitrix.Name = "Citrix";
seriesCollection.Add(seriesCitrix);
}
areaChart.SetXAxis(xAxis);
areaChart.SetYAxis(yAxis);
areaChart.SetSeries(seriesCollection.ToArray());
litAreaChart.Text = areaChart.ToHtmlString();
}
else
litAreaChart.Text = "Error populating chart.";
}
示例3: GetBarChart
private void GetBarChart()
{
DashboardViewModel dashboard = new DashboardViewModel();
dashboard.ViewModelEvent += dashboard_ViewModelEvent;
Dictionary<string, object> mdbData = dashboard.GetDatabaseSizeChart(ConfigurationManager.ConnectionStrings["CPDatabase"].ConnectionString);
if (mdbData != null)
{
var databaseNames = from d in mdbData orderby d.Key select d.Key;
var databaseValues = from d in mdbData orderby d.Key select d.Value;
List<object> arrayValues = databaseValues.ToList();
List<DotNet.Highcharts.Options.Point> points = new List<DotNet.Highcharts.Options.Point>();
for (int i = 0; i < arrayValues.Count; i++)
{
double theValue = 0;
double.TryParse(arrayValues[i].ToString(), out theValue);
points.Add(new DotNet.Highcharts.Options.Point()
{
Y = Number.GetNumber(theValue),
Color = decimal.Parse(arrayValues[i].ToString()) > 500 ? System.Drawing.Color.Red : System.Drawing.Color.Blue
});
}
Highcharts columnChart = new Highcharts("mdbBarChart")
.SetOptions(new DotNet.Highcharts.Helpers.GlobalOptions()
{
Lang = new DotNet.Highcharts.Helpers.Lang()
{
DecimalPoint = ".",
ThousandsSep = ","
}
})
.InitChart(new Chart
{
DefaultSeriesType = ChartTypes.Column,
BackgroundColor = new DotNet.Highcharts.Helpers.BackColorOrGradient(Color.Transparent),
Height = 300
})
.SetTitle(new Title
{
Text = ""
})
.SetCredits(new Credits
{
Enabled = false
})
.SetXAxis(new XAxis
{
Categories = databaseNames.ToArray()
})
.SetYAxis(new YAxis
{
Title = new YAxisTitle { Text = "GB" },
Labels = new YAxisLabels() { Enabled = true },
PlotLines = new[]
{
new YAxisPlotLines
{
Value = 0,
Width = 1
}
}
})
.SetLegend(new Legend
{
Enabled = false
})
.SetPlotOptions(new PlotOptions()
{
Column = new PlotOptionsColumn()
{
DataLabels = new PlotOptionsColumnDataLabels()
{
Enabled = true,
Style = "fontWeight: 'bold'"
}
}
})
.SetSeries(new[]
{
new Series
{
Name = "GB",
Data = new DotNet.Highcharts.Helpers.Data(points.ToArray())
}
}
);
litBarChart.Text = columnChart.ToHtmlString();
// Change the div
if (databaseNames.Count() > 8)
divBarChart.Style.Value = "col-sm-12 col-md-12"; // If more than 8 database then make the graph full length of page
else
divBarChart.Style.Value = "col-sm-6 col-md-6"; // Otherwise half length
}
else
//.........这里部分代码省略.........
示例4: CurrentMonthGoalProgressNet
public string CurrentMonthGoalProgressNet()
{
var now = DateTime.Now;
var daysInMonth = DateTime.DaysInMonth(now.Year, now.Month);
var expectedPct = ((decimal)now.Day / daysInMonth);
var remainingDays = daysInMonth - now.Day;
var stepsPR = pedometerCalcService.StepsPR();
var remainingSteps = (int) (stepsPR-pedometerCalcService.MonthStepsActual())/remainingDays;
var highchart = new Highcharts("CurrentMonthGoal");
var chart = new Chart() {Type = ChartTypes.Bar};
var categories = new List<string> {"Steps"};
var yaxis = new YAxis {Max = 1};
var seriesArray = new List<Series>();
var series = new Series {Name = "Expected",Color = Color.Red};
var data = new List<object> {pedometerCalcService.MonthPctExpected(now)};
var plotoptions = new PlotOptionsBar
{
Grouping = false,
Shadow = false,
DataLabels = new PlotOptionsBarDataLabels()
{
Enabled = false,
Format = string.Format("Expected: {0}", (int) (stepsPR*expectedPct)),
Color = Color.White
}
};
series.Data = new Data(data.ToArray());
series.PlotOptionsBar = plotoptions;
seriesArray.Add(series);
series = new Series {Name = "Actual", Color = Color.Green};
data = new List<object> { pedometerCalcService.MonthPct(now.Month, now.Year) };
plotoptions = new PlotOptionsBar
{
Grouping = false,
Shadow = false,
DataLabels = new PlotOptionsBarDataLabels()
{
Enabled = true,
Format = string.Format("Remaining: {0}/day", remainingSteps),
Color = Color.White,
Shadow = false
}
};
series.Data = new Data(data.ToArray());
series.PlotOptionsBar = plotoptions;
seriesArray.Add(series);
highchart.InitChart(chart);
highchart.SetTitle(new Title() {Text = "Month Progress"});
highchart.SetXAxis(new XAxis() {Categories = categories.ToArray()});
highchart.SetYAxis(yaxis);
highchart.SetSeries(seriesArray.ToArray());
highchart.SetTooltip(new Tooltip() {Enabled = false});
return highchart.ToHtmlString();
}
示例5: WeightYearProgressNet
public string WeightYearProgressNet()
{
var startWeight = pedometerCalcService.GetStartWeight(DateTime.Now.Year);
const int goalWeight = 144;
var currentWeight = pedometerCalcService.GetRecentWeight();
var goalLoss = startWeight - goalWeight;
var actualLoss = Math.Round(startWeight - currentWeight, 1);
var expectedPct = (DateTime.Now.DayOfYear / 365.0);
var expectedLoss = Math.Round(expectedPct * goalLoss, 1);
var highchart = new Highcharts("weightloss");
var chart = new Chart()
{
Type = ChartTypes.Gauge
};
highchart.InitChart(chart);
highchart.SetTitle(new Title{Text = "Weight Loss " + Math.Round(currentWeight,1)});
var series = new Series {Data = new Data(new object[] {actualLoss})};
highchart.SetSeries(series);
var pane = new Pane
{
Background = new[]
{
new BackgroundObject
{
InnerRadius = new PercentageOrPixel(60, true),
OuterRadius = new PercentageOrPixel(100, true)
}
},
StartAngle = 0,
EndAngle = 360
};
highchart.SetPane(pane);
var yaxis = new YAxis
{
Min = 0,
Max = goalLoss,
PlotBands = new[]
{
new YAxisPlotBands { From = 0, To = expectedLoss, Color = Color.Red },
new YAxisPlotBands { From = expectedLoss, To = expectedLoss+0.7, Color = Color.Yellow },
new YAxisPlotBands { From = expectedLoss+0.7, To = goalLoss, Color = Color.Green }
},
Labels = new YAxisLabels() { Style = "color:'black'"}
};
highchart.SetYAxis(yaxis);
highchart.SetTooltip(new Tooltip() {Enabled = false});
highchart.SetSubtitle(new Subtitle()
{
Text = string.Format("Actual: {0} | Expected: {1} | Difference: {2}", actualLoss, expectedLoss, actualLoss-expectedLoss)
});
highchart.SetLegend(new Legend() {Enabled = false});
return highchart.ToHtmlString();
}