06-18-2011 12:21 AM
Is there a way to get a reference to the legend item of a plot?
Thanks,
Andy
Solved! Go to Solution.
06-20-2011 12:36 PM
Greetings,
What type of graph you are using to display your plot?
06-20-2011 12:50 PM
ScatterGraph
06-21-2011 02:51 PM
I might not completely understand what you're trying to do. However, it seems to me that when I drop a Scattergraph on my form and then drop a Legend on the form, I can access the legend like any other object via its name. IE MyLegend.Property=ValueForProperty.
Is that helpful? If not, can you provide more information about what you're trying to do?
06-21-2011 09:31 PM
I want a reference through the ScatterPlot object. In other words, if I have a reference to a ScatterPlot object at runtime, I now have to search the legend.legenditems collection for the plot's legend item. It would have been nice if I could reference directly the legend item tied to a plot--if there is one. Ie. ScatterPlot.LegendItem.
The workaround is to search the legend items for the legend item corresponding to the plot.
Andy
06-27-2011 05:13 AM
Hi Andeezle, from ScatterPlot you cannot get the LegendItem directly.
If you do not want to do the search in the Legend in the list, then you can do the following work around.
public class MyLegendItem : LegendItem
{
public MyLegendItem()
{
//Hook onto the property changed event.
PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); }
void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { // IF the property changed was Source then set the legend to the MyPlot.LegendItem.
if (e.PropertyName == "Source") { ((sender as LegendItem).Source as MyPlot).LegendItem = sender as LegendItem; } } } // My derived scatter plot class that exposes Legend property
public class MyPlot : ScatterPlot { public MyPlot() { } private LegendItem legend = null; public LegendItem LegendItem { get { return legend; } set { legend = value; } } }
07-06-2011 04:48 PM
Don't know much about scatter graph.
07-07-2011 11:50 AM
Greetings,
Did you have any specific questions about Scatter Graphs?