-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Enable DDK compatibility #1541
Enable DDK compatibility #1541
Conversation
Group regex match condition with similar conditions
I haven’t looked at the implementation but I think this is a good solution in principle to the problem of allowing PX and DDK to interoperate, even if it looks a bit weird. I’d be fine with putting this behind a flag that px could turn on if you think that’s necessary, @jonmmease but not doing that makes it easier to interop with DDK more broadly even outside of PX :) |
Thanks @wbrgss, The regex looks fine so long as it covers everything DDK needs (which I'm not familiar enough to judge). Just to help me better understand the workflow here, will users set these colors in their own code or are these implementation details for DDKs own internal use? Are there cases where a user might specify a color this way thinking that they are using DDK, but accidentally not using DDK? Are there any conditions under which plotly.py could check to make sure that DDK is active before accepting these colors? |
BTW, don't worry about the |
The main idea is that ddk will set the default PX color scales to these magic variables up front, then px runs and sprinkles them throughout a figure, then ddk picks them up on the way out and substitutes them client side with the desired color scheme... is that about right @wbrgss ? |
I’d say the odds are low that a non-ddk user would stumble across this and use them unknowingly |
Yeah, it's pretty specific. I left the wildcard between
Users will set the colors in their own code to theme variables, which will be mapped by DDK in the front end to the theme. In their app, users can set a static
Great question — it's possible that a user might specify a color this way because it's the same as CSS syntax, and be confused as to why they can't set a trace color to a CSS variable. I agree with @nicolaskruchten that it's not very likely, however. This possibility could be mitigated by...
Yeah, I thought about this as well. The figures generated by
Does that make sense or does it seem like a hack to you guys? |
Thanks for the background @nicolaskruchten and @wbrgss, I'm comfortable with merging this as is. We can look at validating that |
Thank you @jonmmease! |
(would also be great to have this guy be part of 3.9, released sooner than plotly.js 1.48 ... :D ) |
In Dash Design Kit, we allow for colors to be specified with
var(--*)
syntax, similar to CSS variable syntax. This will allow for Graph colors to dynamically match theme colors when the theme is changed with the Theme Editor.When using
plotly.py
to generate Graph data, aValueError
is raised when using this syntax:This crashes the Dash app, despite the fact that DDK will safely evaluate colors with the above syntax based on the currently defined theme.
This PR allows for these dynamic variables to be passed. It's my first PR, so feedback is welcome, especially on my RegEx 😅
cc @nicolaskruchten — I've tested this with
px
as well asplotly.graph_objs