[英]iOS Charts - set minimum y axis range
我正在使用神話般的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
( Chart.setVisibleXRangeMaximum
用......)
3: Chart.setVisibleXRangeMinimum
(現在你的YRange
堂兄在哪里?!)
所以無論如何,這就是我所處的位置。 我看過文檔,但無濟於事。 幫我嗎?
customAxisMin
在最新的圖表中已棄用。
請改用屬性axisMinValue
!
看看下面的屬性。 應該可以解決你的問題。
/// 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
例如:
_chartView.leftAxis.customAxisMax = 35;
_chartView.leftAxis.customAxisMin = 0;
或_chartView.leftAxis.startAtZeroEnabled = YES;
對於圖表3(在圖表3.0.2上試用),這適用於:
chartView.leftAxis.axisMinimum = 0
默認情況下還有rightAxis(至少對於條形圖),如果您還沒有設置,網格將不會對齊:
chartView.rightAxis.axisMinimum = 0
注意:我最初將其寫為評論,但我認為這應該是一個答案,以便更容易找到最終來自谷歌的人。
linechart2.leftAxis.axisMinimum = chartDataline.getYMin() - 0.1
要使圖形僅關注y值范圍,請獲取數據集LineChartData的最小值,以及是否要為某些填充減去緩沖區。
有人說使用“linechart2.leftAxis.startAtZeroEnabled = false”,但不再在代碼中看到。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.