Series draw order

5 posts, 1 answers
  1. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 29 May 2013 Link to this post

    Hello,

    Is there a way to control the order of series when they draw?

    For example, we have at least two subsets of series that I would like to discern between. One should overlay the other for easier perception what is going on in the scatter line curves.

    Currently things paint and it's somewhat of a muddy mess to discern much of anything, especially for series of any magnitude, say a dozen tree nodes selected with 9x-series per node, some background, some foreground.

    Thank you!

    Regards,

    Michael Powell
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 03 Jun 2013 Link to this post

    Hi Michael,

    Thank you for writing.

    Currently there is no mechanism for changing the draw order. Series are drawn in the order they are stored in the Series collection of RadChartView. Once you have all the series you will plot on the chart you can reorder them in a way that you want.

    I hope this will help. Do not hesitate to write back with further questions.

    Regards,
    Ivan Petrov
    Telerik
    RadChart for WinForms is obsolete. Now what?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 05 Jun 2013 Link to this post

    Hmm. I want to say, no they're not. Because I insert several blue color series after several gray color series, and the gray ones are drawing on top of the blue ones. Perhaps, could you clarify, what do you mean "order in which they are inserted"? From first to last? or last to first? or some other criteria, like X,Y sort order?
  5. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 10 Jun 2013 Link to this post

    Hi Michael,

    Thank you for your reply.

    Digging further into this I found what might be causing this behavior. Here is a code fragment from RadChartView's drawing code:
    protected override void Initialize()
    {
      base.Initialize();
     
      this.drawParts.Clear();
                            
      for (int i = 0; i < this.area.Series.Count; i++)
      {
        if (this.area.Series[i] is AreaSeries)
        {
          this.drawParts.Insert(0, new AreaSeriesDrawPart((AreaSeries)this.area.Series[i], this));
        }
        else if (this.area.Series[i] is LineSeriesBase)
        {
        //........

    This code is executed on every redraw and what it does is, it iterate all series that are added to the chart and creates draw parts which contain painting logic. Then it inserts draw parts at the 0th position which means that the series are drawn in exactly the reverse order as they are stored in the chart Series collection. So if you add three series using something like this:

    chart.Add(RedSeries);
    chart.Add(GreenSeries);
    chart.Add(BlueSeries);

    The result will be the blue series on the bottom, the green series in the middle and the red series on top.
    In the same manner this code will produce the same drawing:

    chart.Add(GreenSeries);
    chart.Insert(0, RedSeries);
    chart.Add(BlueSeries);

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Regards,
    Ivan Petrov
    Telerik
    RadChart for WinForms is obsolete. Now what?
  6. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 12 Jun 2013 Link to this post

    Ah! Reverse order is the key then. That makes sense. Thanks.

    Actually, that starts to answer another question, but will follow up in another entry.
Back to Top
UI for WinForms is Visual Studio 2017 Ready