-
Notifications
You must be signed in to change notification settings - Fork 14
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
Histogram widget #170
Conversation
no updating yet
also public api for set / get selection
this fixes the selection growing and shrinking
--histogram-widget--background-color: #{$color-ui-01}; | ||
|
||
display: block; | ||
background: var(--histogram-widget--background-color, $color-ui-01); |
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.
I think this is not working
background: var(--histogram-widget--background-color, $color-ui-01); | ||
|
||
.as-histogram-widget__header { | ||
font: #{$font-subheader}; |
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.
Do we need the curly brackets here?
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.
nope
|
||
.as-histogram-widget__tooltip { | ||
// ATT REVIEWER: do we want to do this? | ||
@extend .as-tooltip; |
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.
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)); |
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.
I think this is hard to read, can we improve it somehow?
this._setSelection(d1); | ||
} | ||
|
||
private _setSelection(selection: number[]) { |
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.
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}; |
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.
Same, do we need the curly brackets?
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.
nope.gif
.call(this.brush); | ||
|
||
this.brushArea.on('mousemove', () => { | ||
const evt = d3event as MouseEvent; |
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.
Can we avoid using abbreviations in variable names? Same for the bb
below
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.
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 && |
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.
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) { |
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.
Can we merge this conditional and the one below?
return false; | ||
}); | ||
|
||
// True if any of the selection values is inside the data |
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.
Is this more readable?
this.data.any(value => selectionValue >= value.start && selectionValue <= value.end);
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.
I N V E N T
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.
Great job!! 🚀
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.