-
-
Notifications
You must be signed in to change notification settings - Fork 144
Enhancement: add property Graph.prependData to support Plotly.prependTraces #850
Conversation
6f5269a
to
4a09f70
Compare
Would love to see this feature added in the near future! |
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.
@sleighsoft I agree, this is a nice feature! I wonder if we can DRY the code a bit though?
- I don't think
EMPTY_PREPEND_DATA
is necessary - just reuseEMPTY_EXTEND_DATA
, maybe call itEMPTY_DATA
- this array is never modified. clearPrependData
andclearExtendData
look like they can be merged into perhapsclearState(key='prependData'|'extendData')
- likewise
prepend
andextend
are essentially the same function, just withprependData
swapped in forextendData
andprependTraces
swapped in forextendTraces
. So it could be generalized to something like:
merge(props, 'prependData'|'extendData', 'prependTraces'|'extendTraces')
or even
merge(props, 'prepend'|'extend')
(don't DRY the tests though, those are good to keep distinct. Thanks for including the new test!)
@Marc-Andre-Rivet I don't imagine you'll be too excited about extendData
getting a friend, given the headaches it creates, but do you have any other thoughts about this PR?
Also we'll need a changelog entry |
Reworked it based on your suggestions. Let me know what you think :) |
src/components/Graph.react.js
Outdated
? { | ||
extendData: EMPTY_EXTEND_DATA, | ||
data: EMPTY_DATA, |
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.
data: EMPTY_DATA, | |
[dataKey]: EMPTY_DATA, |
Not sure how that would cause the prepend tests to fail while the extend tests still succeed... there may be something else funny going on. Aside from the fact that it broke the tests, yes this refactoring is exactly what I had in mind 😅
Might be easier to debug those locally with pytest -k test_graph_prepend_trace
or, if you want to play with the test app before the automation commands run, pytest -k test_graph_prepend_trace --pause
(also the lint test failed, but that can be fixed with with npm run format
)
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.
Not super familiar with JavaScript yet. What is that [..]
syntax you are proposing?
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.
Is there a guide on how to get the whole Chrome thing working for tests? I am on Windows with WSL and have not got it working yet.
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.
When running the prepend and extend examples isolated on my machine (I bascially extracted the test code into a separate dash app .py file) then it works for both prepend and extend. Weird.
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.
Finally got selenium working after upgrading to WSL 2. Will look into this in the coming days.
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.
Oh it took me so long to understand your suggestion... Total Javascript/React rooky here. Well, I learned something today.
c0ca728
to
ca1529c
Compare
Failing test-legacy ... I did not touch those. For the other tests, running |
Added Changelog entry. |
@sleighsoft the failing legacy tests have to do with a behavior change in the latest dash version, and they've been fixed in the dev branch. Can you merge dev back into this branch (and fix the changelog conflict)? That should fix these, then we can figure out what's going on with the new tests. |
(The changelog conflict is normal, we just released a new dash & dcc version today) |
I hope this is it now :) |
Legacy still fails |
@alexcjohnson Haha. Actually I like the unified solution + the extra test. Supporting both vs, one shouldn't make much of a difference 😄 My only concern atm is the |
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.
💃 After a little test tweaking (unrelated to your code, these were just old tests that needed some modernizing to be more robust) and undoing the package-lock.json
changes you had (which also happen for me locally, still don't get what's going on there) I think we're ready. Thanks for all your work @sleighsoft !
Thank you for your help @alexcjohnson ! |
Very similar to #461 but adds
prependData
capabilities which are already supported byPlotly.prependTraces
.