Page 1 of 1
Text overruns Legend bounding box.
Posted: Mon Jul 22, 2013 3:36 am
by 9787981
Hello.
I have an issue where when I have 12 series configured and the top legend is used, the text in the legend for the 12 series overruns the right most edge. I have uploaded an attachment (LegendTextOverrun.rtf) that visuallizes this.
My question is, is there a way to pad the width of the legend, or some other technique to correct this situation. This only seems to be an issue when we have 12 series (the max we allow in our application), configured.
As an alternative perhaps, is there a way to force the top legend to show 2 rows of 6 series titles and checkboxes?
Any advice/guidance would be appreciated to work around this issue.
Thanks,
Ben.
Re: Text overruns Legend bounding box.
Posted: Mon Jul 22, 2013 8:14 am
by narcis
BenW wrote:
I have uploaded an attachment (LegendTextOverrun.rtf) that visuallizes this.
I'm afraid the attachment failed, I can not see it here. You might have missed an error message. Please try compressing it in a zip package and including it again. A simple example project we can run "as-is" to reproduce the problem here would be very helpful too.
Thanks in advance.
Re: Text overruns Legend bounding box.
Posted: Mon Jul 22, 2013 2:34 pm
by 9787981
Hi NarcĂs!
It's been a long time, since we communicated last, I hope you are doing well!
The file has been uploaded as LegendTextOverrun.zip. We are using a very old version (version 2 ) of the .NET Teechart, and I know you don't support this version, but I'm wondering if that version supported a way to pad the legend width (or some such), so that the text would stay within the legend rectangle?
Regards,
Ben.
Re: Text overruns Legend bounding box.
Posted: Mon Jul 22, 2013 3:07 pm
by 9787981
Hi Narcis.
Have also posted a sample that shows this issue (LegendTextOverrunExampleCode.zip). This sample is built with Visual Studio 2008.
Thanks,
Ben.
Re: Text overruns Legend bounding box.
Posted: Mon Jul 22, 2013 3:15 pm
by narcis
Hi Ben,
It's been a long time, since we communicated last, I hope you are doing well!
Yes, thanks. Hope everything is well with you!
The file has been uploaded as LegendTextOverrun.zip. We are using a very old version (version 2 ) of the .NET Teechart, and I know you don't support this version, but I'm wondering if that version supported a way to pad the legend width (or some such), so that the text would stay within the legend rectangle?
Current TeeChart for .NET version is version 2013 (aka v4). No code maintenance is being done in v2. However, we can answer to technical inquiries for this version.
Back to the issue, I'm not able to reproduce it with v2013 and this code:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Top;
tChart1.Legend.MaxNumRows = 1;
tChart1.Legend.CheckBoxes = true;
for (int i = 0; i < 12; i++)
{
tChart1.Series.Add(new Steema.TeeChart.Styles.Line()).FillSampleValues();
}
}
which produces this chart:
- Chart1.jpg (71.53 KiB) Viewed 24134 times
Can you reproduce the problem with this code? If not, can you please modify it so that we can try to reproduce the problem here?
Thanks in advance.
Re: Text overruns Legend bounding box.
Posted: Mon Jul 22, 2013 7:39 pm
by 9787981
Hi Narcis.
Even though your sample code has 12 pens, the legend is only showing 4 pens. Shouldn't it be showing 12 pens? It is important to our customer to be able to see all pens configured on the legend.
I did try the copy and pasting the following section of code:
tChart1.Aspect.View3D = false;
tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Top;
tChart1.Legend.MaxNumRows = 1;
tChart1.Legend.CheckBoxes = true;
but sadly that made no difference to the 12 pen legend text overrun issue.
Also, I posted some code that demonstrtes the issue. Have you received that?
Ben.
Re: Text overruns Legend bounding box.
Posted: Tue Jul 23, 2013 8:30 am
by 10050769
Hello Ben,
If you want see the 12 pens in the legend, you only need adapt the property of legend MaxNumRows as you need. For example, you can change this value, from 1 to 3 as do in next line of code:
Could you tell us if adapting the property MaxNumRow as you like, solve your problem?
Thanks,
Re: Text overruns Legend bounding box.
Posted: Tue Jul 23, 2013 2:46 pm
by 9787981
Hi Sandra.
Setting the value to 3 made no difference using the the code sent by Narcis in my test sample (please see attched screen capture in ResultOfMaxNumRowsSetTo3.zip).
It seems that if the width of the Form is wide enough to hold all 12 pens, then the legend will show all 12 pens in a single row instead of forcing them over 3 rows. Is there a way to force the legend to say show the pens over 2 rows?
As an alternative approach and if it's not possible to pad the legend rectangle with a few extra pixels to have the text show within the bounds of the rectangle, is it possible to create a custom legend that shows in a similar manner to the Steema legend?
Thanks,
Ben.
Re: Text overruns Legend bounding box.
Posted: Wed Jul 24, 2013 2:00 pm
by 10050769
Hello BenW,
Ok. I have tried to reproduce your problem using version 2 and version 4 of TeeChartFor.Net and I inform you I can reproduce your problem in latest version 2 of TeeChartFor.Net but not in latest version 4 of TeeChartFor.Net. Therefore, your problem is fixed for latest version 4 of TeeChartFor.Net. Would be very grateful if you can check your project in latest version 4 Build 4.1.2013.05283 and tell us your results. You can download the evaluation version
here.
On the other hand, working with latest version 2 you can try to solve the problem creating a custom legend as is demonstrated in the example Christopher Ireland posted
here.
I hope will helps.
Thanks,
Re: Text overruns Legend bounding box.
Posted: Wed Jul 24, 2013 8:48 pm
by 9787981
Hi Sandra.
Thanks for confrming that this is an issue on V2.
Is there some programatic way to pad the width of the legend rectangle, independently of its contents?
Regards,
Ben.
Re: Text overruns Legend bounding box.
Posted: Fri Jul 26, 2013 3:19 pm
by yeray
Hi Ben,
The only way I can think right now would be to hide the legend and use custom drawing techniques to drawn your custom legend manually.
Re: Text overruns Legend bounding box.
Posted: Tue Jul 30, 2013 10:08 pm
by 9787981
OK, thanks for the update Yeray...
Ben.
Re: Text overruns Legend bounding box.
Posted: Wed Jul 31, 2013 2:14 am
by 9787981
Hi.
I'm trying the evaluation version 4 in place of an official version 2. There were a couple of minor compile errors that needed to be fixed up in moving from V2 to V4, easy to do. However there is a section of code that retrieves the chart Bitmap:
Bitmap bitmap = this.tChart1.Bitmap;
I can't really figure out why, but with V4 this call is throwing a System.NullReferenceException exception (this wasn't ever an issue under V2), the only piece of context after this call in the stack trace is the following line:
> TeeChart.dll!Steema.TeeChart.Chart.Bitmap(int width, int height, System.Drawing.Imaging.PixelFormat pixelformat) + 0x16e bytes
The System.NullReferenceException is also thrown with the following stack trace:
TeeChart.dll!Steema.TeeChart.TChart.OnPaint(System.Windows.Forms.PaintEventArgs pe) + 0x1f7 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs e = {ClipRectangle = {X=0,Y=0,Width=595,Height=492}}, short layer, bool disposeEventArgs = false) + 0xa8 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WmPaint(ref System.Windows.Forms.Message m) + 0xa9f bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x4e6 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x46 bytes
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg = 15, System.IntPtr wparam, System.IntPtr lparam) + 0xb5 bytes
[Native to Managed Transition]
[Managed to Native Transition]
Is there a V2 to V4 upgrade best practices document that is available that perhaps documents the potential cause of this behaviour, and perhaps how to work around it?
Thanks,
Ben.
Re: Text overruns Legend bounding box.
Posted: Wed Jul 31, 2013 10:16 am
by 10050769
Hello BenW,
I'm trying the evaluation version 4 in place of an official version 2. There were a couple of minor compile errors that needed to be fixed up in moving from V2 to V4, easy to do. However there is a section of code that retrieves the chart Bitmap:
I can not reproduce your problem using next code:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
line1 = new Line(tChart1.Chart);
line1.FillSampleValues();
Bitmap bmp = tChart1.Bitmap;
}
You can reproduce it using my code? If you using my code the problem doesn't appear, Could you please, attach for us a simple project where your problem appears? On the other hand, you can use tChart1.Draw() method if you use Bitmap to redraw() chart.
Is there a V2 to V4 upgrade best practices document that is available that perhaps documents the potential cause of this behavior, and perhaps how to work around it?
The all code as you use in V2 should work for V4, but is possible there are some modifications. My recommendations is that you taking a look in the TeeChart Tutorial and References documentation and TeeChartFor.Net Demo to check the methods as you believe change. Moreover, if you have any problems, please let me know and we will try to help you.
Thanks,