Search code examples
c#asp.netdotnethighcharts

Add multiple series in Dotnet highcharts asp.net c#


at the moment, I can create a series in a dotnet highchart that will display a line on the chart. I am wondering how I'm able to do this with another series. I'm not sure how to add it. Here is how I'm creating the first series

 Highcharts chart = new Highcharts("chart")
            .SetTitle(new Title { Text = "Incoming Stats" })
            .SetXAxis(new XAxis { Categories = stringArr })

            .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Amount Incoming" } })
            .SetSeries(new Series { Name = "Incomings", Data = new Data(objectArr) })

            ;
        ltrChart.Text = chart.ToHtmlString();

I basically want to add another series to this - the type of data will be exactly the same. So instead of adding stringArr and ObjectArr, the second time I will add stringArr2 and objectArr2. I'm sure it's a simple answer but I can't find a solution anywhere. Cheers in advance


Solution

  • Check out the examples at their website: https://dotnethighcharts.codeplex.com/SourceControl/latest#DotNet.Highcharts/DotNet.Highcharts.Samples/Controllers/DemoController.cs

    So basically you just give it an array instead of a single Series.

      .SetSeries(new[]
                    {
                        new Series { Name = "Tokyo", Data = new Data(ChartsData.TokioData) },
                        new Series { Name = "New York", Data = new Data(ChartsData.NewYorkData) },
                        new Series { Name = "Berlin", Data = new Data(ChartsData.BerlinData) },
                        new Series { Name = "London", Data = new Data(ChartsData.LondonData) }
                    }
                    );