-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Date histogram brush - add range filter when field is not index pattern time field. #12286
Conversation
src/ui/public/utils/brush_event.js
Outdated
let filterType = RANGE_FILTER; | ||
if (event.data.xAxisField.type === 'date' && | ||
event.data.xAxisField.name === event.data.indexPattern.timeFieldName) { | ||
filterType = TIME_FILTER; |
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 the switch
really necessary? What if we just moved the block from the switch statement into the body of this if
statement? Seems like it could simplify this logic a bit.
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.
Functionality looks good, and code changes look good! Nice work @nreese!
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.
LGTM
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.
Hmm, seems like there might be a lingering issue here. I've got a date field, creation_date
, which is not my configured time field for the index pattern. Here's the mapping:
"creation_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss Z"
}
When I create a bar chart with a date histogram on this field, then click on one of the bars, everything seems to work properly. However, when I brush on the chart, I get an error:
Is there any way we can mimic the behavior when creating a filter by clicking on the bar?
@lukasolson good find with the date parse error. I pushed a change that converts |
src/ui/public/utils/brush_event.js
Outdated
if (max instanceof Date) { | ||
max = max.getTime(); | ||
} | ||
const range = { gte: min, lt: max }; |
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'm still getting the same error. You'll need to change this line to the following:
const range = { gte: min, lt: max, format: 'epoch_millis' };
Then it will work 😄
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.
LGTM!
fixes #3173
Modifies how brush events on
date
fields are handled. When the field is the index pattern timefield, than the timefilter is updated. When the field is not the index pattern timefield, then the range filter is created.