Page 1 of 1

Trading Chart: Horizontal Scroll Bar Layered Over X Axis Labels

Posted: Thu Oct 15, 2020 9:32 pm
by JeffFerguson
I have a trading chart to which I have added a horizontal scroll bar. The scroll bar is visible but is layered over the labels for the X axis. See attached screen shot. How do I move the scroll bar to reside below the labels?

Re: Trading Chart: Horizontal Scroll Bar Layered Over X Axis Labels

Posted: Fri Oct 16, 2020 8:59 am
by Arction_LasseP
Hello Jeff,

If that is LightningChart's own scrollbar component (HorizontalScrollBar), you can change its position via Alignment and Offset properties. For example:

Code: Select all

            HorizontalScrollBar hsb = new HorizontalScrollBar(_tradingChart.GetInternalChart());
            hsb.Alignment = HorizontalScrollBarAlignment.BelowGraph;
            hsb.Offset.Y = 100;
            _tradingChart.GetInternalChart().HorizontalScrollBars.Add(hsb);
Change the Offfset.Y to find the most suitable position for the scrollbar.

Best regards,
Lasse

Re: Trading Chart: Horizontal Scroll Bar Layered Over X Axis Labels

Posted: Sat Oct 17, 2020 4:21 pm
by JeffFerguson
Thanks you, Lasse. With that, I have a followup question.

Is there a property on the chart that would give me the height of those X axis labels?

Re: Trading Chart: Horizontal Scroll Bar Layered Over X Axis Labels

Posted: Mon Oct 19, 2020 8:34 am
by Arction_LasseP
Hello Jeff,

The height of the axis labels, as well as the interactive axis area, are fixed. The axis area height (between the graph and the time range buttons) can be read via:

double axisThickness = _chart.GetInternalChart().ViewXY.XAxes[0].AxisThickness;

The X-axis labels have a fixed height of 15 pixels. However, since they are not all in the same row (months and years on different rows), you need to take the row into account as well. In the source code this is calculated as follows:

marker.Offset.Y = TimeScaleRowHeight / 2 + rowIndex * TimeScaleRowHeight;

TimeScaleRowHeight is the constant 15 pixels. rowIndex is 0 for days, 1 for months and 2 for years.

Hope this helps.
Best regards,
Lasse