1

有没有人有一个使用 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 => ............

任何帮助,将不胜感激!

4

1 回答 1

4

对于其他有类似问题的人...

var paidmembers = (from c in db.Customer
                   where c.CustomerStatusID == 1
                   select c).Count();

var activemembers = (from c in db.Customer
                     where c.CustomerStatusID == 2
                     select c).Count();

new Series {
            Name = "Category",
            Data = new Data(new object[] {paidmembers, activemembers})
}
于 2012-11-12T17:34:32.910 回答