Skip to content

Commit 72fb5cd

Browse files
authored
Merge branch 'main' into docs-update-next-release
2 parents ec640bd + 51fb8b3 commit 72fb5cd

17 files changed

+493
-1284
lines changed

js/install.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"schemaVersion": 1,
3-
"name": "jupyterlab-plotly",
3+
"packageName": "jupyterlab-plotly",
44
"version": "6.0.1",
5+
"packageManager": "python",
56
"jupyterlab": {
67
"mimeExtension": "lib/mimeExtension.js"
78
}
8-
}
9-
9+
}

js/lib/mimeExtension.js

Lines changed: 99 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/package-lock.json

Lines changed: 132 additions & 974 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {
2121
"lodash-es": "^4.17.21",
22-
"plotly.js": "3.0.1",
22+
"plotly.js": "3.0.3",
2323
"@lumino/widgets": "~2.4.0"
2424
},
2525
"devDependencies": {

plotly/basedatatypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,8 +3404,8 @@ def show(self, *args, **kwargs):
34043404
plot is. The default is set in plotly.js.
34053405
34063406
height: int or float
3407-
An integer or float that determines the number of pixels wide the
3408-
plot is. The default is set in plotly.js.
3407+
An integer or float specifying the height of the plot in pixels.
3408+
The default is set in plotly.js.
34093409
34103410
config: dict
34113411
A dict of parameters to configure the figure. The defaults are set

plotly/io/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from ._html import to_html, write_html
1818
from ._renderers import renderers, show
1919
from . import base_renderers
20-
from ._kaleido import defaults
20+
from ._kaleido import defaults, get_chrome
2121

2222
__all__ = [
2323
"to_image",
@@ -38,6 +38,7 @@
3838
"base_renderers",
3939
"full_figure_for_development",
4040
"defaults",
41+
"get_chrome",
4142
]
4243
else:
4344
__all__, __getattr__, __dir__ = relative_import(
@@ -59,6 +60,7 @@
5960
"._renderers.renderers",
6061
"._renderers.show",
6162
"._kaleido.defaults",
63+
"._kaleido.get_chrome",
6264
],
6365
)
6466

plotly/io/_kaleido.py

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,13 @@ def full_figure_for_development(
775775
return go.Figure(fig, skip_invalid=True)
776776

777777

778-
def get_chrome() -> None:
778+
def plotly_get_chrome() -> None:
779779
"""
780780
Install Google Chrome for Kaleido (Required for Plotly image export).
781-
This function can be run from the command line using the command `plotly_get_chrome`
782-
defined in pyproject.toml
781+
This function is a command-line wrapper for `plotly.io.get_chrome()`.
782+
783+
When running from the command line, use the command `plotly_get_chrome`;
784+
when calling from Python code, use `plotly.io.get_chrome()`.
783785
"""
784786

785787
usage = """
@@ -813,16 +815,60 @@ def get_chrome() -> None:
813815

814816
# Handle "--path" flag
815817
chrome_install_path = None
816-
user_specified_path = False
817818
if "--path" in cli_args:
818819
path_index = cli_args.index("--path") + 1
819820
if path_index < len(cli_args):
820821
chrome_install_path = cli_args[path_index]
821822
cli_args.remove("--path")
822823
cli_args.remove(chrome_install_path)
823824
chrome_install_path = Path(chrome_install_path)
824-
user_specified_path = True
825+
826+
# If any arguments remain, command syntax was incorrect -- print usage and exit
827+
if len(cli_args) > 1:
828+
print(usage)
829+
sys.exit(1)
830+
831+
if not cli_yes:
832+
print(
833+
f"""
834+
Plotly will install a copy of Google Chrome to be used for generating static images of plots.
835+
Chrome will be installed at: {chrome_install_path}"""
836+
)
837+
response = input("Do you want to proceed? [y/n] ")
838+
if not response or response[0].lower() != "y":
839+
print("Cancelled")
840+
return
841+
print("Installing Chrome for Plotly...")
842+
exe_path = get_chrome(chrome_install_path)
843+
print("Chrome installed successfully.")
844+
print(f"The Chrome executable is now located at: {exe_path}")
845+
846+
847+
def get_chrome(path: Union[str, Path, None] = None) -> Path:
848+
"""
849+
Get the path to the Chrome executable for Kaleido.
850+
This function is used by the `plotly_get_chrome` command line utility.
851+
852+
Parameters
853+
----------
854+
path: str or Path or None
855+
The path to the directory where Chrome should be installed.
856+
If None, the default download path will be used.
857+
"""
858+
if not kaleido_available() or kaleido_major() < 1:
859+
raise ValueError(
860+
"""
861+
This command requires Kaleido v1.0.0 or greater.
862+
Install it using `pip install 'kaleido>=1.0.0'` or `pip install 'plotly[kaleido]'`."
863+
"""
864+
)
865+
866+
# Use default download path if no path was specified
867+
if path:
868+
user_specified_path = True
869+
chrome_install_path = Path(path) # Ensure it's a Path object
825870
else:
871+
user_specified_path = False
826872
from choreographer.cli.defaults import default_download_path
827873

828874
chrome_install_path = default_download_path
@@ -848,25 +894,7 @@ def get_chrome() -> None:
848894
"""
849895
)
850896

851-
# If any arguments remain, command syntax was incorrect -- print usage and exit
852-
if len(cli_args) > 1:
853-
print(usage)
854-
sys.exit(1)
855-
856-
if not cli_yes:
857-
print(
858-
f"""
859-
Plotly will install a copy of Google Chrome to be used for generating static images of plots.
860-
Chrome will be installed at: {chrome_install_path}"""
861-
)
862-
response = input("Do you want to proceed? [y/n] ")
863-
if not response or response[0].lower() != "y":
864-
print("Cancelled")
865-
return
866-
print("Installing Chrome for Plotly...")
867-
exe_path = kaleido.get_chrome_sync(path=chrome_install_path)
868-
print("Chrome installed successfully.")
869-
print(f"The Chrome executable is now located at: {exe_path}")
897+
return kaleido.get_chrome_sync(path=chrome_install_path)
870898

871899

872900
__all__ = ["to_image", "write_image", "scope", "full_figure_for_development"]

plotly/labextension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {
2121
"lodash-es": "^4.17.21",
22-
"plotly.js": "3.0.1",
22+
"plotly.js": "3.0.3",
2323
"@lumino/widgets": "~2.4.0"
2424
},
2525
"devDependencies": {
@@ -32,7 +32,7 @@
3232
"mimeExtension": true,
3333
"outputDir": "../plotly/labextension",
3434
"_build": {
35-
"load": "static/remoteEntry.ee69569354eef8c6803d.js",
35+
"load": "static/remoteEntry.fafc1a00b6eac93ead89.js",
3636
"mimeExtension": "./mimeExtension"
3737
}
3838
}

plotly/labextension/static/340.2a23c8275d47a2531dae.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

plotly/labextension/static/340.e13d674598350634d78a.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)