Jump to content
JChartFX Community
  • 0
greg.valainis@pa-tech.com

Change Legend Items on pareto chart

Question

I am trying to style a pareto but have run into a problem with the legend.  I change the bars of the pareto chart to be a different color than the default.  This works fine.  However the associated legend item does not change color either.  I want the square that represents the data in graph to change as well.  This only half way works.  The outline of said square has changed color, but the fill is white.  I want the fill to be this custom color, too.  Thank you for your help.

 Here is the code used to create the graph:


<div id="ChartDiv" style="width:400px;height:400px;">

</div>

<script>

$(document).ready(function(){

var data = [{"Location": "Main Street", "Number of Computers", 4},

   {"Location": "Church Street", "Number of Computers", 3},

   {"Location": "North Street", "Number of Computers", 1}];


var chart1 = new cfx.Chart();

chart1.setDataSource(data);

chart1.setGallery(cfx.Gallery.Pareto);

 

chart1.getSeries().getItem(0).setColor("#a12339");


chart1.setBackColor("#f5faeb");

chart1.getBorder().setColor("#f5faeb");

chart1.setBorder(cfx.SimpleBorder);


chart1.getView3D().setEnabled(true);

chart1.create("ChartDiv");


var heading = new cfx.Title;

heading.setText("Locations with Computers");

chart1.getTitles().add(heading);

chart1.getLegendBox().setDock(cfx.DockArea.Bottom);

chart1.getLegendBox().setContentLayout(cfx.ContentLayout.Near);

});

</script>

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

To make sure your chart only gets painted once, you should call chart1.create("ChartDiv") at the end of your block, if you modify the chart after the create call the chart will have to be repainted.

To get "filled" markers please add the following line

        chart1.getAllSeries().setMarkerStyle(cfx.MarkerStyle.Filled); 

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

×