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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI]added reset support and click support for Brush #131

Merged
merged 7 commits into from
Sep 10, 2018

Conversation

conglei
Copy link
Collaborator

@conglei conglei commented Sep 7, 2018

馃挃 Breaking Changes

馃弳 Enhancements

Exposed the reset function to Brush and added an example to show how to use it.
clear_brush

Enabled the click event for Brush.
click_brush

Exposed starting point of brush to onBrushStart .

馃摐 Documentation

馃悰 Bug Fix

馃彔 Internal

@conglei conglei changed the title added reset support [UI]added reset support and click support for Brush Sep 7, 2018
@ximin-zhang
Copy link

Thanks for those work!!!

handleBrushStart(point) {
const { x, y } = point;
const { onBrushStart, xScale, yScale } = this.props;
const invertedX = xScale.invert(x);
Copy link
Owner

Choose a reason for hiding this comment

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

does this work with band scales?

possible solution here if not (or we could punt to future PR / create issue).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch! Indeed it doesnt work for band scales.. will revise it in this PR.

@williaster
Copy link
Owner

This looks good to me overall, and I pulled it / had no issues locally 馃憤

I think it'd be great to get a test or two in for it if possible tho.

@conglei
Copy link
Collaborator Author

conglei commented Sep 10, 2018

@williaster Added ordinal scale support.

brush_bar

@codecov
Copy link

codecov bot commented Sep 10, 2018

Codecov Report

Merging #131 into master will increase coverage by 0.11%.
The diff coverage is 80.7%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #131      +/-   ##
==========================================
+ Coverage   79.64%   79.76%   +0.11%     
==========================================
  Files         109      109              
  Lines        2334     2382      +48     
  Branches      544      547       +3     
==========================================
+ Hits         1859     1900      +41     
- Misses        301      310       +9     
+ Partials      174      172       -2
Impacted Files Coverage 螖
packages/xy-chart/src/utils/brush/Brush.jsx 83.96% <100%> (+1.67%) 猬嗭笍
...ckages/xy-chart/src/utils/brush/BrushSelection.jsx 33.33% <25%> (-2.67%) 猬囷笍
packages/xy-chart/src/selection/Brush.jsx 65.67% <78.57%> (+5.67%) 猬嗭笍
packages/xy-chart/src/utils/chartUtils.js 87.5% <91.3%> (+3.5%) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 1747f85...4fcf9ee. Read the comment docs.

Copy link
Owner

@williaster williaster left a comment

Choose a reason for hiding this comment

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

Overall looks good, thanks for addressing the band scale issue. I left a couple thoughts about it 馃憤

@@ -77,6 +77,27 @@ export function propOrFallback(props, propName, fallback) {
return props && isDefined(props[propName]) ? props[propName] : fallback;
}

export function scaleInvert(scale, value) {
if (!scale.invert) {
Copy link
Owner

Choose a reason for hiding this comment

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

could we just add a comment here that band scales don't have the invert method?

if (!scale.invert) {
const leftEdges = scale.range();
let i = 0;
const width = scale(scale.domain()[1]) - scale(scale.domain()[0]);
Copy link
Owner

Choose a reason for hiding this comment

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

could this be replaced with scale.step since this should only be hit for band scales?

const invertedY0 = yScale.invert(y0 + (y0 < y1 ? -SAFE_PIXEL : SAFE_PIXEL));
const invertedY1 = yScale.invert(y1 + (y1 < y0 ? -SAFE_PIXEL : SAFE_PIXEL));

let xDomain;
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 what you mean about duplicate code, could this be pulled out into a helper function that does the logic that's duplicated for x + y now?

I think you're right that this will have to return an array of values for a band scale.

} else {
const xValues = [];
for (let i = startX; i <= endX; i += 1) {
xValues.push(xScale.domain()[i]);
Copy link
Owner

Choose a reason for hiding this comment

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

could call .domain once and assign to a variable here instead of calling multiple times.

@conglei
Copy link
Collaborator Author

conglei commented Sep 10, 2018

@williaster Added more test and fixed the comment you mentioned :) Thanks for the suggestions :)

@williaster
Copy link
Owner

this isn't reflecting the successful build, gonna merge. thanks for addressing comments + adding tests! we gotta get that number back up above 80% 馃搱

@williaster williaster merged commit 2620c9a into williaster:master Sep 10, 2018
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.

None yet

3 participants