Fixed series color for specific labels in Jasper Jfree charts

Fixed series color for specific series labels in Jasper jfree charts

We often face the situation where it has been asked to implement specific series color for each particular series in the different charts of jasper. Thus,here I am trying to provide solution for same:

Create two jasper reports one to publish pie chart and other to publish stacked bar chart.

In pie chart,

There are series and count values required in pie chart:


Let us suppose for the above mentioned pie chart we need following color customisation for each series label i.e,

  • Series1 – green
  • Series2 –orange
  • Series3- purple
  • Series4- dark blue


In order to achieve this, we can write custom code in java as follows:

public class PiePlotEnclosingReport implements JRChartCustomizer {

             public void customize(JFreeChart chart, JRChart jasperChart) {

plot.setSectionPaint(“seies1”, new Color(63, 156, 53));

plot.setSectionPaint(“seies2”, new Color(0, 152, 219));

plot.setSectionPaint(“seies3”, new Color(140, 24, 154));

plot.setSectionPaint(“seies4”, new Color(233, 131, 0));



Create jar file of the java code and add it in chart customiser property of chart in the format: ‘packagename.classname’ as follows:-

Refer the screenshot:



Check the result, on executing report. It will be shown as in the above screenshot. One can very well  identify how the colors for each series type got changed through the chart customiser code we have used.

Similarly, we can customise the series color in stacked bar chart using following piece of code:

public class StackedBarChart implements JRChartCustomizer {

       public void customize(JFreeChart chart, JRChart jasperChart) {
       CategoryItemRenderer renderer = chart.getCategoryPlot().getRenderer();

              CategoryDataset catDS = chart.getCategoryPlot().getDataset();

              Color seriesColor = null;

              for (int i = 0; i < catDS.getRowCount(); i++) {

                     if (catDS.getRowKey(i).toString().equalsIgnoreCase(“series1”)) {

                           seriesColor = new Color(255, 175, 175);

                     } else if (catDS.getRowKey(i).toString()

                                  .equalsIgnoreCase(“series2”)) {

                           seriesColor = new Color(166, 25, 46);

                     } else if (catDS.getRowKey(i).toString()

                                  .equalsIgnoreCase(“series3”)) {

                           seriesColor = new Color(63, 156, 53);

                     } else if (catDS.getRowKey(i).toString()

                                  .equalsIgnoreCase(“series4”)) {

                           seriesColor = new Color(16, 24, 32);







Hope it helps!!


Nisha Sahu

BI Developer




Date Input Controls/ Components in Pentaho CDE with a working example

Hello guys…!!!

In this post you will learn about how to create date input controls in CDE.
The dashboard images which I am going to show below are having lots of .css code. I’m not covering all the things but concentrating only on Date input controls in CDE.

My Environment :
BI Server: Pentaho 4.5
CTools: Not found the version numbers of  C-Tools(Unable to check them)– perhaps..! lesser than 13
Database : hsqldb (Comes along with Pentaho installation — A java based small db for servers like pentaho)
NOTE: Images are taken in this post after creating the dashboard, please find the yellow rectangular boxes to understand.

You need to work out @ 3 places in “Components” section.
1. Generic
2. Selects
3. Charts
Explained from step 1 to step 3
You need to work out  @ 1 places in “Data Sources” section. i.e, all in “Properties”
I’m not concentrating on Layout part for this example. So wherever the HtmlObject you find in this example replace them with your working HtmlObjects.

Step 1: Creating parameters
* Design your dashboard as per your requirement ( In the images you can find the sample designs).
 In the “Components” section:
1. Click on components
2. Click on Generic
3. Click on Date parameter
4. Go to properties give the name
eg: param_start_date
5. Click + symbol  per another date parameter
6. Go to properties give the name
eg: param_end_date

Find the  image

Step 2: Creating Date input Components
In the “Components” section
1. Click on Components
2. Click on Selects
3. Click on “Date input Component”
4. Go to Properties give name. eg: start_date in  my example
5. In the properties give HtmlObject. eg: start_date_select
* HtmlObject is the name of the column where you are putting
your dateinput control.
6. Give  Parameter.[It will appear once you try to type]
eg: In step 1, created parameters. So here give “param_start_date”
7. Give Listeners[click on it, you will find the list of Listeners. Click OK]
8. Repeat 3-7 for “end_date” Date input

Step 3:
Find the steps in image.

HtmlObject is the place where you are putting your chart.

Step 4: Applying parameters for Chart & Query
            In the “DataSources”
Find the steps in the image
Find the sub sequent image for  Parameters applying for chart & Query.

do same as shown in images.

Step 5:
Save the dashboard and then Click on “Preview” button.
See the images below for sample out put with date input controls.
Preview of the dashboard with out any input controls selection

Preview of the dashboard after selecting date input controls.. find the images below one by one.

Find the image for observing whether the chart becomes dynamic or not with different date input controls.

That’s it.. You are done with date input controls on dashboard.
Thank you for reading this small post.

[email protected]
Helical IT Solutions Pvt. Ltd,

Radar Charts (Spider Chart)


What is Radar Chart? A radar chart graphically shows the size of the gaps among five to ten performance areas. The chart displays the important categories of performance and makes visible concentrations of strengths and weaknesses. The relative position and angle of the axes is typically uninformative. Radar charts are visually striking, and can add interest to what would otherwise be a dry data presentation.

Generally used with

– To visually depict the incremental improvements over a period of time

– To measure performance against benchmarks

– As a visual snap shot of progress over several criteria


The following points need to be kept in mind while designing Radar charts.

– Also, with many data points, it becomes difficult to identify the values. In those cases, petal charts are used.

Industry Specific Example?

– Used to plot a players weakness & strength

– Control of quality improvement to display the performance metrics of any ongoing program

– Comparing various cars based on their fuel efficiency, manoeuvrability, pick-up and engine power

Pie Chart – Data Visualization


What is Pie Chart? A pie chart (or a circle graph) is a circular chart divided into sectors, illustrating proportion. In a pie chart, the arc length of each sector (and consequently its central angle and area), is proportional to the quantity it represents. When angles are measured with 1 turn as unit then a number of percent is identified with the same number of centiturns. Together, the sectors create a full disk. It is named for its resemblance to a pie which has been sliced. The size of the sectors are calculated by converting between percentage and degrees or by the use of a percentage protractor. The earliest known pie chart is generally credited to William Playfair’s Statistical Breviary of 1801.

When to use :

Its recommended to be used when a piece is to be compared with respect to the total.

Pie charts work particularly well when the slices represent 25 to 50% of the data, but in general, other plots such as the bar chart or the dot plot, or non-graphical methods such as tables, may be more adapted for representing certain information.

Do the parts make up a meaningful whole? If not, use a different chart. Only use a pie  chart if you can define the entire set in a way that makes sense to the viewer.

Are the parts mutually exclusive? If there is overlap between the parts, use a different chart.








Difficult to compare individual pieces

Do you want to compare the parts to each other or the parts to the whole? If the main purpose is to compare between the parts, use a different chart. The main purpose of the pie chart is to show part-whole relationships.

How many parts do you have? If there are more than five to seven, use a different chart. Pie charts with lots of slices (or slices of very different size) are hard to read.

– While designing pie chart, make sure that slices are mutually exclusive; by definition, they cannot overlap. The data therefore must not only sum up to a meaningful whole, but the values need to be categorized in such a way that they are not counted several times.

Research suggests that we look at the angle in the center, essentially reducing the chart to just the crossing lines there. We are not very good at measuring angles, but we recognize 90 and 180 degree angles with very high precision. Slices that cover half or a quarter of the circle will therefore stand out. Others can be compared with some success, but reading actual numbers from a pie chart is next to impossible.

Industry specific examples of Pie Chart Usage :-

If a company has five divisions, and the pie chart shows profits per division, the sum of all the slices/divisions is the total profits of the company.