-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Unique colors for expanded traces #1830
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
Conversation
@etpinard @alexcjohnson I implemented this as discussed. It turned out to be pretty simple, but these things usually have unintended consequences, so glad to get feedback if I'm missing any caveats. I've added an image test and a supplyDefaults test, though maybe that's a bit redundant. |
src/plots/plots.js
Outdated
|
||
if(!trace || !trace._module) continue; | ||
|
||
PlotSchema.crawl(trace._module.attributes, locateExpandedTraceAttrs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be worthwhile to cache colorAttrs
in _module
so we don't need to crawl the schema with every supplyDefaults
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Will do.
Current status: Lots of test failures due to subtle color changes. Debugging the source to determine whether desired or not. |
@@ -0,0 +1,30 @@ | |||
var Plots = require('@src/plots/plots'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a new file here.
Can you move this to either transform_groupby_test.js
or the poorly-named transform_multi_test.js
?
src/plots/plots.js
Outdated
plots.clearExpandedTraceDefaultColors = function(expandedTraces) { | ||
var colorAttrs, path, trace, i, j; | ||
|
||
// A better check *might* be to explicitly check for a groupby transform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be better for sure, but I'm ok with this for now, as this will never get called for transform-less traces.
Maybe we start thinking about adding transform module categories (similar to our trace module categories) to help us out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a hypothetical for now, since groupby
is currently the only one that can yield more than one trace... but my rationale for suggesting this was that it's precisely this condition that breaks default colors. We'll see what happens if/when we add more such transforms, if this is insufficient then a category system is a great idea!
@rreusser looking good! I didn't notice any red flags in those failed tests. 👌 for updating them. |
@etpinard Your initial sense was correct. To get the sequence correct and to preserve existing behavior, I had to move this into the groupby code instead of calling it directly from supplyDataDefaults. That makes it a general-purpose function that still has to be called manually where needed (since the styling pass from within the transform is kinda custom), so I left it in plots.js. Waiting to confirm that it passes the original and new tests, otherwise I think I'm content. |
I've removed a redundant image mock and transferred making sure the colors are correct over to the jasmine test. Looks like it's green, so I don't have anything further to add to this PR. |
Looks great to me! One more question though: Are there other trace types that make sense with groupby that we should include |
In theory, all attributes that get coerced using I'll make sure they're handled properly in this PR. By the way, as object keys can't be minified, would anyone be opposed to shortening Even better, I think we don't even have to add another attribute field: all |
Interesting - I think this is valid (in traces only, of course, not in layout, but we're only crawling trace modules anyway) so yeah, go for it! |
Does And even if we decide this is a good idea, not sure if we want it to happen all the time or just patch it in during testing somehow. |
Replacing (attr.useExpandedTraceDefaultColor) by (attr.valType === 'color' && attr.dflt === undefined) on this line, gives the following
which includes a few attributes that should have had Clearing attributes that inherit from |
- now, Plots.clearExpandedTraceDefaultColors clears any trace attributes with valType: color and no set dflt.
All done in 25c2951. @alexcjohnson ready to 💃 ? |
Very nice. 💃 |
Great solution re: not having to manually set, @etpinard. Thanks! 💃 |
This PR clears color defaults between supplyDefault passes so that expanded traces get unique colors.