2016-03-24 83 views
0

如何设置最小x轴(水平线)。在下面的例子中它有7行。我如何让它只有4个区间?如何在iOS图表中设置最小x轴间隔?

此外,有没有一种方法可以去除每一个点上的圆圈,以使其只是普通线条?

仅供参考,我使用的是iOS-Charts library

example graph

+0

为了澄清,这是你正在使用的库:https://github.com/danielgindi/ios-charts? – Chris

+0

是我使用的同一个库 – sss

回答

0

要设置最低需要设置轴的customAxisMin财产轴线。

例如在迅速:

lineChartView.leftAxis.customAxisMin = 0 

要删除您必须设置drawCirclesEnabled属性falseLineChartDataSet

+0

lineChartView.leftAxis.customAxisMin = 0 是针对y轴的,但我需要针对x轴 – sss

0

对于点了一圈,禁用dataSet.isDrawCirclesEnabled

对于范围,请查看下面的内容。顺便说一句,你必须明白,因为你有7个X轴值,它会默认绘制它的每一个。如果你想要细致的控制,你需要改变渲染器的逻辑。

您可以设置最大范围为4,因此只会显示4个x轴值,否则您只应将4个数据值传入图表。

/// Sets the size of the area (range on the x-axis) that should be maximum visible at once (no further zomming out allowed). 
/// If this is e.g. set to 10, no more than 10 values on the x-axis can be viewed at once without scrolling. 
public func setVisibleXRangeMaximum(maxXRange: CGFloat) 
{ 
    let xScale = _deltaX/maxXRange 
    _viewPortHandler.setMinimumScaleX(xScale) 
} 

/// Sets the size of the area (range on the x-axis) that should be minimum visible at once (no further zooming in allowed). 
/// If this is e.g. set to 10, no less than 10 values on the x-axis can be viewed at once without scrolling. 
public func setVisibleXRangeMinimum(minXRange: CGFloat) 
{ 
    let xScale = _deltaX/minXRange 
    _viewPortHandler.setMaximumScaleX(xScale) 
} 
0

如果你想只显示4个间隔,那么你可以设置标签数为4

chartView.xAxis.labelCount = 4 

要隐藏圈,禁用drawCircleEnabled为ChratDataSet

chartDataSet.drawCirclesEnabled = false 
相关问题