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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×