Post

Replies

Boosts

Views

Activity

Reply to SectorMark foreground style colors
I assume your model is something similar to this. Then add the new color property as below. struct Data { let risultato: String let partite: Int // add this new property let color: Color } So in your Chart block you will need to set the color to foregroundStyle. Make sure you already set the colors in your array of data. Chart(data, id: \.risultato) { dataItem in SectorMark(angle: .value("Type", dataItem.partite), innerRadius: .ratio(0.7), angularInset: 1.5) .foregroundStyle(dataItem.color)) // update this line .annotation(position: .overlay){ Text("\(dataItem.partite)") .font(.caption) } } .frame(height: 150)
Mar ’24