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

Histogram widget #170

Merged
merged 33 commits into from
Aug 23, 2018
Merged

Histogram widget #170

merged 33 commits into from
Aug 23, 2018

Conversation

rjimenezda
Copy link
Contributor

@rjimenezda rjimenezda commented Aug 21, 2018

Closes #91

This PR adds a histogram widget to airship

The only thing that I didn't implement is the color range. There's still time to copy the builder approach, though.

--histogram-widget--background-color: #{$color-ui-01};

display: block;
background: var(--histogram-widget--background-color, $color-ui-01);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not working

background: var(--histogram-widget--background-color, $color-ui-01);

.as-histogram-widget__header {
font: #{$font-subheader};
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the curly brackets here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope


.as-histogram-widget__tooltip {
// ATT REVIEWER: do we want to do this?
@extend .as-tooltip;
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of a better approach to this, so I'd keep it

*/
@Method()
public setSelection(values: number[] | null) {
this._setSelection(values === null ? values : this._adjustSelection(values));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is hard to read, can we improve it somehow?

this._setSelection(d1);
}

private _setSelection(selection: number[]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is (AFAIK) always called with _adjustSelection can we call _adjustSelection inside this method instead of doing it multiple times outside of it?

}

.as-histogram-widget__description {
font: #{$font-body};
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, do we need the curly brackets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope.gif

.call(this.brush);

this.brushArea.on('mousemove', () => {
const evt = d3event as MouseEvent;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid using abbreviations in variable names? Same for the bb below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

event would shadow window.event

boundingbox instead of bb makes everything too big imho, and it's just some geometry check

const node = nodes[i] as Element;
const bb = node.getBoundingClientRect();

if (bb.left <= clientX &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we extract this conditional to a variable to give it some context? otherwise it's hard to know what we're checking

}

// I don't know why this happens
if (!evt.sourceEvent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we merge this conditional and the one below?

return false;
});

// True if any of the selection values is inside the data
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this more readable?

this.data.any(value => selectionValue >= value.start && selectionValue <= value.end);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I N V E N T

Copy link
Contributor

@rubenmoya rubenmoya left a comment

Choose a reason for hiding this comment

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

Great job!! 🚀

@rubenmoya rubenmoya merged commit a18b28b into master Aug 23, 2018
@rubenmoya rubenmoya deleted the histogram-widget branch August 23, 2018 14:43
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

2 participants