5

我一直在尝试使用基本的 asp.net Chart 类来呈现折线图。无论我做什么,它总是呈现一个柱形图。这是我将数据表绑定到图表的代码。

var IEtable = (table as System.ComponentModel.IListSource).GetList();

var chart = new Chart(width: 1000, height: 1000)
    .AddSeries(chartType: "Line").AddLegend("Key")
    .AddTitle("Time Series Metric")
    .DataBindCrossTable(IEtable, "Key", "Date", "Value");

有人可以帮忙吗?自从超过 12 个小时以来,我一直在用这件事打破我的头。

4

1 回答 1

0

I'm building my charts slightly differently - perhaps because I'm building mine in MVC pages? Anyway, I'm still using the MS Chart stuff - http://msdn.microsoft.com/en-us/library/ee410579.ASPX

I create my chart:

var chart = new Chart();
chart.Width = 900;
chart.Height = 500;
...lots more options...

then add my series one at a time....

chart.Series.Add(CreateDataSeries(id, "GI Lower", null, null, GetGILowerDataPoints));
chart.Series.Add(CreateDataSeries(id, "GI Upper", null, null, GetGIUpperDataPoints));

where CreateDataSeries sets the chart type like this:

Series seriesDetail = new Series();
seriesDetail.ChartType = SeriesChartType.Spline;
...
return seriesDetail;

Does that help at all?

于 2013-11-13T14:57:58.250 回答