Page 1 of 1

Non-continuous Legend Display

Posted: Mon Sep 29, 2008 6:40 pm
by 9337074
I'm using the ColorGrid to display Integer values, 0-2, and adding them with the following code:
colorgrid.add(x,val , z, Data.get(0).getCountries().get(x),colors.get(new Integer(val)));
where val is in {0,1,2} and colors contains three colors.

The legend for this chart displays the values 0-2 in 8 steps with colors ranging from white to blue. I want instead to show just 0,1,2 in the legend with their associated colors.

How can I achieve this?

Posted: Tue Sep 30, 2008 7:54 am
by narcis
Hi McMClark,

You can try doing as in the All Features\Welcome!\Themes\Chart Palettes example in TeeChart.Features.jar demo included with TeeChart's installation. You could create a custom palette with 3 colors so that's what is displayed in the legend.

Legend - Color Grid

Posted: Sat Oct 04, 2008 6:51 pm
by 9337074
narcis wrote:Hi McMClark,

You can try doing as in the All Features\Welcome!\Themes\Chart Palettes example in TeeChart.Features.jar demo included with TeeChart's installation. You could create a custom palette with 3 colors so that's what is displayed in the legend.
I tried this and saw that it worked for the bar chart. However when I changed the Series type to Color Grid the legend stopped being updated by the palette changes. You can reproduce by changing only the series type in the sample code and running the example.

Posted: Mon Oct 06, 2008 9:39 am
by narcis
Hi,

For ColorGrid series this may not be the most appropiate example. In that case you can use this:

Code: Select all

        myChart.getLegend().setVisible(true);
        
        ColorGrid tmpSeries = new com.steema.teechart.styles.ColorGrid(myChart.getChart());
        
        tmpSeries.setUsePalette(true);
        tmpSeries.setPaletteSteps(5);
        tmpSeries.setUseColorRange(false);
        tmpSeries.clearPalette();
        tmpSeries.addPalette(1, Color.RED);
        tmpSeries.addPalette(2, Color.BLUE);
        tmpSeries.addPalette(3, Color.YELLOW);
        tmpSeries.addPalette(4, Color.WHITE);
        tmpSeries.addPalette(5, Color.GREEN);
        
        for (int x = 1; x < 6; x++)
        {
            for (int z = 1; z < 6; z++)
            {
                tmpSeries.add(x, x, z);
            }
        }
Hope this helps!