-
-
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
Drawing CubicLineChart based on NSDates #38
Comments
There are discussions about supporting this directly- |
In case anybody faces the same issue: I solved it by using the timestamp of the (chronologically) first value in the chart as zero and using the seconds between the first value and each of the following values as xIndex like that: yVals.append(ChartDataEntry(value: [some float], xIndex: [time interval between a value and the first value] * count / [time interval between first and last value])) I am currently working on the x-Axis description (corresponding dates). These are still ordered by count and not by timestamp. More on that as soon. |
Update on the x-Axis description (bit hacky, though): I simply add an "independent" date value for each float value to display in the chart. let timeInterval = Int(dateOfFirstMeasurement.timeIntervalSince1970) + Int([loop iterator] * timeIntervalTotal / [count of float values to display]) |
I am also currently trying to find a good solution for the NSDate mapping. My solution at the moment is to add all xValues at the beginning for the TimeInterval to Show and later map the data xValue to the shown TimeInterval.
My problem is, if I want to display the data of a whole year, I have to add too many xValues. Is your solution doing the same trick caloon? |
365 values are not a lot :-) On Mon, Apr 27, 2015 at 5:21 PM, FranzBusch notifications@github.com
|
365 is no problem;) But if I want to cover every minute of one month, I have to handle about 43.000 values. |
Man you shouldn't do that. You need to run an averaging filter on your data בתאריך יום שני, 27 באפריל 2015, FranzBusch notifications@github.com כתב:
|
You are probably right about that. I was just trying to experiment with the time it needs to display.. Another question I think the xAxisLabelModulus is not working properly. ChartXAxis *xAxis = self.lineChart.xAxis; After this setUp code the chart still doesn't apply the modulus. Is it not possible to set a fixed modulus? |
Follow up on your first comment @FranzBusch: my app does not contain too much data (e.g. no stock prices) and I only tried it with about 70-80 xValues. Averaging the data should be the right way to go. There won't be "enough space" to display 43000 values on your iOS device anyway. I also planned to use an averaging filter. If values are "too close to each other" in x-direction, the cubic line will make it look like the chart is not ordered correctly, with graphs going backwards. @danielgindi: Is there an averaging mechanism built into ios-charts? |
Actually there is a filtering mechanism with one filter implemented- a very בתאריך יום שני, 27 באפריל 2015, Josef notifications@github.com כתב:
|
Follow up - my first code sample was not guide as it caused the line chart to vanish (cp. issue #63). Instead of the xIndices, yVals should be an approximation. The right way to go (sorry but its difficult to describe) would be to approximate each xIndex with a yVal:
|
Hi there,
first of all - thanks for providing this framework. It's exactly what I've been looking for for years.
A problem I am currently facing is that the cubic line charts in my app are currently drawn based on the amount of values in the Set/Array (i.e. if there are 5 values to draw in a rect which is 200px wide, the x-distance between the graph points is 40px).
However, in many use cases, drawing the chart based on NSDates makes a lot of sense. If you for example think about stock prices: a specific stock price is always associated to a specific date & time.
Maybe I've just overseen this option.
Can this already be done with ios-charts? If not, are there plans to implement this option?
The text was updated successfully, but these errors were encountered: