Page 1 of 1

Legend painting issues

Posted: Mon Nov 15, 2004 3:04 pm
by 8880867
If Legend.ResizeChart is false and the chart is zoomed in, the chart may be painted on top of the Legend. Other than setting ResizeChart to true, is there any way to prevent this? i.e. can the painting order be changed?

Also, I'm producing 3D charts with multiple surfaces, each of which is painted using a distinct colour. However, the legend entry for each surface does not reflect the colour - each one just has a rectangle with a white>black top>bottom gradient. Is there a particular property of the Surface series that I need to set? (At present, I'm just setting the Color property. Also, in some cases, I modify the surface colour in the GetValueColor event - could this affect matters? Either way, I want the legend to display the "nominal" colour for each surface.)

Many thanks for any advice you can provide.

Posted: Thu Nov 18, 2004 8:37 am
by Pep
Hi nathan,
If Legend.ResizeChart is false and the chart is zoomed in, the chart may be painted on top of the Legend. Other than setting ResizeChart to true, is there any way to prevent this? i.e. can the painting order be changed?
You can do this :

Code: Select all

private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
Steema.TeeChart.Legend l=tChart1.Legend;
l.CustomPosition=true;
l.Paint(tChart1.Graphics3D,l.ShapeBounds);
l.CustomPosition=false;
}
Also, I'm producing 3D charts with multiple surfaces, each of which is painted using a distinct colour. However, the legend entry for each surface does not reflect the colour - each one just has a rectangle with a white>black top>bottom gradient. Is there a particular property of the Surface series that I need to set? (At present, I'm just setting the Color property. Also, in some cases, I modify the surface colour in the GetValueColor event - could this affect matters? Either way, I want the legend to display the "nominal" colour for each surface.)
The way around this could be changing the Color Mode of the Grid 3d and then set a custom color for each value you add to the Surface :

Code: Select all

surface1.UseColorRange = false;
surface1.Add (10,13,10,"",Color.Yellow);
surface1.Add (11,13,20,"",Color.Blue);
......

Posted: Thu Nov 18, 2004 11:54 am
by 8880867
Thanks for the legend painting order suggestion - works perfectly!

I'll try out the other suggestion (not seeing surface colours in the legend) this afternoon ...

Posted: Mon Nov 22, 2004 5:33 pm
by 8880867
Two follow-up questions / remarks:

Firstly, whilst the legend painting order suggestion worked, it seems that it cannot be used if I actually want the legend to have a custom position - otherwise I end up with two legends being drawn. Any other suggestions?

Secondly, setting UseColorRange to false on the surface series does indeed give me the correct colour in the legend. (I don't even need to use the Add overload with a colour specified - it seems as though setting the Color on the surface series is sufficient.) And pre-empting a further question, setting UseColorRange to true and setting the StartColor, MidColor and EndColor properties allows me to control the colour gradient of the legend, which is very helpful!

Anyway, thanks again for your help.

Posted: Tue Nov 23, 2004 8:22 am
by Pep
Hi nathan,

it works fine using :

Code: Select all

private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
Steema.TeeChart.Legend l=tChart1.Legend; 
l.CustomPosition=true;			
l.Paint(tChart1.Graphics3D,l.ShapeBounds); 
//l.CustomPosition=false; 
}

private void Form1_Load(object sender, System.EventArgs e)
{
surface1.FillSampleValues(10);
tChart1.Legend.CustomPosition = true;
tChart1.Legend.Left = 60;
tChart1.Legend.Top = 30;
}

Posted: Tue Nov 23, 2004 1:36 pm
by 8880867
Indeed, I realised I could try that this morning! And, as you say, it works fine.

The only complication in my case is that I want to stick the legend in the top-right corner, which means that I need to know how big it is in order to work out its custom position - but this information isn't available until it has been displayed. However, it seems to work if I first display it "off-screen" (to avoid flicker) and then calculate its custom position ...