Relative Content

Tag Archive for swiftswiftuiswiftcharts

Swift Chart foregroundstyle(for:) chartOverlay change colour of indicator based on where the user is dragging

I have a chart – see screenshot below. As you can see I have a gradient on the colour on the LineMark. I also have a Circle on the chartOverlay which tracks where the user drags. This is currently white, but I want to update that to be the color of the line at that point. I have found this (foregroundstyle(for:)) in the apple docs but doesn’t work with any data I feed it and always returns nil.

SwiftUI Charts Y-axis at lowest value in data

I am trying to create a SwiftUI chart that doesn’t start its y-axis at 0. This is the current issue – see screenshot below. Even though first data in stockPrices is 132.70 the chart starts at 0.