Page 1 of 1
Legend drawn outside plotting area
Posted: Thu May 25, 2017 10:02 am
by 15679992
In the past we have been setting the legend alignment on our plots to the right of the plot i.e. Legend.Alignment = 1
This worked OK
We recently tried setting the Alignment to the top of the plot i.e. Legend.Alignment = 2
Although the legend does appear at the top of the plot it appears far over to the left so only the right hand part of the legend is visible (the left hand part of the legend is off the plot area).
If I move the mouse over the plot area it will eventually re-center itself correctly on the plot.
I also tried looking at the plot properties dialog and the Legend-Position tab showed no position selected.
Is there another property we need to set to center the legend?
Re: Legend drawn outside plotting area
Posted: Fri May 26, 2017 8:11 am
by Christopher
Hello!
Using the latest public release of TeeChart, the following code:
Code: Select all
private void InitializeChart()
{
Line series1 = new Line(tChart1.Chart);
series1.FillSampleValues();
tChart1.Legend.Alignment = LegendAlignments.Top;
}
gives me the following:
- TChart636313901917214266.png (14.81 KiB) Viewed 15776 times
Which version of TeeChart are you using? Can you give me a simple code example which reproduces your problem?
Re: Legend drawn outside plotting area
Posted: Fri May 26, 2017 1:52 pm
by 15679992
Christopher
The version of TeeChart.dll is 4.1.2011.4193.
We use a wrapper but we end up calling the following:-
x_chart.Legend.Visible = true;
x_chart.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series;
x_chart.Legend.CheckBoxes = true;
x_chart.Legend.Alignment = Steema.TeeChart.LegendAlignments.Top;
When the plot is first created we get the plot shown in the attachment with the legend too far over to the left.
If you resive the plot or move the mouse over the data then the legend suddenly moves into the center.
Thanks for any assistance.
Re: Legend drawn outside plotting area
Posted: Mon May 29, 2017 8:31 am
by Christopher
Hello -
The oldest version I presently have installed on my machine is 4.1.2013.5280 - running the following code:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
for (int i = 0; i < 3; i++)
{
Line line = new Line(tChart1.Chart);
line.Pointer.Visible = true;
line.FillSampleValues();
line.Title = "Series Title " + i.ToString();
}
tChart1.Legend.Visible = true;
tChart1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series;
tChart1.Legend.CheckBoxes = true;
tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Top;
}
gives me:
- TChart636316429624563798.png (40.03 KiB) Viewed 15740 times
Would you please be so kind as to run this code in a new WinForm project with just a TChart on the form?
Re: Legend drawn outside plotting area
Posted: Tue May 30, 2017 10:13 am
by 15679992
Christopher
We have several products using TChart in a similar way. And its the same version for all products.
All products use the same calls to setup the legend.
However one product does center the legend correctly whereas another has the legend positioned off the left hand side of the plot (as shown in my last file upload).
So I don't think it is the version.
I had assumed that although we think we are setting up the legend the same in all our products presumably there is something we are doing differently. Or there is something to do with how the chart is embedded in the dialog - maybe relating to resizing.
Can you think of anything that might cause the different behaviour?
Re: Legend drawn outside plotting area
Posted: Wed May 31, 2017 9:42 am
by Christopher
Hello,
petex wrote:
I had assumed that although we think we are setting up the legend the same in all our products presumably there is something we are doing differently. Or there is something to do with how the chart is embedded in the dialog - maybe relating to resizing.
Can you think of anything that might cause the different behaviour?
Difficult to say - maybe something is interfering with the timing of the paint order of TChart - are you running it on a separate thread?
Normally we'd ask for a minimal, complete and verifiable example [
MCVE] to enable us to reproduce the issue here and fix it. If the code I sent you in my last message does work correctly for a TChart object sitting on a WinForm designer, then in order to obtain a MCVE we'd have to ask you to modify this code so that the problem can be clearly seen. I understand that in your case this may not be as easy as it sounds, but other than getting lucky with a guess at what is happening I can't see any other way forward.
Re: Legend drawn outside plotting area
Posted: Fri Jun 02, 2017 9:02 am
by 15679992
Christopher
Its not multithreaded so that is not the issue.
Its a huge code base so I doubt it is practical to create a simple program to show the issue.
The plot is embedded in dialog which has other panels so I suspect it may be a sizing issue i.e. the legend is positioned before another panel is introduced which make resizes the plot but not the legend.
I am not a regular user of TChart (I just do occasional bug fixes). So can you tell me if there is a resize call that I could add at the end of the initialisation that might sort out any resizing problems?
Re: Legend drawn outside plotting area
Posted: Tue Jun 06, 2017 8:18 am
by Christopher
petex wrote:So can you tell me if there is a resize call that I could add at the end of the initialisation that might sort out any resizing problems?
Yes - TChart has a Resize event which it inherits from the Control class from which it derives.
Re: Legend drawn outside plotting area
Posted: Tue Jun 06, 2017 10:03 am
by 15679992
Christopher
Thanks, I will give it a try.