How to put bar's value inside bar on HorizontalBarChartView of Swift iOS Charts?

by Augusto   Last Updated February 11, 2019 09:26 AM

I'm trying put the bar's value inside bar on my HorizontalBarChartView, because some values are clipping on the right side of the screen, but I not found solutions on the web search. Also, I want put the labels on left side of the chart, but I don't know how to this and I can't ask two things on the same question.

This is my setup Chart code:

func setupChart() {
    self.chartViewHorizontal.fitBars                   = true
    self.chartViewHorizontal.legend.enabled            = false
    self.chartViewHorizontal.isUserInteractionEnabled  = false
    self.chartViewHorizontal.animate(yAxisDuration: 1.5)

    self.chartViewHorizontal.rightAxis.enabled = false

    self.chartViewHorizontal.leftAxis.labelCount      = 5
    self.chartViewHorizontal.leftAxis.labelFont       = UIFont.boldSystemFont(ofSize: 10.0)
    self.chartViewHorizontal.leftAxis.valueFormatter  = CustomAxisValueFormatter()

    self.chartViewHorizontal.xAxis.drawGridLinesEnabled    = false
    self.chartViewHorizontal.xAxis.enabled                 = false

results in:

enter image description here

I want this:

enter image description here

I'am using this lib:

Answers 1

Try to set below property false in your chartview:

horiBarChartView.drawValueAboveBarEnabled = false

this will help you to get your value labels inside BarChart.

February 11, 2019 09:25 AM

Related Questions

How to hide a label when touch event finished?

Updated November 19, 2017 03:26 AM

Swift 4 Custom Collection Types

Updated June 16, 2017 00:26 AM

Force to show min/max on x axis

Updated May 17, 2017 11:26 AM