Hi I am trying to build a pie chart with SwiftUI. I have created one with a dark background, and it seems like labels that correspond to each sector (labels are of black color) are not visible. It would be better to switch these labels' foreground color to white, but I don't see any suitable method to modify this. I tried both chartYAxis and chartXAxis (they worked for BarChart), but the color didn't change. Also, I added a separate struct that conforms to LabelStyle and defines makeBody in the following way
struct WhiteLabelStyle : LabelStyle {
func makeBody(configuration: Configuration) -> some View {
Label {
configuration.title.foregroundColor(.white)
} icon: {
configuration.icon
}
}
}
However, that also doesn't change color of labels on a chart. Below the complete code of the view:
ZStack {
CommonConstants.defaultBackground
Chart(data, id: \.name) { name, sales in
SectorMark(angle: .value("Value", sales))
.foregroundStyle(by: .value("Product category", name))
}
.labelStyle(WhiteLabelStyle())
}
Can you suggest any ways to manipulate with a chart comprised of SectorMarks