Skip to content
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

Merged
merged 3 commits into from
Jul 8, 2019

Conversation

tanayv
Copy link
Contributor

@tanayv tanayv commented Jun 10, 2019

Adds the height/width limit props discussed in #149

Screen Shot 2019-06-10 at 3 41 10 AM

Screen Shot 2019-06-10 at 3 40 43 AM

Copy link
Contributor

@krissalvador27 krissalvador27 left a 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]);
Copy link
Contributor

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?

Copy link
Contributor Author

@tanayv tanayv Jun 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2019-06-12 at 11 23 21 PM

So with y1 set as -spacingTop, the line begins from the top instead of the bottom. I assumed since the value is within the domain, the line should begin from the lower bound of the domain. Let me know if that's not what you had in mind/if there's a better implementation for this.

Copy link
Contributor

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?

Copy link
Contributor Author

@tanayv tanayv Jun 21, 2019

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?

Copy link
Contributor

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) {
Copy link
Contributor

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.

@tanayv
Copy link
Contributor Author

tanayv commented Jun 12, 2019

Thanks for the comments. I'll add the tests and address the comments with an updated PR soon!

@tanayv
Copy link
Contributor Author

tanayv commented Jun 29, 2019

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 y1 = yScale(yDomain[0]) + spacingBottom since now y1 is the lower point of the line.

Thanks!

Copy link
Contributor

@krissalvador27 krissalvador27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tanayv!

@krissalvador27 krissalvador27 merged commit 4a9e836 into spotify:master Jul 8, 2019
install pushed a commit that referenced this pull request Feb 25, 2020
…ly (#152)

* implement xy limit props

* update documentation

* add test cases, better undefined check for XLine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants