Page 1 of 1

Barseries Plot Width

Posted: Tue Apr 27, 2021 6:09 am
by kamla
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?

Re: Barseries Plot Width

Posted: Tue Apr 27, 2021 2:22 pm
by ArctionKestutis
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.

Re: Barseries Plot Width

Posted: Tue Apr 27, 2021 4:55 pm
by kamla
This was exactly what I needed. Thank you. :)