-
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
Make d3 place nicely with object values #62004
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
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.
Code LGTM.
Tested locally on Mac OS 10.14 Chrome 80:
- checked vertical bar charts with various aggregation (Date Range, Ip Range, Range)
- checked horizontal bars with the same aggs
Note: not sure if this is caused by these changes or not, but when creating a vertical bar with a Date Range, Ip Range or Range agg like the one mentioned above, if you change the X axis position to left, the resulting chart loose the top most axis label. The label shows up only disabling the Filter labels
mysterious flag 👻 :)
If this is a different issue, let's consider this approved for me
Update: the above issue is probably the same as #21589
Aah, here we go again. I think it's not related, just another problem. I will look into it. |
@markov00 It also happens without this change, but I think I figured it out. Will prepare a separate PR for this. |
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.
Tested on Mac OS in Chrome with sample logs index pattern. Created vertical bar with date range aggregation, works as expected. Haven't tested other visualizations.
* master: Switch to embeddable factory interface with optional override (elastic#61165) fix text error in diagrams (elastic#62101) [Index management] Prepare support Index template V2 format (elastic#61588) Updates dashboard images (elastic#62011) [Maps] remove MapBounds type (elastic#62332) [Uptime] Convert anomaly Jobs name to lowercase to comply with… (elastic#62293) Make d3 place nicely with object values (elastic#62004) EMT-287: update schema with elastic agent id (elastic#62252) [Maps] fix replaceLayerList to handle case where map is not intialized (elastic#62202) Remove support for deprecated xpack.telemetry configurations (elastic#51142) [Uptime] Remove static constant for index name completely (elastic#62256) [APM] E2E: install dependencies for vanilla workspaces (elastic#62178) [backport] Bump to 5.1.3 (elastic#62286) Show server name in Remote Cluster detail panel (elastic#62250) Rename some alert types (elastic#61693) changing duration type to ms, s, m (elastic#62265) [ML] Clear Kibana index pattern cache on creation or form reset. (elastic#62184) Move `src/legacy/server/index_patterns` to data plugin (server) (Remove step) (elastic#61618) [NP] Remove IndexedArray usage in Schemas (elastic#61410)
Summary
Fixes #57122
Currently range aggregations (ip range, date range) are not rendering correctly when put on the x axis, because d3 scales don't play well with objects as values (a range object looks like this:
{ from: 123, to: 456 }
).When a new ordinal scale is created, it uses a "D3 map" internally to store the set of values and its indices. All values are casted to string because its using a regular JS object as storage mechanism. This means an object like
{ from: 123, to: 456 }
becomes"[object Object]"
- as all values will be mapped to the same string, there will be only a single value on the x axis.Previously to #48090 this worked, because the formatter was applied to the object before the data table got passed to the visualization. However that's problematic because the visualization now never knows about the raw value behind a data point and can't reliably apply filters: #40334
To fix the problem, this PR overwrites the
toString
function of the complex objects in the data table, allowing the d3 map to work as expected.Checklist