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.
Legend painting issues
Hi nathan,
You can do this :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?
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;
}
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 :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.)
Code: Select all
surface1.UseColorRange = false;
surface1.Add (10,13,10,"",Color.Yellow);
surface1.Add (11,13,20,"",Color.Blue);
......
Pep Jorge
http://support.steema.com
http://support.steema.com
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.
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.
Hi nathan,
it works fine using :
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;
}
Pep Jorge
http://support.steema.com
http://support.steema.com
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 ...
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 ...