-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add limit props to set height and width of XLine and YLine respectively #152
Add limit props to set height and width of XLine and YLine respectively #152
Conversation
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.
Hey @tanayv this looks great, just a few comments.
Also, let's add some tests to YLine.spec.js and XLine.spec.js to make sure it works as expected now and in the future :)
src/XLine.js
Outdated
let y2 = height + spacingBottom; | ||
|
||
if (yLimit) { | ||
y1 = yScale(yDomain[0]); |
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 can't this stay -spacingTop
?
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.
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.
Gotcha! I think we're missing the spacingBottom as well so we need to account for that if users pass that in. Is it possible, for consistency, for the YLine to always grow from the top or bottom (the latter makes more sense to me). So if there's a yLimit the only thing that would be altered is y2 where y1 should stay yScale(yDomain[0]) - spacingBottom
?
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.
Hey @krissalvador27, sorry for the delay in making these changes. Finally had the chance to get to them.
For the XLine to always consistently grow from the bottom (ie. by fixing the value of y1 as yScale(yDomain[0]) - spacingBottom
), I will also have to account for the XLines created by the XGrid, which is a child of the XAxis component.
As of now, the XAxis component doesn't accept the yDomain as a prop from the XYPlot, and so the XLines that make the grid do not have the prop yDomain available. So should I go ahead and add yDomain and yScale as props for both XAxis and XGrid to make all lines (including the grid lines) grow from the bottom?
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.
Hey @tanayv!
Thanks for catching that! XYPlot should hand yDomain and yScale down to all its children, so XAxis should easily accept it. I do worry that the complexity and scope is growing though. I think we can go with your original logic to accomplish the original XLine and YLine height and width limits and consistently have XLines grow from the top/limit point. 👍
src/XLine.js
Outdated
let y1 = -spacingTop; | ||
let y2 = height + spacingBottom; | ||
|
||
if (yLimit) { |
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.
Seems possible for yLimit to be 0
making this falsey.
Thanks for the comments. I'll add the tests and address the comments with an updated PR soon! |
Hey @krissalvador27, I've added the test cases for the new props, and fixed the undefined check on XLine. For the logic, I stuck to having only the lines with xLimit in their props to grow from the bottom, while all other XLines consistently grow from the top. Also, I set Thanks! |
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.
Thanks @tanayv!
…ly (#152) * implement xy limit props * update documentation * add test cases, better undefined check for XLine
Adds the height/width limit props discussed in #149