Text overruns Legend bounding box.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Text overruns Legend bounding box.

Post by BenW » Mon Jul 22, 2013 3:36 am

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Text overruns Legend bounding box.

Post by Narcís » Mon Jul 22, 2013 8:14 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Text overruns Legend bounding box.

Post by BenW » Mon Jul 22, 2013 2:34 pm

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.
Attachments
LegendTextOverrun.zip
(61.43 KiB) Downloaded 831 times

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Text overruns Legend bounding box.

Post by BenW » Mon Jul 22, 2013 3:07 pm

Hi Narcis.

Have also posted a sample that shows this issue (LegendTextOverrunExampleCode.zip). This sample is built with Visual Studio 2008.

Thanks,
Ben.
Attachments
LegendTextOverrunExampleCode.zip
Sample code to reproduce legend text overrun issue.
(15.67 KiB) Downloaded 857 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Text overruns Legend bounding box.

Post by Narcís » Mon Jul 22, 2013 3:15 pm

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
Chart1.jpg (71.53 KiB) Viewed 24185 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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Text overruns Legend bounding box.

Post by BenW » Mon Jul 22, 2013 7:39 pm

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.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Text overruns Legend bounding box.

Post by Sandra » Tue Jul 23, 2013 8:30 am

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:

Code: Select all

  tChart1.Legend.MaxNumRows = 3;
Could you tell us if adapting the property MaxNumRow as you like, solve your problem?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Text overruns Legend bounding box.

Post by BenW » Tue Jul 23, 2013 2:46 pm

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.
Attachments
ResultOfMaxNumRowsSetTo3.zip
Text still overruns legend rectangle with MaxNumRows set to 3.
(70.95 KiB) Downloaded 928 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Text overruns Legend bounding box.

Post by Sandra » Wed Jul 24, 2013 2:00 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Text overruns Legend bounding box.

Post by BenW » Wed Jul 24, 2013 8:48 pm

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.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Text overruns Legend bounding box.

Post by Yeray » Fri Jul 26, 2013 3:19 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Text overruns Legend bounding box.

Post by BenW » Tue Jul 30, 2013 10:08 pm

OK, thanks for the update Yeray...

Ben.

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Text overruns Legend bounding box.

Post by BenW » Wed Jul 31, 2013 2:14 am

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.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Text overruns Legend bounding box.

Post by Sandra » Wed Jul 31, 2013 10:16 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply