Need help on Multi Line Series chart

2 posts, 0 answers
  1. Ravi
    Ravi avatar
    5 posts
    Member since:
    May 2016

    Posted 08 Jun 2016 Link to this post

    I am plotting WeekNumber of the year on X-axis, and Number of Requests of a particular school on to Y-axis of a Line Series.

    Results of a Stored Procedure are assigned to a List of section-requests, by passing School ID, and a date range.

    The output of Stored procedure gives: Number of Requests per week, Created Date, Week Number (of the Year), School Name.

    Code calls stored procedure 5 times, and stores the results in 5 individual Lists. Code loops through an array of 5 Lists (section-requests) .

    By using the LineSeries, AxisItem, and CategorySeriesItem , I have created a Multi-Line chart. 

    My issues are:
    (1) Once the first List plots on the first LineChart, because of the looping as individual Lists, the Week Number of the second List is starting from where the Week Number of the first List ended.  Is there a way that I can group all the Lists with the LineSeries, and plot only one set of Week Numbers (X axis) and related LineSeries (Y axis) for each individual school?  Please take a look at the Line chart in the attached file

    (2) If there is no section-request in a particular week, I need logic to treat “Number of Requests per week” as zero.

    For Loop Code:

    for (int i = 0; i < arrMasterList.Length; i++)
        int intCount = arrMasterList[i].Count;

        foreach (var sectionRequest in arrMasterList[i])
            intSecReqs = sectionRequest.NumberOfRequestsPerWeek;

            if (intSecReqs >= 0)
                AxisItem item = new AxisItem();
                item.LabelText = "Wk: " + sectionRequest.WeekNumber;

                CategorySeriesItem categorySeriesItem = new CategorySeriesItem();
                categorySeriesItem.Y = intSecReqs;


       intMaxValueReqs = lstSecReqs.Max();

       LineChart.PlotArea.YAxis.MinValue = 0;
       LineChart.PlotArea.YAxis.MaxValue = intMaxValueReqs + 10;
       LineChart.PlotArea.YAxis.MinorGridLines.Color = Color.White;
       LineChart.PlotArea.XAxis.MajorGridLines.Color = Color.White; 
       LineChart.PlotArea.XAxis.TitleAppearance.Text = "Week number";

  2. Danail Vasilev
    Danail Vasilev avatar
    1502 posts

    Posted 13 Jun 2016 Link to this post

    Hi Ravi,

    Basically, you have two options:
         1) Use category series (i.e., line series). This means each y-value will be aligned over the corresponding x-axis category. In that case you should create null y-values for missing x-axis categories, so that the y-values can be properly aligned.
         2) Use numeric series (i.e., scatterline series). In that case you can set the x for each y from the series item. This may be the easier approach.

    You can also use binding for both approaches.

    Danail Vasilev
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top