sivaraj Posted April 8, 2014 Report Share Posted April 8, 2014 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); Quote Link to comment Share on other sites More sharing options...
Question
sivaraj
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 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);
Link to comment
Share on other sites
0 answers to this question
Recommended Posts
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.