I have to show [0, 25, 50, 75, 100] with dollar sign in Charts using swift iOS
var xValue = [25.0, 50.0]
var dollarValue = ["$25", "$50", "$75", "$100"]
Added in view didLoad
rightAxis.valueFormatter = IndexAxisValueFormatter(values: dollarValue)
func updateCharts() {
var chartDataEntry = [BarChartDataEntry]()
let spaceForBar = 10.0;
for i in 0..<xValue.count {
let value = BarChartDataEntry(x: Double(i) * spaceForBar, y: xValue[i])
chartDataEntry.append(value)
}
let chartDataSet = BarChartDataSet(entries: chartDataEntry, label: "10x In-Store ")
chartDataSet.colors = ChartColorTemplates.material()
let chartMain = BarChartData(dataSet: chartDataSet)
chartMain.barWidth = 5.0
horizontalBarChartContainnerView.animate(yAxisDuration: 0.5)
horizontalBarChartContainnerView.data = chartMain
}
I wanted to show 0 $25 $50 $75 $100 instead of 0 10 20 30 40 50
2
Answers
Add inside of viewDidLoad()
You need to create a custom formatter
and set the axis value formatter to your custom formatter