Reputation: 71
I have been using iOS Charts to create a bar graph. This is what I have so far:
I am having trouble achieving three things:
Help with any one of these would be greatly appreciated
Upvotes: 0
Views: 4202
Reputation: 1
lineChartView.leftAxis.axisMinimum = 0
lineChartView.xAxis.valueFormatter = IndexAxisValueFormatter(values: weekdays)
Upvotes: 0
Reputation: 7485
Please check below:
Changing the x-axis labels from (0-7) to Monday, Tuesday, Wednesday, etc. :
var weekdays: [String] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
barChartView.xAxis.valueFormatter = IndexAxisValueFormatter(values: weekdays)
Getting rid of the labels above the bars (1.0, 10.0, 20, etc.) :
let chartDataSet = BarChartDataSet(values: dataEntries, label: "")
chartDataSet.drawValuesEnabled = false
For lining bars to the xAxis :
barChartView.rightAxis.axisMinimum = 0.0
barChartView.leftAxis.axisMinimum = 0.0
Upvotes: 5
Reputation: 5075
Please share your code.
For problem number 1:
var xvalues: [String] = [String]()
for i in 0 ..< datapoints.count {
xvalues.append("custom text here")
}
barchartview.xAxis.valueFormatter = IndexAxisValueFormatter(values: xvalues)
For problem number 2:
let dataSet = BarChartDataSet()
dataSet.values = barChartDataEntries
// to hide values above the bars
dataSet.drawValuesEnabled = false
let data = BarChartData(dataSet: dataSet)
barchartview.data = data
Upvotes: 3