Cam*_*mon 6 charts ios swift ios-charts
我有一个使用Daniel Gindi iOS图表构建的条形图.它代表一段时间内的历史数据.我遇到的问题是数据是从左到右(新数据 - >旧数据)绘制的.我需要将它绘制为从右到左(旧数据 - >新数据).我知道我可以颠倒我输入数据的顺序BarChartData,但后来我的图表问题仍然是左对齐.它需要正确对齐.我在这里讨论了讨论反转x轴的问题以及如何解决它(目前不是框架的一个包含特性),但是我无法弄清楚实际需要做什么.以下是我需要的例子:
这就是我的图表目前的样子:
这就是我需要的样子:
我的问题
有没有办法颠倒x轴?
要么
有没有办法正确对齐图表?
以下是我的一些代码并尝试解决此问题:
class ViewController: UIViewController {
@IBOutlet weak var barChartView: BarChartView!
//...
func plotChart() {
// Create history data
//...
barChartView.data = chartData // 'chartData' is the BarChartData() containing all of the history information
// No efect
barChartView.legend.direction = .RightToLeft
// Chart breaks
barChartView.leftAxis.axisMinValue = 30
barChartView.leftAxis.axisMaxValue = 0
// Breaks the ability to zoom
barChartView.setVisibleXRangeMinimum(CGFloat(40))
barChartView.setVisibleXRangeMaximum(CGFloat(1))
}
}
Run Code Online (Sandbox Code Playgroud)
文件中chartLegend.swift有一个变量:
public var direction = ChartLegendDirection.LeftToRight
尝试更改该文件,它可能会解决您的问题。