Legend painting issues

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
nathan
Newbie
Newbie
Posts: 10
Joined: Mon Feb 16, 2004 5:00 am

Legend painting issues

Post by nathan » Mon Nov 15, 2004 3:04 pm

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.

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Nov 18, 2004 8:37 am

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);
......

nathan
Newbie
Newbie
Posts: 10
Joined: Mon Feb 16, 2004 5:00 am

Post by nathan » Thu Nov 18, 2004 11:54 am

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 ...

nathan
Newbie
Newbie
Posts: 10
Joined: Mon Feb 16, 2004 5:00 am

Post by nathan » Mon Nov 22, 2004 5:33 pm

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.

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Nov 23, 2004 8:22 am

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;
}

nathan
Newbie
Newbie
Posts: 10
Joined: Mon Feb 16, 2004 5:00 am

Post by nathan » Tue Nov 23, 2004 1:36 pm

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 ...

Post Reply