有没有人有一个使用 DotNet.Highcarts 用 MS SQL DB 中的数据填充 Highchart 的简单示例?
我有使用静态数据的演示
Highcharts chart = new Highcharts("chart")
.SetCredits(new Credits { Enabled = false })
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
.SetTitle(new Title { Text = "Membership Overview" })
.SetXAxis(new XAxis { Categories = new[] { "Paid Members", "Active Members", "Retained Members", "New Members", "Lapsed Members" } })
.SetYAxis(new YAxis
{
Min = 0,
Title = new YAxisTitle { Text = "Total Members" }
})
.SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y +''; }" })
.SetPlotOptions(new PlotOptions { Bar = new PlotOptionsBar { Stacking = Stackings.Normal } })
.SetSeries(new[]
{
new Series { Name = "Total", Data = new Data(new object[] { 441, 441, 22, 30, 610 }) }
});
如何更改系列以接受来自我的数据库的数据?
假设我需要像这样连接到数据库:
var newcustomer = db.Customer;
然后做这样的事情:
new Series
{
Name = "Total",
Data = new Data(newcustomer.Select(x => ............
任何帮助,将不胜感激!