-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
select traces doesn't do partial matches on meta
#2629
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
Does this do what you want? print(len([f for f in fig.select_traces(selector=dict(meta_a=1))])) I seem to remember making the design decision that selectors keys needed to be matched in full, and magic underscore notation could be used to target subsets. Not sure off hand if anything goes wrong if we support partial matches, but it would be a breaking change. We'd also need to decide whether the partial match logic is applied recursively. |
that doesn't work, no, possibly because
|
(to be clear: I would be fine with having this work, it would meet my needs just fine :) |
Ok, yeah. this is special because meta doesn't have a sub-schema. I think having special case magic underscore logic to handle dicts is a good approach. This would also be useful in the fig.update_layout(meta_a=8) It would mean we're asserting that dict keys are strings without underscores. Not sure at the moment if this should be a special case for |
Or we could have it do partial matches off a dict, as a special case... either way :) |
On further thought: I want to store keys in |
From reading the dialogue above, I gather that |
I would be OK if partial matches on I don't think I would favour a new |
Ok sounds good. |
that's not a bad idea... I could implement my PX stuff on top of that, yes. Is that easier to build? |
Maybe, I'm looking into it right now 👍 |
Yes I think it would be very easy, basically in def _perform_select_traces(self, filter_by_subplot, grid_subplot_refs, selector):
from plotly.subplots import _get_subplot_ref_for_trace
for trace in self.data:
# Filter by subplot
if filter_by_subplot:
trace_subplot_ref = _get_subplot_ref_for_trace(trace)
if trace_subplot_ref not in grid_subplot_refs:
continue
# Filter by selector
if not self._selector_matches(trace, selector):
continue
yield trace So I would just add a check to see if selector is a |
And if we just leave the |
OK, let's do that then! |
Would it be crazy to implement this for all the |
No, seems reasonable and consistent and powerful and flexible to implement it everywhere :) |
Today, the output of
is
1, 0
, meaning that we can't useselector
to do partial matches onmeta
.It would be really convenient if PX could tag all of its traces with some structured data in
meta
so that users could target these traces with updates, but for that to be useful we would need to do partial matches.@jonmmease any major reason not to do this?
The text was updated successfully, but these errors were encountered: