Jump to content
JChartFX Community
  • 0
sivaraj

change order of legend labels

Question

Hi Guys,

 I am trying to change the order of legend labels. But able to change using orderIndex. Please find below code which i tried.

 can u please suggest some way to changethe order.. so that i can get "% Accepted" label to be the last in legend(only in legend, not in series).

Code:

 

var chart1 = new cfx.Chart();

        

var items = [{"Date":"Feb 26","% Accepted":0,"Offered":0,"Accepted":0},{"Date":"Feb 27","% Accepted":0,"Offered":0,"Accepted":0},{"Date":"Feb 28","% Accepted":0,"Offered":0,"Accepted":0},{"Date":"Mar 1","% Accepted":0,"Offered":0,"Accepted":0},{"Date":"Mar 2","% Accepted":0,"Offered":0,"Accepted":0},{"Date":"Mar 3","% Accepted":0,"Offered":0,"Accepted":0},{"Date":"Mar 4","% Accepted":66.66666666666666,"Offered":3,"Accepted":2}];

chart1.setDataSource(items);

// chart1.setGallery(cfx.Gallery.Lines);

var lia1 = new cfx.LegendItemAttributes();

lia1.setOrderIndex(2);

var lia2 = new cfx.LegendItemAttributes();

lia2.setOrderIndex(0);

lia2.setVisible(false);

var lia3 = new cfx.LegendItemAttributes();

lia3.setOrderIndex(1);

chart1.getLegendBox().getItemAttributes().setItem(chart1.getSeries(), 0, lia2);

// chart1.getLegendBox().getItemAttributes().setItem(chart1.getSeries(), 2, lia3);

// chart1.getLegendBox().getItemAttributes().setItem(chart1.getSeries(), 0, lia1);

series3 = chart1.getSeries().getItem(0);

series1 = chart1.getSeries().getItem(1);

series2 = chart1.getSeries().getItem(2);

series1.setGallery(cfx.Gallery.Bar);

series2.setGallery(cfx.Gallery.Bar);

series3.setGallery(cfx.Gallery.Line);

series3.getPointLabels().setFormat("%v%%");

var axis2 = chart1.getAxisY2();

axis2.setVisible(true);

axis2.getGrids().getMajor().setVisible(false);

axis2.getLabelsFormat().setDecimals(1);

series3.setAxisY(axis2);

var divHolder = document.getElementById('ChartDiv');

chart1.create(divHolder);

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...