Jump to content
JChartFX Community
  • 0
sgatade

Independent colors for bars in a single series

Question

I have a single series on my chart which depicts 3 different levels of authentications in a day...


chartMaster = new cfx.Chart();
var data = [1,7,46];
chartMaster.getLegendBox().setVisible(false);
chartMaster.getAllSeries().getPointLabels().setVisible(true);
chartMaster.setDataSource(data);
chartMaster.setGallery(cfx.Gallery.Bar);
chartMaster.getAxisY().setMin(0);
chartMaster.getAxisY().setMax(50);
chartMaster.getAxisX().getLabels().setItem(0, "EXECO");
chartMaster.getAxisX().getLabels().setItem(1, "MGMT");
chartMaster.getAxisX().getLabels().setItem(2, "EMP");

chartMaster.getSeries().getItem(0).setColor("#CC008B");

var divHolderMaster = document.getElementById('DivGraph');
        chartMaster.create(divHolderMaster);   

 I want to show these 3 bars in different colors. How to do this?

 Thanks in advance.... 

post-2107-1393974387671_thumb.gif

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Note the use of -1 when using getItem to modify the color for all series of the particular point. Even though you only have 1 series, it is better to use this in case you decide to show the legend box.
 
chart1.getAllSeries().setMultipleColors(true);
var points = chart1.getPoints();
points.getItem(-1, 0).setColor("#FF0000");
points.getItem(-1, 1).setColor("#00FF00");
points.getItem(-1, 2).setColor("#FFFF00");
 
JuanC 

Share this post


Link to post
Share on other sites

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...