-
Notifications
You must be signed in to change notification settings - Fork 195
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
Transformation for custom value in SparklinesReferenceLine #73
base: master
Are you sure you want to change the base?
Conversation
@@ -56,7 +56,8 @@ class Sparklines extends React.Component { | |||
return ( | |||
<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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can move this to some other parts of the app?
And keep this simple?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you wish. I just want to make SparklinesReferenceLine works in expected way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).