SwiftUICharts
SwiftUICharts copied to clipboard
pointMarkers modifier causing X Axis not to be visible until scrolled
A strange bug - with the attached code if you comment out the pointMarkers modifier the X Axis displays as expected, but with it in it appears not to be visible. If you wrap the chart in a ScrollView and trigger some motion, the X Axis does appear after being scrolled.

struct ContentView: View {
let data: LineChartData = chartData()
var body: some View {
ScrollView {
LineChart(chartData: data)
// Removing the pointMarkers modifier, and the X axis is always visible
.pointMarkers(chartData: data)
.xAxisLabels(chartData: data)
.yAxisLabels(chartData: data)
.id(data.id)
.frame(height: 200)
.padding()
}
}
static func chartData() -> LineChartData {
let dailyData = LineDataSet(dataPoints: [
LineChartDataPoint(value: 12000, xAxisLabel: "M", description: "Monday" ),
LineChartDataPoint(value: 10000, xAxisLabel: "T", description: "Tuesday" ),
LineChartDataPoint(value: 8000 , xAxisLabel: "W", description: "Wednesday"),
LineChartDataPoint(value: 17500, xAxisLabel: "T", description: "Thursday" ),
LineChartDataPoint(value: 16000, xAxisLabel: "F", description: "Friday" ),
LineChartDataPoint(value: 11000, xAxisLabel: "S", description: "Saturday" ),
LineChartDataPoint(value: 9000 , xAxisLabel: "S", description: "Sunday" ),
])
return LineChartData(dataSets: dailyData)
}
}
Hey @1337domz, sorry for the late reply!
Is this just in the previews? I can't replicate it on a device or a simulator but I can when in a preview.
Heres another issue #89 to do with x axis labels in previews.
Thanks, Will
Hey @willdale
Weirdly this happens on simulator but no on device. I have had issues with the library and disappearing X-axis on device though, and I thought I had found a minimum reproducible case but maybe not? Maybe there are multiple issues?
Here is it happening in the simulator though:
Xcode 13.2.1 iOS 15.2 Library added via SPM
https://user-images.githubusercontent.com/5438325/149403296-e3d2ee79-5eca-4229-9b86-67ec649e7f0d.mp4
+1
I do see this issue on real devices.
Actually, I see this issue regardless of whether I call .pointMarkers
. My chart displays x-axis labels initially. But all subsequent charts I display are missing the x-axis labels until I drag the left edge of the screen to the right a bit and let go. Then the labels appear.