Reputation: 85
I have a list with values. I want to show a HighCharts .NET chart based on these values. The problem is: I have to set the chart properties in my code. It looks like this:
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]})
});
So now, the chart only work if my list contains three values. But maybe the list has 20, 40, or more values. How can i code that?
Thanks for help
Upvotes: 1
Views: 394
Reputation: 85
Found a solution:
chart.SetXAxis(new[]
{
new XAxis { Categories = results.Date.ToArray()}
});
chart.SetSeries(
new Series
{
Data = new Data(results.Values.Cast<object>().ToArray())
}
);
Upvotes: 0