Number of rows in a Legend with LegendScrollbar?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
BobG
Newbie
Newbie
Posts: 4
Joined: Thu Jul 09, 2009 12:00 am

Number of rows in a Legend with LegendScrollbar?

Post by BobG » Fri Jul 10, 2009 3:29 pm

Hello,

I was wondering if there is a way to determine at run time the number of LegendItems that are currently being displayed within a Legend. I'm generating a tChart with a variable number of FastLine series, featuring a Legend on the right side and a LegendScrollbar using DrawStyle WhenNeeded. I'm allowing the form window to be resizable, so the number of LegendItems that are displayed changes with the form size.

Since I may have many FastLines in the chart, I'm trying to use the ClickSeries event to help the user identify which series was clicked. Right now the event temporarily increases the LinePen.Width of the selected line (and restores it with MouseUp), and the short line segment attached to the corresponding LegendItem thickens too. I like that. However, if for example I have N = 50 series in the chart but only M = 10 visible LegendItems (at one specific window size), there's a possibility that the clicked series might not be one of the 10 in the Legend, so I've been having the event adjust the Legend.FirstValue to automatically scroll the legend to make sure the clicked series name is always displayed.

However, if I simply set FirstValue to the clicked series index, when I select the last series in the collection (seriesIndex [N-1]) the legend shrinks to only 1 LegendItem high. What I'd really like to be able to do is set things up so that I can inquire what the displayed LegentItem count M is, and then adjust FirstValue as necessary to keep the number of LegendItems fixed for that window size.

So for
clicked seriesIndex in the range [0,M-1], set FirstValue to 0 (scroll to show the top M items)
clicked seriesIndex in [M,N-M-1], set FirstValue to seriesIndex-M/2 (scroll to show M items centered around seriesIndex) or
clicked seriesIndex in [N-M,N-1], set FirstValue to N-M (scroll to show the bottom M items)


Any recommendations greatly appreciated!
Thank you,
Bob

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

Re: Number of rows in a Legend with LegendScrollbar?

Post by Sandra » Mon Jul 13, 2009 10:43 am

Hello BobG,
However, if I simply set FirstValue to the clicked series index, when I select the last series in the collection (seriesIndex [N-1]) the legend shrinks to only 1 LegendItem high. What I'd really like to be able to do is set things up so that I can inquire what the displayed LegentItem count M is, and then adjust FirstValue as necessary to keep the number of LegendItems fixed for that window size.
I couldn't reproduce your problem here with last version of TeeChartFor .Net. Please, could you send us a simple example project we can run "as-is" to reproduce the problem here? .Now, you can attach your project directly in forums post. Also, you could said with version of TeeChartFor.Net you are using?

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

BobG
Newbie
Newbie
Posts: 4
Joined: Thu Jul 09, 2009 12:00 am

Re: Number of rows in a Legend with LegendScrollbar?

Post by BobG » Mon Jul 13, 2009 2:23 pm

I'm using TeeChart 2009 for .NET (Pro V4?) on Visual Studio 2005.

To clarify my original post, the tChart is anchored to all four sides of the parent form so it resizes along with the form. So the "problem" I'm trying to solve is determining the number of legend items that can be displayed at a given form/legend height.

I've uploaded a short project. When the form opens at its default size, only 20 of the 50 items are displayed. When maximized, all 50 show up. Rather than just setting the FirstValue to my clicked series index so the clicked series legend item is always at the top of the legend box, I want to be sure to be able to display the clicked series between its neighbors in the legend, even if the user shrinks the window so small that only 5 legend items show up.

Thank you very much,

Bob
Attachments
SteemaLegendResizeIssue.zip
(134.89 KiB) Downloaded 368 times

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

Re: Number of rows in a Legend with LegendScrollbar?

Post by Yeray » Tue Jul 14, 2009 10:23 am

Hi Bob,

There is no property to do that but you can calculate your MaxItemsInLegend knowing the chart height and how many pixels in height take for every item:

Code: Select all

int MaxItemsInLegend = (tChart1.Height / 17);
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

BobG
Newbie
Newbie
Posts: 4
Joined: Thu Jul 09, 2009 12:00 am

Re: Number of rows in a Legend with LegendScrollbar?

Post by BobG » Tue Jul 14, 2009 5:23 pm

Thank you, Yeray. I'll give that a try!

Post Reply