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

fix lingering issues from #57 following @timelyportfolio's approach #61

Merged
merged 2 commits into from
Jan 30, 2019

Conversation

joshhjacobson
Copy link
Contributor

I was still having issues when an array of axes that included the rightmost axis was hidden. This gave the error TypeError: Cannot read property 'type' of undefined from this line in brushFor.js:

brushRangeMax = config.dimensions[axis].type 

I followed the same approach released in v2.2.5 to correct this.

@joshhjacobson
Copy link
Contributor Author

@BigFatDog sorry to bother you, but is there any way we can get this PR merged in the next few days? I have a deadline coming up at the end of the month and it would be great to have this fixed by then.

@BigFatDog
Copy link
Owner

@joshhjacobson
Don't worry. I do it right now.

@joshhjacobson
Copy link
Contributor Author

Hi there, just wanted to check in on this. Any chance you'd be able to merge this in the next day or two? If there are revisions that need to be made, please let me know. Thanks!

@BigFatDog
Copy link
Owner

I've been waiting for your response for the pending code review these days.
as I said in the end of review:

Please also don't worry this discussion would block your work. I'll merge ASAP once we have a conclusion.

If we reach a conclusion, I'll do this tonight.

@joshhjacobson
Copy link
Contributor Author

My bad, I didn't realize you'd already completed a review. Where can I find that?

@BigFatDog
Copy link
Owner

Oh MY GOD! I didn't submit it...

Sorry, my bad.

]
: config.dimensions[axis].yscale.range()[0];
// handle hidden axes which will not be found in dimensions
let brushRangeMax = null;
Copy link
Owner

Choose a reason for hiding this comment

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

How about returning a dummy function when an axis is hidden:

 if (!config.dimensions.hasOwnProperty(axis)) {
    return () => {}
 }

// no more check
const brushRangeMax = ...
const yScale = ...

I'm not sure yet. Still investigating

Copy link
Owner

Choose a reason for hiding this comment

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

I see. @timelyportfolio's fix should be reserved.

In our case, my consideration is: when brushRangeMax is null, it may cause unexpected behavior to set brush extent:

const _brush = brushY(_selector).extent([[-15, 0], [15, brushRangeMax]]);

Therefore it returning a dummy function should be safer.

I've tested this with your original test case.

Please also don't worry this discussion would block your work. I'll merge ASAP once we have a conclusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, I see what you mean. I'll implement this change right now.

Copy link
Owner

Choose a reason for hiding this comment

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

I'll be online to make sure this is merged tonight

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks so much!

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry again for my mistake. I wish it didn't delay your work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify, did you want to take the following approach:

if (!config.dimensions.hasOwnProperty(axis)) {
  return () => {}
}

// no more check
const brushRangeMax = ...
const yScale = ...

which leaves the code something like this:

// handle hidden axes which will not be a property of dimensions
if (!config.dimensions.hasOwnProperty(axis)) {
 return () => {}
}

const brushRangeMax =
    config.dimensions[axis].type === 'string'
      ? config.dimensions[axis].yscale.range()[
          config.dimensions[axis].yscale.range().length - 1
        ]
      : config.dimensions[axis].yscale.range()[0];

const yscale = config.dimensions[axis].yscale;

i.e. change what @timelyportfolio had done for #57?

Copy link
Owner

Choose a reason for hiding this comment

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

keeping @timelyportfolio's fix unchanged.

Only adding this to the function:

const brushFor = (state, config, pc, events, brushGroup) => (
  axis,
  _selector
) => {
  // add this line
  if (!config.dimensions.hasOwnProperty(axis)) {
      return () => {}
  }
  // the rest code remain unchanged.
  const brushRangeMax = ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it

@BigFatDog BigFatDog merged commit 4278338 into BigFatDog:develop Jan 30, 2019
@BigFatDog
Copy link
Owner

BigFatDog commented Jan 30, 2019

v2.2.7 has been published to deliver this PR.

Thank you for your time and efforts!
Good night. 🌔

@joshhjacobson
Copy link
Contributor Author

Much appreciated!

@joshhjacobson joshhjacobson deleted the feature/fix-hideAxis branch January 30, 2019 04:27
@timelyportfolio
Copy link
Contributor

@joshhjacobson @BigFatDog thanks so much. Sorry I missed that!

@joshhjacobson
Copy link
Contributor Author

@timelyportfolio no problem! Wouldn't have been able to figure this out without your initial fix.

@BigFatDog
Copy link
Owner

BigFatDog commented Jan 30, 2019

Much appreciated!

You're welcome.

@BigFatDog
Copy link
Owner

@joshhjacobson @BigFatDog thanks so much. Sorry I missed that!

It's fine. Please don't worry about it.

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.

3 participants