Description
@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:
[{
x: [1, 2, 3, 4],
y: [5, 6, 7, 8],
METADATA: [{
name: 'country',
values: ['USA', 'Canada', 'Canada', 'Mexico']
}]
}]
In this example, there is just one field. Adding a transform could filter on this attribute as follows:
[{
x: [1, 2, 3, 4],
y: [5, 6, 7, 8],
METADATA: [{
name: 'country',
values: ['USA', 'Canada', 'Canada', 'Mexico']
}],
transforms: [{
type: 'filter',
operation: '{}',
filtersrc: 'METADATA.country',
value: ['USA', 'Canada']
}]
}]
This would filter out the fourth point since it corresponds to Mexico
.
(One small note is that filtersrc
would need a special case for METADATA.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)