Easy way to Move Series in front of Another

TeeChart for JavaScript for the HTML5 Canvas
Post Reply
jzarech
Newbie
Newbie
Posts: 58
Joined: Mon Jul 07, 2008 12:00 am

Easy way to Move Series in front of Another

Post by jzarech » Sun Sep 04, 2016 4:47 am

Hi Steema --

Without recoding my javascript too much -

Is there an easy way to move one series in front of another as it's being blocked.

I know I can recode and the series in a different order but I do a lot of index based updates and such and would rather not have to change that.

is there a Z-Order property or MoveSeriesUp or something like that?

Thanks so much,

Joseph
Attachments
moveforward.gif
Need to move blue line forward.
moveforward.gif (90.84 KiB) Viewed 12397 times

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Easy way to Move Series in front of Another

Post by Yeray » Mon Sep 05, 2016 8:26 am

Hello,

The series are in an array you can swap elements from as with any array. Ie:

Code: Select all

            var tmp = Chart1.series.items[0];
            Chart1.series.items[0] = Chart1.series.items[1];
            Chart1.series.items[1] = tmp;
If you want to do it with a function:

Code: Select all

        Array.prototype.swap = function(a, b) {
            var temp = this[a];
            this[a] = this[b];
            this[b] = temp;
        };
And then:

Code: Select all

            Chart1.series.items.swap(0,1);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

jzarech
Newbie
Newbie
Posts: 58
Joined: Mon Jul 07, 2008 12:00 am

Re: Easy way to Move Series in front of Another

Post by jzarech » Mon Sep 05, 2016 8:59 pm

Hi Yeray --

I think this is the same as just adding the series to the chart in a different order.

All my code that is array based will still have to be modified.

I was hoping for an answer that wouldn't require change all my array based index code.

Such as Series1.ZOrder = 0 or something like that.

I do appreciate your help however.

I'll just rewrite my code it's not a huuuuge deal. :)

Thanks again.

Joseph

Post Reply