-
Notifications
You must be signed in to change notification settings - Fork 117
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
Allow non-primitive data values #808
Comments
cc @dej611 |
I agree that this feature could be useful. Any thoughts @markov00? |
@nickofthyme definitely. |
Sounds even better than |
@nickofthyme is there still appetite to implement the original proposal? For my use case the exposed datum in the handler callback is fine, so I wouldn't object closing this. |
@flash1293 If you are referring to adding some type of If you want to argue that this approach is necessary I'm all ear. 🦻 |
@nickofthyme thanks for the explanation, I’m totally fine with the event handler callback solution. I was referring to the general ability to have objects in the table, but the issue you linked seems like a nice way to handle that (missed it originally, that’s why I asked). |
@flash1293 Ok perfect. Just to be clear, the current version of elastic-charts allows the functional accessor for the |
🎉 This issue has been resolved in version 24.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Is your feature request related to a problem? Please describe.
In Kibana values in a chart are not always primitive values like strings or numbers (e.g. when working with ranges). In these cases, the table looks like this (this would be rendered as a bar chart with an ordinal x axis):
{ from: 5, to: 20 }
{ from: 20, to: 40 }
Of course in this case we have a formatter ready to render a nice string tick label out of the object. One solution would be to map over the data and turn all of the objects into the string representation before passing the data to elastic-charts:
However the problem with this solution is that it makes it harder to get back to the original object. This is necessary on interactions - e.g. if the user clicks a bar associated with the first row in the table, we need the orginial object to turn it into a filter. The string representation doesn't help in that case.
Currently, elastic-charts seems to filter out rows containing objects, so nothing is rendered:
String values (works)
https://codesandbox.io/s/sweet-sunset-f1s3i?file=/src/App.tsx
Object values (breaks)
https://codesandbox.io/s/festive-jang-z78p6?file=/src/App.tsx
Describe the solution you'd like
Ideally elastic-charts would simply be able to work with objects as values in the data and treat them as ordinal values. Equality checks could be done using
JSON.stringify
or a similar way of serializing the object.Describe alternatives you've considered
Another option would be to make it possible to pass "additional data" into the click handler, maybe like this:
It's possible to work around this in "user land" as well, by keeping the original table around and doing a reverse lookup in the click handler to get the object for the clicked string, like this: https://codesandbox.io/s/great-browser-ef00i?file=/src/App.tsx
However it would be nice if it wouldn't be necessary to do this intermediary step, especially because it's possible to run into edge cases.
Additional context
A similar issue in vislib was solved by overriding the
toString
function of the object: elastic/kibana#62004We are running into this issue in elastic/kibana#76121
Kibana Cross Issues
Checklist
Delete any items that are not applicable to this feature request.
Kibana Cross Issues
listkibana cross issue
tag is associated to the issue if any kibana cross issue is presentThe text was updated successfully, but these errors were encountered: