Reduce SeriesEventMarkers dynamically when zooming in ViewXY

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
Igor
Posts: 67
Joined: Mon Sep 28, 2015 1:14 pm

Reduce SeriesEventMarkers dynamically when zooming in ViewXY

Post by Igor » Wed Dec 06, 2017 7:57 am

Hi,

is there a build in feature in LightningChart to reduce dynamically the amount of SeriesEventMarkers, if they are starting to overlap?
If not, do you have an advice how can I do this?

I'm using the version 8.1.5 of LightningChart.
2017-12-06_0849.png
2017-12-06_0849.png (68.58 KiB) Viewed 10265 times
# Overlapping SeriesEventMarker-Labels when zooming out.
2017-12-06_0850.png
2017-12-06_0850.png (125.22 KiB) Viewed 10265 times
thank you very much

Igor

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Reduce SeriesEventMarkers dynamically when zooming in Vi

Post by ArctionKestutis » Thu Dec 07, 2017 7:08 am

Hi Igor,

We don't have auto-placement feature for series markers. We do have for Series' titles as illustrated in our Demo App example "Minimal logarithmic axes". Also, internally contour labels use anti-overlap algorithm.
You could setup your own algorithm for Markers with set of rules you find necessary. For that you just need to read current position of label with SeriesEventMarker.Label.DrawRectangle after chart was rendered (e.g. in _chart.AfterRendering event). Next you compare labels with each other. If you find overlap, you can change visibility or other Label's property.

Hope this helps.
All the best.

Igor
Posts: 67
Joined: Mon Sep 28, 2015 1:14 pm

Re: Reduce SeriesEventMarkers dynamically when zooming in Vi

Post by Igor » Mon Jan 22, 2018 8:27 am

I’ve tried your suggestion, but I came to another issue with that.
I get an stackoverflow exception when I set the marker visibility in the AfterRendering-Event.
Have you any idea how I could fix that?

I've created a sample project but I can't send it to your support email address.
"Your outbound message contains suspicous content. The message has been discarded."
I packed the solution in a 1.5mb .zip file.
Edit: As I see it, this is a problem on our side. I will try to send the email again

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Reduce SeriesEventMarkers dynamically when zooming in Vi

Post by ArctionKestutis » Mon Jan 22, 2018 10:59 am

Hi Igor,

We got you email with project attached.
Please remember that each property change (including EventMarker visibility) will trigger new frame rendering. As you have multiple markers, rendering will triggered for each of them, unless you batch all update between _chart.BeginUpdate() and _chart.EndUpdate().
However, overflow error is due to infinite cycle: you update chart -> AfterREndering event is fired -> you change something in event handler -> chart is updated again. Please unsubscribe from AfterRendering event before modifying chart's properties

Code: Select all

        private void LightningChartUltimate1_AfterRendering(object sender, AfterRenderingEventArgs e)
        {
            lightningChartUltimate1.AfterRendering -= LightningChartUltimate1_AfterRendering;
            UpdateMarkers();
            lightningChartUltimate1.AfterRendering += LightningChartUltimate1_AfterRendering;
        }
The algorithm look almost fine, just not set lastVisibleMarker = eventMarker at the end of FOR loop.

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Reduce SeriesEventMarkers dynamically when zooming in Vi

Post by ArctionKestutis » Wed Jan 24, 2018 10:40 am

Actual problem that DrawData is not update if marker is not visible. Therefore the work flow need to be modified.
First, I would suggest subscribing to Axis’ RangeChanged and Chart’s SizeChanged events.
Second, in those event handlers you want to make all Markers visible, force rendering frame (BegingUPdate - EndEpdate) and do one time subscription to AfterRendering event.
Finally, after data have been rendered (AfterRendering event), you unsubscribe from AfterRendering and change visibility of Markers.

Igor
Posts: 67
Joined: Mon Sep 28, 2015 1:14 pm

Re: Reduce SeriesEventMarkers dynamically when zooming in Vi

Post by Igor » Fri Feb 02, 2018 7:45 am

Yes perfect. That was the solution.
Thank you

Post Reply