我正在嘗試使用Microsoft's charting library構建股票圖表。ASP.NET MVC 3 MSChart錯誤:只能爲此數據系列設置1個Y值
我使用此代碼創建在我看來圖表:
@{
System.Web.Helpers.Chart cht = new Chart(600, 400);
cht.AddTitle(ViewData["Symbol"].ToString());
cht.AddSeries(name: "Price",
chartType: "Stock",
chartArea: "Top",
xField: "Date",
xValue: Model,
yFields: "Open,High,Low,Close",
yValues: Model);
cht.Write();
}
當調用得到圖表的作用,下面的異常被拋出:
ArgumentOutOfRangeException: Data points insertion error. Only 1 Y values can be set for this data series. Parameter name: yFields System.Web.UI.DataVisualization.Charting.DataPointCollection.DataBindXY(IEnumerable xValue, String xField, IEnumerable yValue, String yFields) +1076598 System.Web.Helpers.Chart.ApplySeries(Chart chart) +508 System.Web.Helpers.Chart.ExecuteChartAction(Action`1 action) +174 System.Web.Helpers.Chart.GetBytes(String format) +144 System.Web.Helpers.Chart.Write(String format) +96
的「股票「chartType應該允許Y的4個值,並且這似乎在使用反射器檢查Chart幫助程序的代碼時得到確認。我錯過了什麼嗎?
如果有人感到困惑,圖表似乎來自System.Web.UI.DataVisualization.Charting命名空間。而不是System.Web.Helpers命名空間 – Ben 2016-06-20 15:31:52