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

Adding text data points to axis #3592

Closed
Sviests opened this issue Jul 31, 2018 · 3 comments
Closed

Adding text data points to axis #3592

Sviests opened this issue Jul 31, 2018 · 3 comments

Comments

@Sviests
Copy link

Sviests commented Jul 31, 2018

I am very new to swift so I might be doing something wrong, but I cannot find a way to add String data points to any axis (e.g. line chart with numerical values on y-axis and months (Jan, Feb etc...) on the x-axis). I see in tutorials that this is added to the ChartData but for me it only takes the ChartDataSet...

Thank you in advance!

@NSAmit
Copy link

NSAmit commented Jul 31, 2018

@Sviests
You have to make sure you are doing following to show labels on xAxis -
chartView.xAxis.drawLabelsEnabled = true
chartView.xAxis.valueFormatter = self // In case you want to format the values on your own

Also, recommend you to look at the demo code so that you will get clear idea. I also used it first time in my app and I am loving this library. But the key thing which helped me a lot is to play around with the demo app. Try changing some properties and updating some values in demo app to get clear understanding for this beautiful lib.

@abhi137
Copy link

abhi137 commented Sep 7, 2018

I did something like this -

self.lineChartView.xAxis.valueFormatter = DefaultAxisValueFormatter { (value, axis) in
            if (value == 0) {
                return "Now"
            } else {
                return "8/26"
            }
        }

@liuxuan30
Copy link
Member

for beginners, stack overflow is the better place to ask.

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

4 participants