-
-
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
Display label MMyyyy for barChart #2142
Comments
Same issue here. Hope this objective-c code from my app helps you out. I think what you want to do is implement IAxisValueFormatter delegate. @interface UndeliveredGraphDueByMonthViewController: UIViewController <ChartViewDelegate, IChartAxisValueFormatter> I stored my xLabels as an array of dates but discovered the delegate was calling for items out of the array bounds and crashing the program, so I ended up using a starting date and implanting a function I otherwise use to add months to the start month/year for the graph. Here is my chart setup for xAxis: Here's the delegate callback: #pragma mark - IAxisValueFormatter
Heres my add month function incase you need it:
} |
@DoctorG Thank you for example! I'm working with it but can't do that I want, can you help me?! I have array with NSDate objects and I want to show them in xAxis. When I use [yVals addObject:[[BarChartDataEntry alloc] initWithX:x y:val]]; I use double parameter something like (NSTimeInterval tInt = [[NSDate date] timeIntervalSinceDate:self.dates[i]];), but when I want to get string from my x value, using delegate IAxisValueFormatter, it shows another date that I need... Please, need in your help! TNX! |
@st-small it's about data formatter issues, so maybe ask on SO and be more specific. |
@liuxuan30 Thank you for reply! I did it! It was very simple! In method setChart... I use int i with steps 0,1,2,...n and in formatter method I use my dates and make strings from them to show as labels in xAxis. But have question, can I show yAxis values in format integer value, without .00? I want to see value, for example, 7, but now showing 7.00. Tnx! Update: just now see your reply in other thread about valueformatter, ok, will try to have that I want, thank you very much!!! |
Hi
I need to display the bar chart data according to
MMyyyy
, may i know how should i approach this?I tried converting the Date to double using
expirationDate.timeIntervalSinceDate
and convert it back to date atfunc stringForValue(_ value: Double, axis: AxisBase?) -> String {}
The barData's color is gone. I can see it's top label value though
Some Observations as well:
let yData = BarChartDataEntry(x: month, y: value) //month = 1475 251 200
func stringForValue(_ value: Double, axis: AxisBase?) -> String { } //value = 1464 000 000 and increment by 2 000 000
The text was updated successfully, but these errors were encountered: