Legend resize

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Legend resize

Post by SPS » Tue Sep 22, 2009 4:27 pm

Hi,

When i try to resize a window with a legend in it, and there isnt enough room for the legend to draw completely i get the following error:

"Height must be non-negative"

at System.Windows.Rect.set_Height(Double value)
at Steema.TeeChart.WPF.Legend.ResizeChartRect(Rect& rect)
at Steema.TeeChart.WPF.Chart.DoDrawLegend(Rect& tmp)
at Steema.TeeChart.WPF.Chart.DrawTitlesAndLegend(DrawingContext g, Rect& tmp, Boolean BeforeSeries)
at Steema.TeeChart.WPF.Chart.InternalDraw(DrawingContext g, Boolean noTools)
at Steema.TeeChart.WPF.Chart.InternalDraw(DrawingContext g)
at Steema.TeeChart.WPF.TChart.Draw(DrawingContext g)
at Steema.TeeChart.WPF.TChart.OnRender(DrawingContext drawingContext)

Is there a way to remove the rectangle from the legend?

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

Re: Legend resize

Post by Yeray » Wed Sep 23, 2009 9:42 am

Hi SPS,

Of course, you can hide it as follows:

Code: Select all

tChart1.Legend.Visible = false;
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

SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Re: Legend resize

Post by SPS » Wed Sep 23, 2009 10:35 am

Yes i know, but i want the legend to be visisble. If i set the alignment of the legend to bottom or top i get the set_height error when resizing the window. If i set the alignment to right or left i dont get this error. So there seems to be a problem in the legend onpaint with the height of the rectangle. I Tried to make my own class for the legend and inherit from the legend and override the onpaint, but the chart legend doesnt have a setter.

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

Re: Legend resize

Post by Yeray » Wed Sep 23, 2009 11:22 am

Hi SPS,

Could you please send us a picture showing the chart just before getting the error? I can reproduce the error but only in a chart as small as the ChartRect has been already disappeared.
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

SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Re: Legend resize

Post by SPS » Wed Sep 23, 2009 11:41 am

Hi,

Yes that is what i get too, when the window is too small for the legend rect it will give the error. The project im working on is a dashboard where multiple small windows can be placed and can contain a chart. So if someone resize one of these windows too small it will give this error.

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

Re: Legend resize

Post by Yeray » Wed Sep 23, 2009 1:55 pm

Hi SPS,

We've just fixed a bug that could solve your problem in NET v2009 but to ensure that to you it would be helpful if you could send us a simple code snipped we can run as-is here to reproduce the problem here.

For example, the fixed problem was reproducible with the following:

Code: Select all

tChart1.Aspect.View3D = false;

for (int i = 0; i < 40; i++)
{
    tChart1.Series.Add(new Steema.TeeChart.WPF.Styles.Line());
    tChart1[i].FillSampleValues();
    tChart1[i].Title = "this is a series with a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long name";
}
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

SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Re: Legend resize

Post by SPS » Wed Sep 23, 2009 2:59 pm

Here is a sample project that reproduce the error when making the window as small as possible.
Attachments
sample1.zip
(11.9 KiB) Downloaded 486 times

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

Re: Legend resize

Post by Yeray » Wed Sep 23, 2009 3:11 pm

Hi SPS,

Are you sure that the project you've attached is reproducing the legend problem? Here it gives me another "Height must be non-negative." error:
System.ArgumentException was unhandled
Message="Height must be non-negative."
Source="WindowsBase"
StackTrace:
at System.Windows.Rect.set_Height(Double value)
at Steema.TeeChart.WPF.Chart.CalcWallsRect(Rect& r)
at Steema.TeeChart.WPF.Chart.InternalDraw(DrawingContext g, Boolean noTools)
at Steema.TeeChart.WPF.Chart.InternalDraw(DrawingContext g)
at Steema.TeeChart.WPF.TChart.Draw(DrawingContext g)
at Steema.TeeChart.WPF.TChart.OnRender(DrawingContext drawingContext)
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

SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Re: Legend resize

Post by SPS » Wed Sep 23, 2009 3:12 pm

Hi yes, because when removing the legend it works ok

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

Re: Legend resize

Post by Yeray » Thu Sep 24, 2009 9:20 am

Hi SPS,

Yes, I see in your error message that the legend rectangle is what is crashing for you. But here I can see the walls rectangle crashing in one computer (error posted above) and the title rectangle in another:
System.ArgumentException was unhandled
Message="Height must be non-negative."
Source="WindowsBase"
StackTrace:
at System.Windows.Rect.set_Height(Double value)
at Steema.TeeChart.WPF.Title.Draw(Graphics3D g, Rect& rect)
at Steema.TeeChart.WPF.Title.DoDraw(Graphics3D g, Rect& rect, Boolean CustomOnly, String Entity)
at Steema.TeeChart.WPF.Chart.DrawTitleFoot(Rect& rect, Boolean CustomOnly)
at Steema.TeeChart.WPF.Chart.DrawTitlesAndLegend(DrawingContext g, Rect& tmp, Boolean BeforeSeries)
at Steema.TeeChart.WPF.Chart.InternalDraw(DrawingContext g, Boolean noTools)
at Steema.TeeChart.WPF.Chart.InternalDraw(DrawingContext g)
at Steema.TeeChart.WPF.TChart.Draw(DrawingContext g)
at Steema.TeeChart.WPF.TChart.OnRender(DrawingContext drawingContext)
Anyway I've added this to be revised for next releases (TW16014439).

In the meanwhile I can only think on removing the legend at OnResize event when the window height is too small.
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

SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Re: Legend resize

Post by SPS » Thu Sep 24, 2009 12:46 pm

Ok, Thanks

SPS
Newbie
Newbie
Posts: 27
Joined: Tue May 26, 2009 12:00 am

Re: Legend resize

Post by SPS » Thu Sep 24, 2009 1:08 pm

Is there a way to get the legend height when its visibilty state is set to false ?

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

Re: Legend resize

Post by Yeray » Thu Sep 24, 2009 2:00 pm

Hi SPS,

I'm afraid that's not possible. The legend rectangle information isn't available until it is being drawn.
So you should save the heigh into a variable before hiding it.
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

Post Reply