[WIP] fix: decimal step cause divide not equal#228
Conversation
7395d99 to
a132e78
Compare
a132e78 to
d57068d
Compare
|
ping @benjycui |
src/Range.jsx
Outdated
| const { marks, step, min, max } = this.props; | ||
| const cache = this._getPointsCache; | ||
| if (!cache || cache.marks !== marks || cache.step !== step) { | ||
| const decimal = step.toString().split('.')[1] && step.toString().split('.')[1].length; |
src/Range.jsx
Outdated
| if (step !== null) { | ||
| for (let point = min; point <= max; point += step) { | ||
| let point = min; | ||
| while (point <= max) { |
There was a problem hiding this comment.
This loop will cost a lot.
e.g. min = 0 && max = 99999
There was a problem hiding this comment.
the performance problem only occur when users set step to be a very small decimals, I think it's not our worries ?
There was a problem hiding this comment.
maybe use something like binary search + Array.map to caculate the point more quickly?
There was a problem hiding this comment.
caculate the point more quickly ——> avoid Maximum call stack
There was a problem hiding this comment.
Another idea, what if when step is very small compare to max - min, we don't calculate the whole points array at first, instead just get the formula,something like: value = f(index), then the cost just happen when every time getter
d57068d to
3ef1197
Compare
3ef1197 to
778c729
Compare
|
close. going to open a new pr to fix the decimal step problem. |
close #227