Skip to content

fix: DH-18653: migrate to plotly >= 6.0.0 #1179

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

jnumainville
Copy link
Collaborator

@jnumainville jnumainville commented May 8, 2025

Fixes #946

  1. Bump plotly.py to 6.0.0
  2. Bump plotly.js to 3.0.0
  3. Deprecate any mapbox reference
  4. Remove alignmentgroup and offsetgroup in tests where they now do not need to be set
  5. Generally replaced NULL_INT and NULL_DOUBLE with a binary data form plotly is now converting those values to in tests
  6. Replaced all title=<str> with title_text=<str> as the former is deprecated
  7. Fixed some minor inconsistencies
  8. Added a few e2e tests where I could to make sure migration did not break the charts. Those images were generated on main originally.

Copy link

github-actions bot commented May 8, 2025

plotly-express docs preview (Available for 14 days)

Copy link

github-actions bot commented May 9, 2025

plotly-express docs preview (Available for 14 days)

Copy link

github-actions bot commented May 9, 2025

plotly-express docs preview (Available for 14 days)

Copy link

github-actions bot commented May 9, 2025

plotly-express docs preview (Available for 14 days)

Copy link

github-actions bot commented May 9, 2025

plotly-express docs preview (Available for 14 days)

@jnumainville jnumainville requested review from Copilot and mofojed May 13, 2025 19:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the plotting functionality to use plotly versions ≥6.0.0 by updating dependencies, replacing deprecated mapbox‐based functions with their new map counterparts, and updating test constants and parameter names.

  • Bump plotly.py to 6.0.0 and plotly.js to 3.0.0 in package configurations
  • Replace all usages of mapbox functions (e.g. scatter_mapbox, line_mapbox, density_mapbox) with new functions (scatter_map, line_map, density_map) and add deprecation warnings
  • Update test files to use new binary data constants (PLOTLY_NULL_INT and PLOTLY_NULL_DOUBLE) and adjust expected layouts accordingly

Reviewed Changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated no comments.

File Description
plugins/plotly-express/test/deephaven/plot/express/plots/* Replace deprecated NULL_* values with new PLOTLY_NULL_* constants and update test names for map-based functions
plugins/plotly-express/src/js/* Update JS utility and model files to work with the new plotly.js version and reframe map detection logic
plugins/plotly-express/src/deephaven/plot/express/plots/maps.py Deprecate mapbox functions in favor of the new map functions; update parameter names (mapbox_style → map_style) and docstrings accordingly
plugins/plotly-express/setup.cfg & package.json Bump plotly dependency constraints to support plotly version ≥6.0.0
Comments suppressed due to low confidence (3)

plugins/plotly-express/test/deephaven/plot/express/plots/test_indicator.py:236

  • For consistency across tests, consider replacing NULL_INT with PLOTLY_NULL_INT as done in other test files.
from deephaven.constants import NULL_INT

plugins/plotly-express/src/deephaven/plot/express/plots/maps.py:152

  • The deprecation functions now call the new scatter_map; ensure that the docstrings and return descriptions are updated to consistently reflect the new naming and API changes.
def scatter_mapbox(*args, **kwargs) -> DeephavenFigure:

plugins/plotly-express/src/js/src/PlotlyExpressChartModel.ts:794

  • Verify that checking for the substring 'map' in trace types (via hasMap()) does not unintentionally match trace types other than the intended map traces; a stricter condition may be needed.
return this.hasScene() || this.hasGeo() || this.hasMap() || this.hasPolar();

Copy link

plotly-express docs preview (Available for 14 days)

@jnumainville jnumainville marked this pull request as ready for review May 13, 2025 19:54
@@ -68,8 +68,8 @@
"deep-equal": "^2.2.1",
"memoizee": "^0.4.17",
"nanoid": "^5.0.7",
"plotly.js": "^2.29.1",
"plotly.js-dist-min": "^2.29.1",
"plotly.js": "^3.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 805 to 807
hasMap(): boolean {
return this.plotlyData.some(({ type }) => type?.includes('map'));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make all these has* methods private as well, since they're just used internally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

from typing import List


PLOTLY_NULL_INT = {"dtype": "i4", "bdata": "AAAAgA=="}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any more details on these? Any documentation about where these are defined in plotly? I'm guessing you found these as a result of unit tests, but would like to know why these values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is this PR - plotly/plotly.py#4470
Essentially it is a custom base64 spec

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More specifically PLOTLY_NULL_INT is just [NULL_INT] converted to their spec

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment to code

Comment on lines +75 to +78
"close": PLOTLY_NULL_INT,
"high": PLOTLY_NULL_INT,
"low": PLOTLY_NULL_INT,
"open": PLOTLY_NULL_INT,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expects null now, when it expected a 2D array before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2D array was a subtle bug I noticed when going through and doing this PLOTLY_NULL_INT work. See the changes to the function in custom_draw. It should have been a null int array in the first place.

"mapbox": {
"center": {"lat": NULL_INT, "lon": NULL_INT},
"map": {
"center": {"lat": -2147483648.0, "lon": -2147483648.0},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually make sense? How come it's getting these values?

Copy link
Collaborator Author

@jnumainville jnumainville May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been NULL_INT still, fixed.
As to why it is these values, it is because plotly sets the center to the mean of the values by default (see here)
Since the NULL_INT is the only data point passed to plotly for lat and lon, it become the center. It's then not converted to the base64 spec because it is not considered a data array.

"orientation": "h",
"showlegend": False,
"textposition": "auto",
"x": [0.0],
"x": {"bdata": "AA==", "dtype": "i1"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where'd this magic value come from?

Copy link
Collaborator Author

@jnumainville jnumainville May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the [0.0] value encoded in their base64 spec. I didn't create a variable for it because it is not reused.

Copy link

plotly-express docs preview (Available for 14 days)

Copy link

plotly-express docs preview (Available for 14 days)

Copy link

plotly-express docs preview (Available for 14 days)

Copy link

plotly-express docs preview (Available for 14 days)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate dx from Mapbox to MapLibre
2 participants