swimlane / ngx-charts

:bar_chart: Declarative Charting Framework for Angular
https://swimlane.github.io/ngx-charts/
MIT License
4.29k stars 1.15k forks source link

Width of bars on grouped vertical bar chart depends on height #1965

Open rsporsche opened 3 months ago

rsporsche commented 3 months ago

The width of the bars on the 'grouped vertical bar chart' change with the height of the chart. I would expect that the width of the bars should only depend on the width of the chart and the number of bars.

To Reproduce Open the example here: https://swimlane.github.io/ngx-charts/#/ngx-charts/bar-vertical-2d Change height from the default of 300, to 150, 120, 100, etc. and observe that the width of the bars is significantly reduced.

Expected behavior I expect that the width of the bars does not change when only the height of the chart is changed

Screenshots 300 high: image

120 high: image

yoandyshyno commented 3 months ago

This can be fixed by not applying "paddingInner" and "paddingOuter" on the result of function getGRoupScale. See: https://github.com/swimlane/ngx-charts/blob/ff89cfe08ada08ab898083be76cd0a6cc1adfdb2/projects/swimlane/ngx-charts/src/lib/bar-chart/bar-vertical-2d.component.ts#L267C2-L275C4