-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Passing additional metadata to points #1031
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
Comments
Instead, what if
|
A fair amount of operations will just want to filter on trace data. Forcing an array will lead to additional copying in that case? A pointer to an array like The Could |
@bpostlethwaite Can you clarify what you mean by that? |
@chriddyp Thinking strictly about the json, I'm not sure a transform is the most desirable place for metadata about the points. Thinking about the UI though, I can see why it might be desirable to instantiate a transform that encapsulates the data it needs rather then injecting additional data into the trace itself. If there were multiple traces, you'd need to determine which metadata needs to be included and then insert and update that as the transforms change. I wouldn't think it would be that difficult, but I can see why it might be somewhat undesirable. |
To summarize: It's pretty easy to tack on some extra data in the json and reference that where needed. Wisdom and perspective I may need from someone with more experience than I have:
|
Besides the fact that some data could be duplicated if the transform happened to use the same data as some other attribute, why wouldn't this be desirable?
That's definitely true. But couldn't you make the same argument about multiple traces that share the same It may be extra copying in the JS side of things but this won't introduce any extra network lag since these attributes will have the same column source ID. I'm not familiar with the internals of plotly.js's filtering, but if these arrays had the same reference, would there necessarily / does there need to be extra copying ?
Nothing entirely blocking, but It'll require some extra things for us:
If the motive for introducing this is type of structure is to reduce duplicate copies of data in the JSON, it seems like the ultimate solution would be for plotly to encapsulate the data in the json, like:
We actually already serialize our data like this on plot.ly so that we can keep data and plots separate and so that we're not sending any more columns over the wire than we need to. I'm not sure of what other benefits we might get by doing something like this in plotly.js. |
Interesting! I didn't realize plot.ly was assembling the data client-side. Good to know. I mostly type examples by hand so that duplication is particularly irksome (not so much the typing but the fact that I have to sit there contemplating normalization vs. denormalization as I copy/paste/synchronize) The only reason for my aversion to transforms owning the data is that it sits logically in parallel with the data so that a transform 'owning' the data seems like an unnecessary denormalization since two transforms talking to the same metadata would need their own individual copies. Also, since the decision to add metadata is a departure from what plotly currently does and since it seems reasonably possible that it could have other uses (similar to the way components and transforms have grown in scope and capability as they interact in new ways), it seems like nesting it inside transforms limits the possibilities without just starting over from scratch the next time it's needed. That said, I'm not currently aware of what those other uses might be. Realistically, even novel, unexpected uses may well just be transforms anyway. |
If it were contained in, e.g., (Meaning |
Ah yup, if it has a standard name like |
Resolved (for now). Future development will be discussed in https://github.com/plotly/streambed/issues/8112 |
@chriddyp has requested, for example, a slider that selects which subset of data to show. The easiest way to accomplish this is if points are able to carry some additional metadata on which a transform can filter. My simplistic approach was to add a single attribute (see: #1028), but after talking with @etpinard, here is a proposal for a slight generalization:
I will call it
METADATA
because I haven't found a name I like yet. Please substitute your preferred name for now.METADATA
is supplied to points as follows:In this example, there is just one field. Adding a transform could filter on this attribute as follows:
This would filter out the fourth point since it corresponds to
Mexico
.(One small note is that
filtersrc
would need a special case forMETADATA.country
since it's not strictly a nested property lookup. This does not seem problematic though.)The upshot is that we can add metadata to points that adds capability and otherwise interacts with nothing. So it shouldn't be difficult to maintain.
The downside is that this is a new direction for plotly so should be considered carefully and with knowledge of whether this is consistent with how the front-end can be reasonably made to work.
cc: @etpinard @chriddyp @alexcjohnson
(and please cc others who may have a particular opinion about this)
The text was updated successfully, but these errors were encountered: