最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - using library highcharts with asp.net mvc 3 - Stack Overflow

programmeradmin5浏览0评论

I want to use the library highcharts with asp mvc 3 but the examples that I have found in the web is with asp mvc 2. The other thing is, how can I pass the result data from a linq query to a highcharts´s serie in my application.

And anyone that can provide an example of highcharts with asp mvc 3?

I want to use the library highcharts with asp mvc 3 but the examples that I have found in the web is with asp mvc 2. The other thing is, how can I pass the result data from a linq query to a highcharts´s serie in my application.

And anyone that can provide an example of highcharts with asp mvc 3?

Share Improve this question edited Jul 28, 2012 at 15:42 tereško 58.5k25 gold badges100 silver badges150 bronze badges asked Nov 23, 2011 at 18:57 Jack1987Jack1987 7271 gold badge14 silver badges27 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Another way to do this is by using DotNet.Highcharts library. You can build the Highchart entirely on the server side and there are a lot of MVC3 samples.

A good way to do this is to configure your chart object using static Javascript and then load your chart series as JSON data using Ajax and the addSeries method. You can use the Controller.Json method to return your LINQ results as JSON. Assuming you are passing a numeric array to the Controller.Json method in your AJAX action, the following is a simple example of the JavaScript needed to do this:

$(document).ready(function() {
   var chart = new Highcharts.Chart({
      chart: {
         renderTo: "<chart-div>"
      },
      title: { text: "Test Chart" },
   });
   $.ajax({
      url: "<query-url>",
      success: function(result) {
         chart.addSeries({
            data: result,
         });
      }
   });
});

Replace <chart-div> with your container and <query-url> with your Ajax URL or a call to UrlHelper.Action.

发布评论

评论列表(0)

  1. 暂无评论