willdale / SwiftUICharts

A charts / plotting library for SwiftUI. Works on macOS, iOS, watchOS, and tvOS and has accessibility features built in.
MIT License
844 stars 105 forks source link

Add bar spacing option to grouped bar charts #97

Closed LJNIC closed 3 years ago

willdale commented 3 years ago

Hello,

I think the result of this is already possible by setting the Bar Width:

GroupedBarChartData(...
                    barStyle: BarStyle(barWidth: 0.5),
                    ...)

An issue with setting spacing in the HStack is that the extra padding needs to be taken account of if the touch functions of the data model.

func getDataPoint(touchLocation: CGPoint, chartSize: CGRect)

func getPointLocation(dataSet: GroupedBarDataSets, touchLocation: CGPoint, chartSize: CGRect) -> CGPoint?

not-lining-up

The touch marker no longer lines up with the centre of the bars.

Thanks, Will