Jump to content
Software FX Community

Retrieving a SerLegendBox from MouseEventArgsX


User (Legacy)

Recommended Posts

The following code is intended to capture the users mouse click on a

serlegbox and report the number of titles (i.e., series) in the legend.

--

private void chart1_MouseDown(object sender, MouseEventArgsX e)

{

if (e.HitType.Equals(HitType.LegendBox)){

LegendBox lb = (LegendBox)e.Object;

MessageBox.Show(String.Format("I see you hit a

{0}",e.Object.ToString()));

MessageBox.Show(String.Format("I see {0}

LegendBox.Titles",lb.Titles.Count.ToString()));

}

}

--

e.Object is always a pretty much empty LegendBox except for size/loc stuff

needed for the strict control instance stuff (loc, dimensions, colors,

etc.). The first message box reports the correct type

(SoftwareFX.ChartFX.LegendBox), but the second messagebox always reports 0

titles. Given this behavior (which I assume is related to a shallow

copy/clone of the actual hit target), how would you recommend I:

1) Get the actual legend object that the user clicked on from the

event -and/or-

2) Determine which series/title was clicked, either from the e.object, or

perhaps from (e.X, e.Y).

My intent is to enable the user to toggle a series' visiblity by clicking on

it's legend title/glyph.

Thanks.

Link to comment
Share on other sites

The titles is not the series, titles can be added to a series legend but

they are not representative of the series, they are in addition to.

You are getting the actual legend object that the user click on, however,

the test and color information is not stored in this object it comes from

the chart series collection (chart.Series(i).Legend).

The index of the series that was clicked comes back to you is e.Series.

--

FP

Software FX, Inc.

Link to comment
Share on other sites

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:4Pyr4QP5CHA.3148@webserver1.softwarefx.com...

> The titles is not the series, titles can be added to a series legend but

> they are not representative of the series, they are in addition to.

> You are getting the actual legend object that the user click on, however,

> the test and color information is not stored in this object it comes from

> the chart series collection (chart.Series(i).Legend).

I understand now.

> The index of the series that was clicked comes back to you is e.Series.

Only if you clicked inside the bound of a chart, apparently. You always get

back 0 if the click was actually on the Legend box. The following code

always displays 0 no matter where on a legend box the user clicks:

--

private void chart1_MouseDown(object sender, MouseEventArgsX e)

{

if (e.HitType.Equals(HitType.LegendBox)){

MessageBox.Show(String.Format("You clicked series number

{0}",e.Series.ToString()));

}

}

--

Again, any suggestion on how to translate a click on a legend box into the

series in that legend box that was clicked? I need to react to a user click

on a series in a legend box with behavior that affects the indicated series.

Excellent support, gang.

Link to comment
Share on other sites

Oops !

I meant e.Point, I was printing both in my little sample (e.Series and

e.Point) and didn't realize that the one containing the index was e.Point.

Notice that what is being returned to you is the index of the element being

displayed, this may or may not correspond to the actual series in the chart.

For example if there are hidden series or empty labels (skipped), this

number is off. Also, this event is fired for the Values Legend as well, in

this case e.Point represents the point in the chart, but this may also be

off depending on the scrolling, hidden labels, etc.

So in conclusion you can use e.Point but always have in mind that what you

get is the index of the legend Item, consider all the cases in which this

may be different from the series index depending on your particular

situation.

--

FP

Software FX, Inc.

Link to comment
Share on other sites

Bingo. You guys thought of everything. ;)

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:6ta$u0P5CHA.2116@webserver1.softwarefx.com...

> Oops !

>

> I meant e.Point, I was printing both in my little sample (e.Series and

> e.Point) and didn't realize that the one containing the index was

e.Point.

>

> Notice that what is being returned to you is the index of the element

being

> displayed, this may or may not correspond to the actual series in the

chart.

> For example if there are hidden series or empty labels (skipped), this

> number is off. Also, this event is fired for the Values Legend as well, in

> this case e.Point represents the point in the chart, but this may also be

> off depending on the scrolling, hidden labels, etc.

>

> So in conclusion you can use e.Point but always have in mind that what you

> get is the index of the legend Item, consider all the cases in which this

> may be different from the series index depending on your particular

> situation.

>

> --

> FP

> Software FX, Inc.

>

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...