skip to main content
Charts > Programmer's documentation > Developing with the JViews Charts SDK > Creating a Chart > Customizing a treemap chart
 
Customizing a treemap chart
Additional customizations of a treemap chart can be found in Treemap charts.
To set the column to use for the area of each item:
*Use the following code:
 renderer.setAreaColumn(amount2005Column);
To differentiate the growth of each item through a color:
*Use the following code:
 renderer.setColorColumn(growthColumn); renderer.setColorScheme(IlvTreemapChartRenderer.COLORSCHEME_DIVERGING_GREEN_
RED);
For example, with regard to expenses, a high growth is alarming and a decrease is agreeable. Therefore, you can choose the color scheme that maps high values to red and low values to green:
To add a legend:
*To display the legend at the bottom of the treemap chart area, use the following code:
 chart.addLegend(new IlvLegend(), IlvChartLayout.SOUTH_BOTTOM);
The contents of the legend is automatically determined by the treemap chart renderer, based on the setting of the color column.
In this example, the legend labels represent the growth. The growth values are around 1, but you want to present them as percentage values, so you need to customize the formatting of the legend labels.
 renderer.setLegendLabelFormat( new DecimalFormat("+##0%;-##0%")
{ public StringBuffer format(double number, StringBuffer result,
                            FieldPosition fieldPosition) {
        return super.format(number-1, result, fieldPosition);
  } });

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.