Page 1 of 1

How do I change the legend range/level for TColorGridSeries

Posted: Sat Apr 01, 2006 6:46 pm
by 9234539
For TColorGridSeries, how do I set the range of legend (Y value) manually, ex from 0 to 1 and show 5 levels in between, like the contour plot levels.

thanks.

Posted: Mon Apr 03, 2006 8:50 am
by narcis
Hi Fang,

You should create your own palette levels as told here.

Posted: Mon Apr 03, 2006 1:15 pm
by 9234539

Code: Select all

 
	Series1->FillSampleValues(32);
	Series1->UsePalette =true;
	Series1->UseColorRange = false;
	Series1->ClearPalette();
	Series1->AddPalette(0,clYellow);
	Series1->AddPalette(0.5,clGreen);
	Series1->AddPalette(1,clRed);
I tried the above code, but isn't quite what I want. I just don't want the lengend to show that many levels, but I do want the color to be smooth out in between.
But then I tried to set UseColorRange to true, it seems working but using colorrange color not the palette color. Am I doing right? Thanks.

Posted: Mon Apr 03, 2006 1:31 pm
by 9234539
Basically I want a long legend bar (continous color, which can be set) with only a few number besides it, like this.

|| 1.0
||
||
||
|| 0.5
||
||
||
|| 0.0

Most of the color annotated graph has a legend like that instead of like
|| 1.1034
|| 0.9453
|| 0.8545
|| 0.7434
|| 0.6434
|| 0.5344
|| 0.4343
|| 0.3323
|| 0.2344

Badly needed. Thanks.

Posted: Mon Apr 03, 2006 1:52 pm
by narcis
Hi Fang,

To achieve that you can use OnGetLegendText and set to an empty string the values you don't want to be displayed and modify the ones you want.

Posted: Mon Apr 03, 2006 2:10 pm
by 9234539
it'll be great if you guys add a feature like this.

'Cause esentially the legend for TColorGrid is another axis Y, I want to be able to adjust this axis as easy as other axises. Ex. set a range and steps

Thanks.

Posted: Mon Apr 03, 2006 2:21 pm
by narcis
Hi Fang,

You can also have that legend customly drawing on TeeChart's canvas.

Posted: Mon Apr 03, 2006 2:39 pm
by 9234539

Code: Select all

	Series1->UseColorRange = true;
	Series1->ClearPalette();
	for (size_t i=0; i <= 40; i++)
		Series1->AddPalette(0.025*i,clTeeColor);


void __fastcall TForm1::Chart1GetLegendText(TCustomAxisPanel *Sender,
	  TLegendStyle LegendStyle, int Index, AnsiString &LegendText)
{
	int m=Index-(Index/4)*4;
	if (m!=0) LegendText="";
}
I used the above code and it almost worked except that the funny thing is that the lenght of this legend bar is dependent on the number of palettes.

Posted: Mon Apr 03, 2006 3:27 pm
by 9335230
Hi Fang,

You can get a continuous legend doing one of these things:
- Setting chart->Legend->VertSpacing less than 0 (I have set -10)
- or setting chart->Legend->Symbol->Continuous = true; (Legend Symbols tab)

And for the legend texts, you should use a coefficient dependant on the
number of palleteSteps (series->PalleteSteps)

Beetle.

Posted: Mon Apr 03, 2006 4:13 pm
by 9234539
thanks Beetle. I'm doing that :)