SwiftChart
SwiftChart copied to clipboard
Add support for logarithmic scale
Can you add support for a log-scale graph? or allowing to choose which Y-values should be shown?
I'm working with data that goes from $25,000 to over $20,000,000,000. Over a 45 year period
And my line is flatlining because of the exponential increase.
To view my line properly I need an logarithmic graph which would show the following values instead:
0 25,000 100,000 1,000,000 10,000,000 100,000,000 1,000,000,000 10,000,000,000 100,000,000,000
Or however many that can fit.
Here's what my data looks like atm.
Hi, thanks for the good idea. This month I could work on it. Let see if I get some free time. (or if you don't mind to send a pull request... 😀)
That would be amazing!
I've been looking at your code since a few hours before creating the issue. But I can't figure out where or how to implement a log-scale y-axis.
If I do figure it out, I will most definitely be sure to make a pull request. But so far I've got nothing.
This is an absolute requirement for my project, and there are no libraries out there, not even for Obj-c that uses a logarithmic scale. So unfotunately there's no reference.
Did this ever get implemented? I'm still searching for a useable Chart system that has support for a logarithmic scale.
Sorry @MarkLyck I couldn't find time for this. Couldn't you just pass down the logarithmic values to the series?
Some code I put together today that might help others with this case:
extension Array where Element == Double {
func logify() -> Array { return self.map { log2(pow(abs($0), $0.signum())) } }
}
extension FloatingPoint {
func signum( ) -> Self {
if self < 0 { return -1 }
if self > 0 { return 1 }
return 0
}
}