willdale / SwiftUICharts

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

How can I have solid horizontal grid lines #204

Closed Ale111 closed 2 years ago

Ale111 commented 2 years ago

I'm trying to create a StackedBarChart with an horizontal solid lines grid, but I have not found a way to do this. I don't know where I'm missing.

Here is the end of my makedata()

`
let yAxisGridStyle = GridStyle( numberOfLines: 7, lineColour: Color.black, lineWidth: 1, dash: [1000] )

    return StackedBarChartData(dataSets: data,
           groups: groups,
           barStyle: BarStyle(barWidth: 0.5),
           chartStyle: BarChartStyle(infoBoxPlacement: .header,
                                     xAxisGridStyle: yAxisGridStyle,
                                     xAxisLabelsFrom: .dataPoint(rotation: .degrees(0)),

// yAxisGridStyle: yAxisGridStyle, yAxisNumberOfLabels: 7, yAxisLabelType: .numeric, baseline: .zero, topLine: .maximum(of: costi.totale))) `

And here there is the result, as well, uncomment the line "yAxisGridStyle: yAxisGridStyle," has no effect on drawing horizontal grid. I need to have Horizontal lines grid only instead of verticals.

Simulator Screen Shot - iPhone 8 - 2022-05-27 at 17 29 26

Thanks in advance for the help!

willdale commented 2 years ago

Hi, are you using yAxisGrid or xAxisGrid in the view?

StackedBarChart(chartData: data)
    .yAxisGrid(chartData: data)
yAxisGridStyle: GridStyle(numberOfLines: 5,
                          lineColour: Color.gray.opacity(0.25),
                          dash: []),
Ale111 commented 2 years ago

Yeap.. I was missing .yAxisGrid... my fault. Thank you a lot. Work fine now! Simulator Screen Shot - iPhone 8 - 2022-05-27 at 20 21 47