override which series appears in legend

TeeChart for JavaScript for the HTML5 Canvas
Post Reply
WCantrall
Newbie
Newbie
Posts: 27
Joined: Mon May 03, 2004 4:00 am
Location: USA
Contact:

override which series appears in legend

Post by WCantrall » Tue Apr 15, 2014 4:57 am

Is there a way to exclude a series from appearing in the legend? It must remain visible.

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

Re: override which series appears in legend

Post by Yeray » Tue Apr 15, 2014 7:33 am

Hello,
WCantrall wrote:Is there a way to exclude a series from appearing in the legend? It must remain visible.
I've just added it to the wish list to be implemented in future releases:
http://bugs.teechart.net/show_bug.cgi?id=731
Feel free to add your mail to the CC list to be automatically notified when an update arrives.
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

amjonas
Newbie
Newbie
Posts: 6
Joined: Mon Aug 26, 2013 12:00 am

Re: override which series appears in legend

Post by amjonas » Tue Jun 10, 2014 11:48 am

Has this been implemented yet?

We're porting some TeeChart_PHP scripts to Javascript / HTML5 and rely on it quite heavily. Happy to test a beta version, as our system won't be going live immediately.

Alternatively, is there a way to override a legend draw method/event?

Kind regards

Mark

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

Re: override which series appears in legend

Post by Yeray » Tue Jun 10, 2014 2:30 pm

Hi Mark,

I'm afraid it hasn't been implemented yet.
I've incremented the issue Importance so it can be reviewed asap.
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

amjonas
Newbie
Newbie
Posts: 9
Joined: Fri Jun 20, 2014 12:00 am

Re: override which series appears in legend

Post by amjonas » Mon Jan 26, 2015 12:19 pm

I've implemented a crude "showInLegend" into javascript version 2014.07.31.1.7 (attached) if that's of any help to anyone?

Hopefully it can be tidied up adopted in the main source :wink:

Mark

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

Re: override which series appears in legend

Post by Yeray » Mon Jan 26, 2015 12:24 pm

Hi Mark,

I've removed the attachment in your post because it contains a the TeeChart sources.
We'll study your implementation and we'll be back to you here asap.

**** EDIT ****
For those customers interested in the implementation Mark has just proposed, I'll try to explain it here:
1. Initialize the property at Tee.Series:

Code: Select all

Tee.Series=function(o,o2) {
  this.chart=null;
  this.data={ values:[], labels:[], source:null }

  this.yMandatory=true;
  this.horizAxis="bottom";
  this.vertAxis="left";
  this.showInLegend=true;	//AMJ: added ShowInLegend
  //...
2. Add the appropriate condition at drawSeries:

Code: Select all

  this.drawSeries=function(index,order) {
    var s=chart.series.items[index];
    if ((this.showHidden || s.visible) && s.showInLegend) {	//AMJ: added ShowInLegend
      this.drawItem(s.titleText(index),s,order,true);
      return true;
    }
    else
      return false;
  }
3. Change itemsCount accordingly:

Code: Select all

  this.itemsCount=function() {
    //...
    if ((st==="values") && (result>0))
       result=ss.firstVisible().legendCount();
    else
    {
      if (((st==="auto") && (result>1)) || (st==="series")) {    //AMJ: added ShowInLegend - remove count where not showInLegend?
        var t;
        for(t=0; t<ss.items.length; t++)
          if (!ss.items[t].showInLegend) result--;
      }
      else
      if (result==1)
        result=ss.firstVisible().legendCount();
    }
    //...
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

amjonas
Newbie
Newbie
Posts: 9
Joined: Fri Jun 20, 2014 12:00 am

Re: override which series appears in legend

Post by amjonas » Mon Jan 26, 2015 12:34 pm

Yeray wrote:I've removed the attachment in your post because it contains a the TeeChart sources.
Whoops - Sorry - didn't think!

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

Re: override which series appears in legend

Post by Yeray » Mon Jan 26, 2015 12:35 pm

Hi,
amjonas wrote:Whoops - Sorry - didn't think!
No worries. I've edited the post above to show your proposal.

Thanks for sharing it!
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

amjonas
Newbie
Newbie
Posts: 9
Joined: Fri Jun 20, 2014 12:00 am

Re: override which series appears in legend

Post by amjonas » Fri Jul 03, 2015 11:21 pm

There have been two releases of Javascript/HTML5 since this post, and it's not been implemented in the core.

Any problems with the implementation? it matches VCL/PHP which we also use.

Slightly bored of continuing to have to update the new releases!

Mark

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

Re: override which series appears in legend

Post by Yeray » Mon Jul 06, 2015 10:09 am

Hello Mark,

Excuse us for the delay here.
I've added your implementation to the internal sources so the next maintenance release with include it.
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

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

Re: override which series appears in legend

Post by Yeray » Tue Jul 07, 2015 8:11 am

Hello,

Note we decided to change showInLegend for legend.visible.
So with the next update you'll be able to do:

Code: Select all

Chart1.series.items[0].legend.visible=false;
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

Post Reply