在Web应用程序使用的JavaScript Highcharts(Using Highcharts

2019-09-22 10:08发布

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

Answer 1:

x轴不胜枚举的代码隐藏。 也许在页面加载。

您提供的两段代码:

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

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

去任何网页都将有图表显示在它的代码隐藏。



Answer 2:

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



文章来源: Using Highcharts javascript in Web Application