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 to use custom y-axis labels #224

Closed mvolkmann closed 1 year ago

mvolkmann commented 1 year ago

So far I have been using computed y-axis labels by calling .yAxisLabels(chartData: chartData) on an instance of LineChart. Now I would like to use custom labels that I determine. I am setting the yAxisLabels property in my call to the LineChartData initializer to an array of strings. But those labels don't appear. What do I need to do to get it use my labels instead of the computed ones?

mvolkmann commented 1 year ago

I learned that three things are required to use custom y-axis labels:

1) In the call to the LineChartStyle initializer call, include yAxisLabelType: .custom, 2) In the LineChartData initializer call, include yAxisLabels: myLabels, where myLabels is an array of strings. 3) After theLineChartinitializer call, include the view modifier.yAxisLabels(chartData: myChartData, ...)`