Cla*_*lis 11 charts ios swift ios-charts
我正在使用神话般的iOS图表库(https://github.com/danielgindi/ios-charts),我很难在文档中找到任何支持此行为的内容.我想强制y轴始终显示0-35的范围.目前,如果我在说(0,9)中只有一个数据条目,则y轴将显示其范围为0-9.然而,当我在(1,32)处添加另一个条目时,突然我可以看到图形的顶部为35.
有三种方法看起来很有前景(因为它们是相关的),但它们并没有提供我正在寻找的行为类型.
1 :( Chart.setVisibleYRangeMaximum如果只是Minimum......)
2 :( Chart.setVisibleXRangeMaximum再没用了......)
3 :( Chart.setVisibleXRangeMinimum现在你的YRange堂兄在哪里?!)
所以无论如何,这就是我所处的位置.我看过文档,但无济于事.帮我吗?
Vla*_*d V 10
对于图表3(在图表3.0.2上尝试),此方法有效:
chartView.leftAxis.axisMinimum = 0
Run Code Online (Sandbox Code Playgroud)
默认情况下,也有一个rightAxis(至少对于条形图),并且如果您未同时设置,则网格将不会对齐:
chartView.rightAxis.axisMinimum = 0
Run Code Online (Sandbox Code Playgroud)
注意:最初我将其写为评论,但我认为这应该是一个答案,对于那些最终从Google那里找到的人来说更容易找到。
看看下面的属性.应该可以解决你的问题.
/// A custom minimum value for this axis.
/// If set, this value will not be calculated automatically depending on the provided data.
/// Use resetCustomAxisMin() to undo this.
/// Do not forget to set startAtZeroEnabled = false if you use this method.
/// Otherwise, the axis-minimum value will still be forced to 0.
public var customAxisMin = Double.NaN
/// Set a custom maximum value for this axis.
/// If set, this value will not be calculated automatically depending on the provided data.
/// Use resetCustomAxisMax() to undo this.
public var customAxisMax = Double.NaN
/// if true, the y-label entries will always start at zero
public var startAtZeroEnabled = true
Run Code Online (Sandbox Code Playgroud)
例如:
_chartView.leftAxis.customAxisMax = 35;
_chartView.leftAxis.customAxisMin = 0;
Run Code Online (Sandbox Code Playgroud)
要么 _chartView.leftAxis.startAtZeroEnabled = YES;