我在我的应用程序中使用条形图。我的要求就像我必须为单个 X 轴值绘制五个值。它可能在 ios 图表中吗? 请帮帮我!
var dataEntries: [BarChartDataEntry] = []
let xAxis:ChartXAxis = Barchartviews.xAxis
xAxis.drawAxisLineEnabled = false
xAxis.drawGridLinesEnabled = false
xAxis.getLongestLabel()
xAxis.avoidFirstLastClippingEnabled=true
xAxis.spaceBetweenLabels=10
for i in 0..<dataPoints.count {
let dataEntry = BarChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(yVals: dataEntries, label: "Units Sold")
chartDataSet.colors = ChartColorTemplates.joyful()
let chartData = BarChartData(xVals: Barmonths, dataSet: chartDataSet)
Barchartviews.data = chartData
let chartData1 = BarChartData(xVals: Barmonths, dataSet: chartDataSet)
Barchartviews.data = chartData1
Barchartviews.legend.enabled=false
Barchartviews.animate(xAxisDuration: 2.0, yAxisDuration: 2.0)
let groupSpace = 0.3
let barSpace = 0.05
let barWidth = 0.3
// it should be like (groupSpace + barSpace) * 2 + barWidth = 1.0
let groupCount = self.days.count // days is Array for xAxis labels
let startDay = 0.0
barChartData.barWidth = barWidth
barChartView.xAxis.axisMinimum = startDay
let gpWidth = barChartData.groupWidth(groupSpace: groupSpace, barSpace: barSpace)
barChartView.xAxis.axisMaximum = startDay + gpWidth * Double(groupCount)
barChartData.groupBars(fromX: startDay, groupSpace: groupSpace, barSpace: barSpace)
barChartView.notifyDataSetChanged()
关于ios - ios图表中单个X轴值的多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38888140/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |