Transformation for custom value in SparklinesReferenceLine#73
Transformation for custom value in SparklinesReferenceLine#73Dem0n3D wants to merge 2 commits intoborisyankov:masterfrom
Conversation
| <svg {...svgOpts} > | ||
| {React.Children.map(this.props.children, child => | ||
| React.cloneElement(child, { points, width, height, margin }) | ||
| React.cloneElement(child, { points, limit, width, height, margin, max: typeof max == "undefined" ? Math.max.apply(Math, data) : max, |
There was a problem hiding this comment.
Maybe we can move this to some other parts of the app?
And keep this simple?
There was a problem hiding this comment.
As you wish. I just want to make SparklinesReferenceLine works in expected way.
There was a problem hiding this comment.
Why does the min and max need to be calculated here? The Sparklines component doesn't do any additional calculations and the dataToPoints function backfills the missing information. The second commit seems extraneous.
There was a problem hiding this comment.
Look at this:
const data = type == 'custom' ? [value] : dataProcessing[type](ypoints);
const y = dataToPoints({ data, limit, width, height, margin, max, min })[0].y;
here dataToPoints gets already transformed data (just one point in many cases), so it has no idea about original data array, and it can't calculate correct min and max.
SparklinesReferenceLine, in other side, don't gets original data too. So, we have that min and max of original data array should be calculated in the top level component.
|
Hey, any progress on this? |
in this PR, point.y will be transformed with dataToPoints (max in min will be calculated automatically in Sparklines).