在Web应用程序中使用Highcharts javascript

Using Highcharts javascript in Web Application

本文关键字:Highcharts javascript Web 应用程序      更新时间:2023-09-26

我正在.Net应用程序中试用Highcharts。

我有一些数据需要包括在内,但似乎不知道在哪里添加。

     /*X axis coordinates*/
     List<int> lstXaxis = new List<int>();
     lstXaxis.Add(2007);
     lstXaxis.Add(2008);
     lstXaxis.Add(2009);
     lstXaxis.Add(2010);

我需要设置公共属性,以便我的aspx页面可以访问它。

我是否在aspx页面后面的C#代码中包含这两个命令?

      public string Series1 { get; set; }
      public string Xaxis { get; set; }

并且使用访问者来转换x轴数据?

      JavaScriptSerializer oSerializer = new JavaScriptSerializer();
      Xaxis= oSerializer.Serialize(lstXaxis);

我将以下网站作为起点:http://deebujacob.blogspot.com/2011/05/aspnet-and-highcharts.html

xAxis列表位于代码后面。可能在页面加载中。

您提供的两个代码片段:

  public string Series1 { get; set; }
  public string Xaxis { get; set; }

  JavaScriptSerializer oSerializer = new JavaScriptSerializer();
  Xaxis= oSerializer.Serialize(lstXaxis);

进入任何要显示图表的页面的代码后面。

我发现了在.NET中生成图表的另一个更简单的方法。想象一下,生成这样的图表;


DataTable tbl; //your datatable with chart info.. 
//the series you would like to draw, first value corresponds to the name of the column, 2nd value to the title you would to use for that chart
string[] serieslist = { "allorders,All orders", "shippedorders, Shipped orders", "rejectedorders,Rejected orders" };
//getting the chart string
string chartString = chart.DrawChart(tbl, serieslist, "yearly-report", "date", "Yearly sales report", "my subtitle", "column", false);

用三条线画一张图表!

查看此博客输入以获取更多信息。http://www.phronesisweb.com/blog/using-highcharts-with-net-without-any-extra-control-generating-a-highchart-chart-in-just-one-method/