ivnsch / SwiftCharts

Easy to use and highly customizable charts library for iOS
Apache License 2.0
2.53k stars 410 forks source link

Axis problem #335

Closed iOSMadDev closed 6 years ago

iOSMadDev commented 6 years ago

If your data looks something like this: let array (Sting, Double) = [("first", 0.001), ("second", 0.001), ("third", 0.001)] there will be a problem with axis x (or y depends how you will pass the parameters).

So main thing is that double value is not changing in data array (straight line) and its less then 1

And in method "func generateAxisValuesWithChartPoints" of "struct ChartAxisValuesStaticGenerator" there is a code:

let last = lastPar =~ first ? lastPar + 1 : lastPar

so "+ 1" is a problem for values than less than 1

ivnsch commented 6 years ago

Which problem? Can you be more specific?

iOSMadDev commented 6 years ago

Problem with scale. So my values in array are less the 1. And if they are all equal ( like 0.001) there will be a problem. Chart will be from 0 to 1 and all of my values will be almost invisible because of wrong scale.

because of : let last = lastPar =~ first ? lastPar + 1 : lastPar

ivnsch commented 6 years ago

ChartAxisValuesStaticGenerator.generateAxisValuesWithChartPoints is just convenience to generate the array and not really needed anymore... I will probably deprecate it soon. You're right that this behavior isn't correct, but given that it will be removed, I don't see it as a priority to fix it (you of course can do a pull request). Now there are dynamic generators - please checkout the wiki. You can also simply pass an array with the desired axis values / write your own logic to generate this array.

iOSMadDev commented 6 years ago

thx