我有此条形图,它存在一些格式问题:
我想解决这些问题:
这是我绘制这些的方式:
func setBarChart (data: [(String,[Double])], label: String, xLabels: [String]) {
var entries: [BarChartDataEntry] = []
for (index, tuple) in data.enumerated() {
entries.append(BarChartDataEntry(x: Double(index), yValues: tuple.1))
}
let set = BarChartDataSet(values: entries, label: DataViewController.constants.labelDate)
set.setColor(UIColor.orange)
let data = BarChartData(dataSets: [set])
barChart.data = data
barChart.chartDescription?.text = label
barChart.xAxis.valueFormatter = IndexAxisValueFormatter(values: xLabels)
barChart.xAxis.granularity = 1
let legendEntry = LegendEntry()
legendEntry.formColor = UIColor.orange
legendEntry.label = "mean performance"
barChart.legend.setCustom(entries: [legendEntry]);
barChart.notifyDataSetChanged()
}
答案 0 :(得分:1)
我不知道您的前三个问题的答案,但是,我遇到的问题与您在第四个问题中描述的问题类似。我发现了两个解决标签重叠问题的方法:
祝你好运!