Non-continuous Legend Display

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Non-continuous Legend Display

Post by McMClark » Mon Sep 29, 2008 6:40 pm

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?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Sep 30, 2008 7:54 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Legend - Color Grid

Post by McMClark » Sat Oct 04, 2008 6:51 pm

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Oct 06, 2008 9:39 am

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!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply