This is a migrated thread and some comments may be shown as answers.

Series draw order

4 Answers 169 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 29 May 2013, 04:49 PM
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

4 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 03 Jun 2013, 01:24 PM
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?
0
Travis
Top achievements
Rank 1
answered on 06 Jun 2013, 12:25 AM
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?
0
Accepted
Ivan Petrov
Telerik team
answered on 10 Jun 2013, 06:51 PM
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?
0
Travis
Top achievements
Rank 1
answered on 12 Jun 2013, 11:18 AM
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.
Tags
ChartView
Asked by
Travis
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Travis
Top achievements
Rank 1
Share this question
or