Segment Splitter in Normal Chart

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
jberlien
Posts: 2
Joined: Mon May 09, 2022 4:43 pm

Segment Splitter in Normal Chart

Post by jberlien » Mon May 09, 2022 4:47 pm

There is a Segment Splitter that automatically displays on TradingChart, but doesn't seem to be available for a normal Segmented chart. Why is this? Could this be added? And in the meantime, is there any other way to visually separate y axis segments?

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: Segment Splitter in Normal Chart

Post by Arction_LasseP » Tue May 10, 2022 6:29 am

Hello,

This kind of Segment Splitter can be added in normal LightningChart as well. Technically, TradingChart is build over regular LightningChart library, therefore everything you see in TradingChart can also be done in the normal chart.

The Segment Splitter is actually a ConstantLine object placed between two Y-axis segments. Here are the most important parts of the code used internally in TradingChart.

Code: Select all

_constantLine = new ConstantLine(_view, _view.XAxes[0], _view.YAxes[0]);
_constantLine.LineStyle.Width = 5;
_constantLine.LineStyle.Color = Colors.LightBlue;
_constantLine.ShowInLegendBox = false;
_constantLine.IncludeInAutoFit = false;
_constantLine.LimitYToStackSegment = false;
_constantLine.ValueChanged += _constantLine_ValueChanged;
_view.ConstantLines.Add(_constantLine);
If you need to modify the heights of the segments by dragging the ConstantLine, as is done in TradingChart, subscribe to ValueChanged event (or alternatively MouseDown and MouseUp events) and adjust the segment heights inside the event.

There is actually one example in the normal chart, which uses ConstantLines as Segment Splitters. You could check "Multisegmented trading" in our Interactive Examples demo application.

Best regards,
Lasse

jberlien
Posts: 2
Joined: Mon May 09, 2022 4:43 pm

Re: Segment Splitter in Normal Chart

Post by jberlien » Fri May 13, 2022 3:54 pm

Thanks so much! I found that example and borrowed heavily from the code there. Now I can have working segment splitters on my normal LightningChart! Great!

Post Reply