HighCharts .NET X-Axis definition



我有一个包含值的列表。我想显示基于这些值的 HighCharts .NET 图表。问题是:我必须在代码中设置图表属性。它看起来像这样:

Highcharts chart = new Highcharts("chart");
chart.SetXAxis(new XAxis
{
Categories = new[] { results.date[0], results.date[1], results.date[2] }
});
chart.SetSeries(new Series
{
Data = new Data(new object[]
{results.Values[0], results.Values[1], results.Values[2]})
});

所以现在,图表仅在我的列表包含三个值时才有效。但也许该列表有 20、40 或更多的值。我该如何编码?

感谢您的帮助

找到了一个解决方案:

chart.SetXAxis(new[]
{
new XAxis { Categories = results.Date.ToArray()}
});
chart.SetSeries(
new Series
{
Data = new Data(results.Values.Cast<object>().ToArray())
}
);

最新更新