How to select Chart-Serie by Name or ID


Author
Message
joern kunze
joern kunze
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
Posts: 86, Visits: 221
Hi Experts,
Is there a way to get an existing point-series of a chart by name or ID (and check in the first place, if a series with that name does exist at all)?

I get the name / id within e.g. a mouse move event:
... ((NSeriesBase)hitTestResult.Object.ParentNode).Name;
... ((NSeriesBase)hitTestResult.Object.ParentNode).Id;

Now I want to remember just the name / id in case I have to change series properties later.
I am looking now for a way to retrieve the serie by name (or ID) something like:
if( _NevronChart.Chart[0].DoesSeriesExist(m_sNameOfSeries) {
NPointSeries series = _NevronChart.Chart[0].GetSeries(m_sNameOfSeries)....
}

Thanks for your help,
Joern





Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Joern,

You can look for chart elements by their unique id - it will stay the same even if the document is serialized / deserialized:


        Guid m_LastClickedSeriesId;

            NChart chart = nChartControl1.Charts[0];

            NBarSeries bar1 = new NBarSeries();
            bar1.Values.Add(10);
            bar1.Values.Add(20);
            bar1.Values.Add(30);
            chart.Series.Add(bar1);

            NBarSeries bar2 = new NBarSeries();
            bar2.Values.Add(10);
            bar2.Values.Add(20);
            bar2.Values.Add(40);
            bar2.MultiBarMode = MultiBarMode.Clustered;
            chart.Series.Add(bar2);

            nChartControl1.MouseDown += new MouseEventHandler(nChartControl1_MouseDown);
            nChartControl1.Refresh();


        void nChartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            NHitTestResult result = nChartControl1.HitTest(e.X, e.Y);

            if (result.ChartElement == ChartElement.DataPoint)
            {
                m_LastClickedSeriesId = result.Series.UniqueId;
            }
        }

        private void HighlightLastClickedBar()
        {
            NBarSeries series = nChartControl1.Document.GetElementFromUniqueId(m_LastClickedSeriesId) as NBarSeries;

            if (series != null)
            {
                series.FillStyle = new NColorFillStyle(Color.Red);
                nChartControl1.Refresh();
            }
        }

The above example shows how to store the unique id of the last clicked series and then to search / highlight.

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



Best Regards,
Nevron Support Team


joern kunze
joern kunze
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
Posts: 86, Visits: 221
.. thanks a lot! Just one tiny problem remains:
How do I get the serie topmost (so that it is displayed over all other series)?

Thanks again,
Joern
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Joern,

That's easy - you just need to make the series the first one in the series collection (e.g. change it position there).



Best Regards,
Nevron Support Team


joern kunze
joern kunze
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
Posts: 86, Visits: 221
... thanks for the hint. Unfortunatly, it is not quite the solution for my problem. I have already done it this way - but running into performance issues with that:
I have about 2000 series with about 70 000 data points each. Now the customer wants to select some serties for highlighting -> and this is rather slow (we "compete" against a compiled MATLAB-application with data visualisation which has the same data loaded).
Presently I always use - as proposed -
nChartControl1.Refresh();
after the series has been selected into the MouseMoveEvent for highlighting.
I was sort of hoping that there is another - faster - way of bringing the selected series topmost (may be without having to redraw the entire chart with 2000 series)

Best regards,
Joern
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Joern,

In this case you may consider to prerender the line series and paint them on the control as pre-rasterized. The advantage here is that this can be done in multithread fashion etc, however writing this type of code is beyond the service we provide on the forum...



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search