-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Custom x-axis labels won't show without backing data #3557
Comments
That’s a really nice looking app. I have the same issue so I hope we get an answer. I upvoted your question on SO. |
Thanks for the input. That would be a real bummer if the library doesn't support it. I tried adding blank data points for the days that don't have data like this: |
If you find a solution and post it here I, and I’m sure many others, would be very grateful. |
I certainly will post if I come up with something. On a deadline with this project so I may need to move to a different library soon unfortunately though. |
I have added some comments on SO |
Thank you very much! I have given it a first pass and what you have suggested appears to be working. Once I have tested thoroughly I will post an update on S/O and close this thread. |
I have updated my stack overflow answer to show what I did to get the labels working. Many thanks to Wingzero - would have never got it working without your suggestions. |
good job! |
I have a relatively simple processing here, just modify the axis of the demo LineChart1ViewController:
You do not need to set xAxis.valueFormatter and xAxisRenderer. ChartDataEntry:
|
What did you do?
I created a date-based chart that shows symptom intensity (1-10) that a user reports during his or her week.
Each day of the week is based on a number. That is, Sunday is the first day of the week so it equals 0, Monday is the second day of the week so it equals 1, and so on.
Let's say the user enters the following: a pain intensity of 10 on Tuesday, a pain intensity of 7 on Friday, and a pain intensity of 2 on Saturday. In data format, this would look like the following:
[day: 2, intensity: 10]
[day: 6, intensity: 7]
[day: 7, intensity: 2]
My goal is to get the chart to have 7 x-axis labels, one for each day of the week ("S", "M", "T", "W", "T", "F", "S" ), even for days for which there is no data present.
I created a custom axis formatter to retrieve the strings for the labels as referenced in this issue (#1340), like so:
I also set the number of labels to be equal to the number of days and forced granularity to 1 like this:
Unfortunately, this does not produce a label for each day on the chart. My hunch is that this happens because
stringForValue
is only ever called based on the days entered (2, 6, and 7) and not for the other days of the week.What did you expect to happen?
I expected to see one x-axis label for each day.
What happened instead?
Instead of getting one x-axis label for each day, I got 7 labels, all corresponding to the backing data. That is, I got labels for Tuesday, Friday, and Saturday, but no other days. See screenshot below.
Charts Environment
Charts version/Branch/Commit Number: 3.1.1
Xcode version: 9.4.1
Swift version: 4.1
Platform(s) running Charts: iOS
macOS version running Xcode: High Sierra
Other
I have opened a Stack Overflow for this question: https://stackoverflow.com/questions/51333345/ios-charts-library-x-axis-labels-without-backing-data-not-showing
The text was updated successfully, but these errors were encountered: