anyone figured out how to customise the Y axis values? id like to be able to process the. axis values and. then display them in the. format id like. eg. "1000" I'd like to display as "1k"
the furthest Ive been able to get is to get the axis to display a static text as the number ie "Y" in the code below. but I haven't been able to access the value. in the code below 'value' seems to be an AxisValue which stores the value but I can't seem to access it in a format I can process.
.chartYAxis {
AxisMarks() { value in
AxisGridLine()
AxisTick()
AxisValueLabel {
Text("Y")
}
}
}
id like to be able to do something like this:
.chartYAxis {
AxisMarks() { value in
AxisGridLine()
AxisTick()
AxisValueLabel {
if value > 1000000000000.0 {
Text("\(value / 1000000000000.0)t")
} else if value > 1000000000.0 {
Text("\(value / 1000000000.0)b")
} else if value > 1000000.0 {
Text("\(value / 1000000.0)m")
} else if value > 1000.0 {
Text("\(value / 1000.0)k")
}
}
}
}
5
2
5.9k