0

我正在我的 .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

4

2 回答 2

0

我发现了另一种更简单的在 .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);

用 3 行绘制图表!

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

于 2012-10-05T17:07:51.530 回答
0

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

您提供的两个代码段:

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

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

进入将在其上显示图表的任何页面的代码隐藏。

于 2012-09-13T20:23:04.273 回答