Charts: Décalages des étiquettes BarChart xAxis

Créé le 23 nov. 2016  ·  4Commentaires  ·  Source: danielgindi/Charts

Bonjour à nouveau, tout d'abord, je tiens à vous remercier d'avoir répondu si rapidement à mon dernier problème. J'ai une autre question, par contre. Lors de la création d'un graphique à barres, avec des étiquettes en bas, la toute première étiquette est décalée et non directement sous la barre respective.
screen shot 2016-11-22 at 3 25 27 pm J'ai jeté un œil à la démo et j'ai fait correspondre tous mes paramètres en conséquence : chartView.isUserInteractionEnabled = false chartView.chartDescription?.text = "" chartView.drawBarShadowEnabled = false chartView.rightAxis.drawGridLinesEnabled = false chartView.rightAxis.drawAxisLineEnabled = false chartView.rightAxis.drawLabelsEnabled = false chartView.xAxis.avoidFirstLastClippingEnabled = true chartView.xAxis.centerAxisLabelsEnabled = false chartView.xAxis.drawLimitLinesBehindDataEnabled = false chartView.xAxis.labelPosition = .bottom chartView.xAxis.labelCount = 3 chartView.xAxis.axisMinimum = -0.5 chartView.xAxis.axisMaximum = 3 chartView.xAxis.drawGridLinesEnabled = false chartView.fitBars = true chartView.xAxis.granularity = 1 Je ne sais pas quelles autres propriétés essayer. J'apprécierais les conseils. Merci encore

bug

Tous les 4 commentaires

Voici toute la fonction que j'appelle pour configurer le graphique `func setUpChart(délégué : IAxisValueFormatter){

    var dataEntries = [BarChartDataEntry]()
    var barChartDataSet = BarChartDataSet()

    for i in 0..<items.count {
        let de = BarChartDataEntry(x: Double(i), yValues: [itemsValues[i]])
        dataEntries.append(de)
    }


    barChartDataSet = BarChartDataSet(values: dataEntries , label: "Monthly Income")

    chartView.isUserInteractionEnabled = false
    chartView.chartDescription?.text = ""
    chartView.drawBarShadowEnabled = false
    chartView.rightAxis.drawGridLinesEnabled = false
    chartView.rightAxis.drawAxisLineEnabled = false
    chartView.rightAxis.drawLabelsEnabled = false
    chartView.xAxis.avoidFirstLastClippingEnabled = true
    chartView.xAxis.centerAxisLabelsEnabled = false
    chartView.xAxis.drawLimitLinesBehindDataEnabled = false
    chartView.xAxis.labelPosition = .bottom
    chartView.xAxis.labelCount = 3
    chartView.xAxis.axisMinimum = -0.5
    chartView.xAxis.axisMaximum = 3
    chartView.xAxis.drawGridLinesEnabled = false
    chartView.fitBars = true
    chartView.xAxis.granularity = 1
    chartView.xAxis.valueFormatter = delegate


    barChartDataSet.colors = ChartColorTemplates.colorful()


    self.chartView.animate(xAxisDuration: 1.5, yAxisDuration: 1.5, easingOption: .easeInOutCirc)

    let bcData = BarChartData(dataSet: barChartDataSet)

    bcData.barWidth = 0.5
    self.chartView.data = bcData


}`

Désactivez avoidFirstLastClippingEnabled . L'activer aura l'effet. Cela ressemble à un bug.

J'ai eu un problème similaire avec les graphiques en courbes, la première étiquette sur l'axe x est désactivée.

screen shot 2016-11-29 at 3 28 53 pm

La seule façon que j'ai trouvée de résoudre ce problème est d'utiliser xAxis.centerAxisLabelsEnabled = true mais je suppose que ma surbrillance sera désactivée.

Voici mon code xAxis. Toute aide est la bienvenue.

 func setupXAxisFormatting() {
        let xAxis = lineChartView.xAxis
        xAxis.enabled = true
        xAxis.drawGridLinesEnabled = false
        xAxis.drawLabelsEnabled = true
        xAxis.drawAxisLineEnabled = false
        xAxis.centerAxisLabelsEnabled = true //would rather fix another way

        xAxis.labelPosition = .bottom
        xAxis.labelTextColor = UIColor.gray
        xAxis.labelFont = UIFont(name: Constants.Fonts.ProximaNovaBold, size: 15.0)!

        xAxis.avoidFirstLastClippingEnabled = true
        xAxis.spaceMin = 5
        xAxis.valueFormatter = axisFormatDelegate
    }

@Rnorback Je ne pense pas que ce soit le même problème pour "la première étiquette sur l'axe x est désactivée" ? désactivez AvoidFirstLastClippingEnabled devrait déplacer '11/23' vers la gauche d'un espace.

Cette page vous a été utile?
0 / 5 - 0 notes