0

我正在使用 Charts API 并实现图表。我是新手,没有适用于 Swift 3 的适当文档。

我尝试并实施了,但不知道如何消除 y 的负比例。如何仅从 0 开始我的图表,所以它不显示负 y 刻度?

下面是我的代码:

fileprivate func ChartViewProperty() {

    barChartView.xAxis.labelPosition = .bottom
    barChartView.chartDescription?.text = ""
    barChartView.fitBars = true
    barChartView.pinchZoomEnabled = false
    self.barChartView.rightAxis.enabled = false
    barChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0)
    barChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0, easingOption: .easeInBounce)

    barChartView.xAxis.valueFormatter = IndexAxisValueFormatter(values:months)
    barChartView.xAxis.granularity = 1
    value.append([jan,feb,mar,apr,may,jun,jly,aug,sep,oct,nov,dec])
    setChart(dataPoints: months, values: value)
}. 

图片:

在此处输入图像描述

在此处输入图像描述

4

3 回答 3

1

尝试设置axisMinValue属性

我猜 barChartView.xAxis.axisMinValue

于 2017-06-29T06:04:21.617 回答
0

此行从条形图中删除所有负值:

chartView.rightAxis.axisMinimum = 0
于 2020-08-05T15:35:21.930 回答
0
fileprivate func ChartViewProperty() {

    //barChartView.xAxis.drawGridLinesEnabled = false
    barChartView.xAxis.drawAxisLineEnabled = false

    //barChartView
    barChartView.xAxis.drawLabelsEnabled = true

    //Space between x axis
    barChartView.xAxis.spaceMin  = 1.0
    barChartView.xAxis.spaceMax  = 1.0

    //Left axis bottom
    barChartView.leftAxis.spaceBottom = 0.0

    //Label Position
    barChartView.xAxis.labelPosition = .bottom

    //Description
    barChartView.chartDescription?.text = ""

    //Fit Bar
    barChartView.fitBars = false

    //Pinch Zoom
    barChartView.pinchZoomEnabled = false

    //Right x axis enabled
    self.barChartView.rightAxis.enabled = false

    //Animate barchart
    barChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0)
    barChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0, easingOption: .easeInBounce)
}
于 2017-06-30T05:33:23.763 回答