简体   繁体   中英

HighCharts .NET X-Axis definition

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

Found a solution:

            chart.SetXAxis(new[]
            {
                new XAxis { Categories = results.Date.ToArray()}
            });

            chart.SetSeries(
                new Series
                {
                    Data = new Data(results.Values.Cast<object>().ToArray())
                }
            );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM