2017-06-29 6 views
0

Ich verwende Charts API und Implementierungsdiagramm. Ich bin neu darin und es gibt keine richtige Dokumentation für Swift 3.Balkendiagramm gibt negative Werte

Ich habe versucht und implementiert, aber ich weiß nicht, wie Sie diese negative Skala für y entfernen. Wie kann ich mein Diagramm nur von 0 starten, so dass es keine negative y-Skala zeigt?

Unten ist mein Code:

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) 
}. 

Image:

enter image description here

enter image description here

Antwort

0

Versuchen Sie, axisMinValue Property

denke, ich barChartView.xAxis.axisMinValue

+0

Ich versuchte das, aber nicht geholfen. Ich habe barChartView.xAxis.axisMinValue = 0.5 – kishor0011

+0

hast du irgendeine Lösung dafür? –

+0

versuchen Sie dies barChartView.leftAxis.axisMinimum = 0 –

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) 
} 
+0

Ist dies eine Antwort oder ein Addendum zu der Frage? – halfer