Profile Picture

How to highlight a data series / data point in OnMouseMove ?

Posted By joern kunze 12 Years Ago

How to highlight a data series / data point in OnMouseMove ?

Author
Message
joern kunze
Posted 12 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 3 Months Ago
Posts: 86, Visits: 221
Hi Experts,

I have the following problem:
Nevron Chart with several data series (NPointSeries) (e.g. 200 series with 20000 points each)
The data series are to be displayed with different colours and when the mouse pointer is moved over a data point, this data point must be highlighted and the series it belongs to should be highlighted too.

My present solution looks as follows:

// Chart initializing: Before creating the "real" data series I create 2 "special" series additionaly :
// one for the hightlighted point, one for the highlighted serie
NPointSeries _seriesHighlightingPoint = getNewNevronSerie();
_seriesHighlightingPoint.AddDataPoint(new NDataPoint(double.NaN, double.NaN));
_oChart.Series.Add(_seriesHighlightingPoint);

NPointSeries _seriesHighlightingSeries = getNewNevronSerie();
_oChart.Series.Add(_seriesHighlightingSeries);

// In the appropriate mouse move event I determine the point / series where mouse is pointing to
// and assign this point / series to _seriesHighlightingPoint / _seriesHighlightingSeries
_seriesHighlightingPoint.XValues.SetValue(0,double)seriesSel.XValues.GetValueForIndex(SelectedPoint));
_seriesHighlightingPoint.Values.SetValue(0,(double)seriesSel.Values.GetValueForIndex(SelectedPoint));

_oChart.Series[1] = seriesMouseCursorPointsTo;

This is working quite as expected - with one problems I cant solve:

In the Chart legend I can easily disable the legend for the selected point:
((NPointSeries)_oChart.Series[0]).Legend.Mode = SeriesLegendMode.None;
But since the highlighted serie is just a reference, I cant do it that way for _seriesHighlightingSeries since this will disable the legend for the underlying data serie as well.

Is there an easy solution to disable the shown legend for _oChart.Series[1] (which is just - for instance - a reference to lets say _oChart.Series[5]) and keep the legend entry for the referenced serie (_oChart.Series[5]) ?
Or is it possible to separate the legend entry for _oChart.Series[1] so that it is displayed somehow appart from the "nomal" legend for the "real" data series?

Or may be you have got a better approach / easier solution for doing the highlighting of a serie / point in the MouseMoveEvent already?

Thank you very much for your help,
Best regards,
Joern



Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Joern,

We could not quite understand how exactly you highlight a series - do you change the color (or some other property) of the selected series? Also, why is it necessary to use additional series? It should be OK to just change the color of the existing series when it is selected.



Best Regards,
Nevron Support Team



joern kunze
Posted 12 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 3 Months Ago
Posts: 86, Visits: 221
... the main goal is to bring the selected series to the foreground since it might be partially hidden by data points of other series (the underlying data are high volume measured manufactoring tool parameters). Furthermore I want to have the data points plotted a little bit bigger so that it is clear to see which points are selected. And the presently selected point of the selected series should be topmost of that in a different colour and surrounded by a border line. Thats what I mean with "highlighting".
I could have achieved this by re-ordering the series so that the selected series becomes topmost - but then the legend is mixed up again with every selection of a new series.
The "highlighting" of the selected data point could be done also by changing just the property of the single point of the series - since in that case I have to take care to change its appereance back to normal when it is not selected anymore I have choosen the approach with an additional data series.

Hope this makes my intensions a little bit clearer. If not I could make you a little example project - please let me know.

Thanks again,
best regards,
Joern

Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

Hi Joern,

One way to workaround this is by having a custom legend:

   // create a chart with some dummy lines
   NChart chart = nChartControl1.Charts[0];

   Color[] colors = new Color[2];
   Random rand = new Random();

   for (int i = 0; i < colors.Length; i++)
   {
    NLineSeries line = new NLineSeries();

    line.Values.Add(rand.Next(100));
    line.Values.Add(rand.Next(100));
    line.Values.Add(rand.Next(100));

    line.BorderStyle.Color = colors[i];
    line.Name = "Line " + i.ToString();

    chart.Series.Add(line);
   }

   // switch the legend in manual mode
   NLegend legend = nChartControl1.Legends[0];
   legend.Mode = LegendMode.Manual;

   // populate with custom items, synchronized with the series in the chart
   for (int i = 0; i < chart.Series.Count; i++)
   {
    NLegendItemCellData licd = new NLegendItemCellData();
    NLineSeries line = chart.Series[i] as NLineSeries;
    if (line == null)
     continue;

    licd.Text = line.Name;
    licd.MarkBorderStyle = (NStrokeStyle)line.BorderStyle.Clone();
    licd.MarkShape = LegendMarkShape.None;

    legend.Data.Items.Add(licd);
   }

That way you'll have complete control over what is present in the legend. BTW it is not a good idea to add a series twice in the series collection.

Hope this helps - let us know if you meet any problems.



Best Regards,
Nevron Support Team



joern kunze
Posted 12 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 3 Months Ago
Posts: 86, Visits: 221
... thanks for the advice. I just run into a problem when the series is added twice (ok - you already adviced that it is not a good idea) on a Win2003 server system. The application crashes, when the series is added twice, e.g.:
_oNevronChart.Series[0] = _oNevronChart.Series[7];

On several computers (Win7, 64bit) this is working with exactly the same data without any problems, though.

Is there another simple way to bring the series topmost or do I have to always copy the data of the series I want to bring into foreground (since the data is rather huge, I would like to avoid this) ?

Thanks a lot,
Best regards,
Joern


Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

Hi Joern,

You must first disconnect the series before adding it again to the document for example:

NSeriesBase temp = chart.Series[2];
chart.Series.RemoveAt(2);
chart.Series[0] = temp;



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic