In the above example, the requirement is to code the bars based on the value of the bar.

To achieve this you need to enable Dynamic Java Script and then add the following Java Script. You need to understand the code that is highlighted in Orange. Basically you can supply any number of colors and range values

for e.g. you need the following
{ if bar value between 0 and 5 then use Color Red}
{if bar value between 5 and 10 then use Color Blue}
{if bar value between 10 and 100 then use color Green}

Now we can split the above rule into following arrays (NOTE: you can use RGB values like new Color(255,0,0) )

Color Array

Next create a Low value array

Next create a high value array

And now replace the above arrays in the highlighted yellow text area below.

//import the necessary classes
import org.jfree.*;
import org.jfree.chart.axis.CategoryAxis;
//import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
//import org.jfree.chart.labels.CategoryItemLabelGenerator;
//import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.BarRenderer3D;
//import org.jfree.chart.renderer.category.CategoryItemRenderer;
//import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.ui.GradientPaintTransformType;
import org.jfree.ui.StandardGradientPaintTransformer;
import InfoPurple.CustomBarRenderer;

//CustomBarRenderer barRenderer = (CustomBarRenderer)plot.getRenderer();

// following is value based color coding of the bars
// for e.g if the bar value is between 17.0 and 20.0 then the first color entry Color(0,0,255,164) will be used
// if the bar value is between 20 and 21 then the second color entry will be used and so on.
// the first array is the list of color values, you can also just say,,Color.gree, Color.yellow and so on
//giving numeric color values for RGB gives flexibility on the various color shades
//the second array is the low range values and the third array is the high range values.
CustomBarRenderer barRenderer = new CustomBarRenderer(
new Paint[]
new Color(0,0,255,164),
new Color(0,255,0,164),
new Color(255,0,0,164),
new Color(10,255,255,164),
new Color(255,255,0,164),

new double[]

new double[]



Tags: , , , , , , , quickbooks,peachtree,sugarcrm,small business

Click on to boost InfoCaptor's Ego.

Your satisfaction is our top priority. If you are not completely satisfied, ask us and we will fully refund your purchase within 60 days.

Your subscription is backed by 100% money back guarantee.

Risk Free - Signup Now for just $29/month

Don't miss this, We offer you an amazing value proposition!

  • Free 60 minutes web consultation. We will look through your data, help and suggest the best way to visualize and most probably build a complete working dashboard. You will be amazed how much can be done in such a short time frame!
  • Absolutely Risk-Free, if you are not completely satisfied we will refund your subscription.
  • Check this step by step tutorial on how to build dashboard

Posted in Charts, General