Image

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
{
Color.red,
Color.blue,
Color.Green
}

Next create a Low value array
{
0,
5,
10
}

Next create a high value array
{
5,
10,
100
}

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.red, Color.blue,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[]
{
0.0,
1.0,
2.0,
4.0,
8.0

}
,
new double[]
{
1.0,
2.0,
4.0,
8.0,
20.0

}
);

plot.setRenderer(barRenderer);
barRenderer.setDrawBarOutline(false);

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

Click on to boost InfoCaptor's Ego.

It is super easy to create and use Dashboards Online at https://my.infocaptor.com (in the cloud)

OR

If you wish to work within your firewall, you can alsodownload and run dashboards on your computer or server (intranet/network etc)

Posted in Charts, General