使用 ASP.NET MVC3 具有动态数据的堆叠分组直方图 HighCharts 图表?

发布于 2024-12-27 04:25:02 字数 309 浏览 1 评论 0原文

我想使用 HighCharts 和 ASP.NET MVC3 制作堆叠和分组直方图。 我在 HighCharts 网站上找到了这个示例: http://www.highcharts.com/ demo/column-stacked-and-grouped

我会在我的控制器中使用 JsonResult。 特别是,在上面的示例中,图形系列是在 javascript 中预定义的,而我将使用 JSON 动态创建它们。

I'd like to make stacked&grouped histograms using HighCharts and ASP.NET MVC3.
I found this example on HighCharts' site: http://www.highcharts.com/demo/column-stacked-and-grouped

I would use JSonResult in my controller.
In particular, in above example, graph series are pre-defined in javascript, while I would dynamically create them with JSON.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薯片软お妹 2025-01-03 04:25:02

使用 DonNet.Highcharts,您可以轻松地仅在服务器端创建 Highcharts。有堆叠和分组列的示例。这是服务器端代码:

Highcharts chart = new Highcharts("chart")
            .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
            .SetTitle(new Title { Text = "Total fruit consumtion, grouped by gender" })
            .SetXAxis(new XAxis { Categories = new[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" } })
            .SetYAxis(new YAxis
                      {
                          AllowDecimals = false,
                          Min = 0,
                          Title = new YAxisTitle { Text = "Number of fruits" }
                      })
            .SetTooltip(new Tooltip { Formatter = "TooltipFormatter" })
            .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })
            .SetSeries(new[]
                       {
                           new Series
                           {
                               Name = "John",
                               Data = new Data(new object[] { 5, 3, 4, 7, 2 }),
                               Stack = "male"
                           },
                           new Series
                           {
                               Name = "Joe",
                               Data = new Data(new object[] { 3, 4, 4, 2, 5 }),
                               Stack = "male"
                           },
                           new Series
                           {
                               Name = "Jane",
                               Data = new Data(new object[] { 2, 5, 6, 2, 1 }),
                               Stack = "female"
                           },
                           new Series
                           {
                               Name = "Janet",
                               Data = new Data(new object[] { 3, 0, 4, 4, 3 }),
                               Stack = "female"
                           }
                       });

您可以根据需要传递数据。

With DonNet.Highcharts you can easily create Highcharts only on the server side. There is example with the stacked and grouped column. Here is the server side code:

Highcharts chart = new Highcharts("chart")
            .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
            .SetTitle(new Title { Text = "Total fruit consumtion, grouped by gender" })
            .SetXAxis(new XAxis { Categories = new[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" } })
            .SetYAxis(new YAxis
                      {
                          AllowDecimals = false,
                          Min = 0,
                          Title = new YAxisTitle { Text = "Number of fruits" }
                      })
            .SetTooltip(new Tooltip { Formatter = "TooltipFormatter" })
            .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })
            .SetSeries(new[]
                       {
                           new Series
                           {
                               Name = "John",
                               Data = new Data(new object[] { 5, 3, 4, 7, 2 }),
                               Stack = "male"
                           },
                           new Series
                           {
                               Name = "Joe",
                               Data = new Data(new object[] { 3, 4, 4, 2, 5 }),
                               Stack = "male"
                           },
                           new Series
                           {
                               Name = "Jane",
                               Data = new Data(new object[] { 2, 5, 6, 2, 1 }),
                               Stack = "female"
                           },
                           new Series
                           {
                               Name = "Janet",
                               Data = new Data(new object[] { 3, 0, 4, 4, 3 }),
                               Stack = "female"
                           }
                       });

You can pass the data as you like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文