Charts
Charts copied to clipboard
Bar Chart xVals Issues - Force Left Alignment and Labels are being overlapped
Hello
I am experiencing 2 issues with the barchart control please see below:
Issue 1 The xVals are not being left aligned and do not center within each individual Bar on the graph. Please can you advise how I can make it possible that the labels are left aligned rather the current right alignment that I am seeing. Please see screenshot below:

** Issue 2 ** The xVals are appearing overlapped when the label length is above 18 characters. Is it possible to increase the space between each Bar when using the BarGraph control? I have tried numerous things from StackOverflow and from reading the Issues raised on GitHub but have still not been able to tackle this problem. Please see screenshot below:

Please see all code being used to update the Bar Graph below:
// XAxis
let xAxis:XAxis = barChart.xAxis
xAxis.labelPosition = XAxis.LabelPosition.bottom
xAxis.labelFont = Constants.Font.fontWithSize(Constants.Font.Gotham, size: 10)
xAxis.labelWidth = CGFloat(2.0)
xAxis.drawGridLinesEnabled = false;
xAxis.centerAxisLabelsEnabled = true
xAxis.avoidFirstLastClippingEnabled = true
xAxis.wordWrapEnabled = true
xAxis.granularityEnabled = true
barChart.legend.enabled = false
barChart.rightAxis.enabled = false
barChart.leftAxis.enabled = false
barChart.xAxis.enabled = true
if xVals.count > 0 && yVals.count > 0 {
let set1:BarChartDataSet = BarChartDataSet(values: yVals, label: "DataSet")
set1.setColor(Constants.Color.Black)
set1.drawValuesEnabled = false
set1.highlightAlpha = 0.7
set1.highlightColor = Constants.Color.Blue
let data:BarChartData = BarChartData(dataSet: set1)
data.setValueFont(Constants.Font.fontWithSize(Constants.Font.GothamBook, size: 10))
barChart.xAxis.valueFormatter = IndexAxisValueFormatter(values: xVals)
barChart.xAxis.labelCount = xVals.count
barChart.xAxis.wordWrapEnabled = false
barChart.data = data;
barChart.setVisibleXRangeMinimum(visibleXRange)
barChart.setVisibleXRangeMaximum(visibleXRange)
}
overlap is known issues :(
about the align, try turn off centerAxisLabelsEnabled
@liuxuan30 doesn't work at all