Barseries Plot Width

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
kamla
Posts: 2
Joined: Wed Jun 03, 2020 1:25 am

Barseries Plot Width

Post by kamla » Tue Apr 27, 2021 6:09 am

Hi,

I have been added a barseries to a plot. I have the bars set to Groupbylocation and I set each at a subsequent point on the x-axis (i.e. x=0, x=1, x=2, etc.).
I then zoomtofit, but I end up with bars that are widely spaced. I want to find out how I can change the width of the bars.
I am using Groupbylocation because I display an annotation with the value at that location (in a mouseover event), so I would prefer to keep doing so (I know setting to groupbyindexfittowidth works, but makes my mouseover annotations off center). Is there any way to adjust this?

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

Re: Barseries Plot Width

Post by ArctionKestutis » Tue Apr 27, 2021 2:22 pm

The width of the bar is controlled by barSeries.BarThickness property. Is is in screen pixels [px], but for winforms application it is same as DIPs.
To convert AxisValue to screen coordinates you should use axisX.ValueToCoord() method. That is, get coordinates of adjacent Axis values (like x=1 and x=2) and difference will be the BarThickness you aiming to.
Don't forget to call this method when chart was rendered. For example, Chart.AfterRendering, Chart.SizeChanged or Axis.RangeChanged event handler would be good place.

Hope this helps.

kamla
Posts: 2
Joined: Wed Jun 03, 2020 1:25 am

Re: Barseries Plot Width

Post by kamla » Tue Apr 27, 2021 4:55 pm

This was exactly what I needed. Thank you. :)

Post Reply