Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BarChart - Show X-Axis with Step as 1 #3122

Closed
mrimadali opened this issue Dec 20, 2017 · 2 comments
Closed

BarChart - Show X-Axis with Step as 1 #3122

mrimadali opened this issue Dec 20, 2017 · 2 comments

Comments

@mrimadali
Copy link

mrimadali commented Dec 20, 2017

Hi Team,

How can I show Barchart X-values continuously with the step as 1, currently the X-Values display with step 2 mean displays alternate values like Feb, Apr, Jun, Aug etc., I want all the months to be displayed like Jan, Feb, Mar etc.,

screen shot 2017-12-20 at 8 53 21 am

let months = ["","Jan", "Feb", "Mar",
                "Apr", "May", "Jun",
                "Jul", "Aug", "Sep",
                "Oct", "Nov", "Dec"]
  func stringForValue(_ value: Double, axis: AxisBase?) -> String {
      return months[Int(value)]
  }


@mrimadali
Copy link
Author

I have fixed this by using property labelCount as:

barChart.xAxis.labelCount = 12

@sylvan-d-ash
Copy link

class AllResultsViewController {
    let xAxisValues = ["W1", "W2", "W3"]
}

extension AllResultsViewController: IAxisValueFormatter {
    func stringForValue(_ value: Double, axis: AxisBase?) -> String {
        return self.xAxisValues[Int(value)]
    }
}

This is an excerpt of what I have. But I still can't get the x-axis labels to be displayed using strings. In fact, the stringForValue code doesn't seem to be getting executed at all. My questions are therefore:

  1. What could I be doing wrong?
  2. What was the reason behind making this entire process so complicated?
  3. Why were the xValues removed from BarChartData(xVals: months, dataSet: chartDataSet)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants