Skip to content

Update CI #4188

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

Merged
merged 11 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 144 additions & 55 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ doc/check-or-enforce-order.py
packages/javascript/jupyterlab-plotly/lib/
packages/python/plotly/jupyterlab_plotly/labextension/
packages/python/plotly/jupyterlab_plotly/nbextension/index.js*

test/percy/*.html
32 changes: 16 additions & 16 deletions doc/python/static-image-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,42 +109,42 @@ If you are running this notebook live, click to [open the output directory](./im

plotly.py can output figures to several raster image formats including **PNG**, ...

```python
~~~python
fig.write_image("images/fig1.png")
```
~~~

**JPEG**, ...

```python
~~~python
fig.write_image("images/fig1.jpeg")
```
~~~

and **WebP**

```python
~~~python
fig.write_image("images/fig1.webp")
```
~~~

#### Vector Formats: SVG and PDF...


plotly.py can also output figures in several vector formats including **SVG**, ...

```python
~~~python
fig.write_image("images/fig1.svg")
```
~~~

**PDF**, ...

```python
~~~python
fig.write_image("images/fig1.pdf")
```
~~~

and **EPS** (requires the poppler library)

```python
~~~python
fig.write_image("images/fig1.eps")
```
~~~

**Note:** It is important to note that any figures containing WebGL traces (i.e. of type `scattergl`, `heatmapgl`, `contourgl`, `scatter3d`, `surface`, `mesh3d`, `scatterpolargl`, `cone`, `streamtube`, `splom`, or `parcoords`) that are exported in a vector format will include encapsulated rasters, instead of vectors, for some parts of the image.

Expand Down Expand Up @@ -199,14 +199,14 @@ Image(img_bytes)
If `kaleido` is installed, it will automatically be used to perform image export. If it is not installed, plotly.py will attempt to use `orca` instead. The `engine` argument to the `to_image` and `write_image` functions can be used to override this default behavior.

Here is an example of specifying that orca should be used:
```python
~~~python
fig.to_image(format="png", engine="orca")
```
~~~

And, here is an example of specifying that Kaleido should be used:
```python
~~~python
fig.to_image(format="png", engine="kaleido")
```
~~~

<!-- #endregion -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@ def open_axes(self, ax, props):
dict(type="y", scale="y", ticks=10),
]
self.scales = [
dict(name="x", domain=props["xlim"], type="linear", range="width",),
dict(name="y", domain=props["ylim"], type="linear", range="height",),
dict(
name="x",
domain=props["xlim"],
type="linear",
range="width",
),
dict(
name="y",
domain=props["ylim"],
type="linear",
range="height",
),
]

def draw_line(self, data, coordinates, style, label, mplobj=None):
Expand Down Expand Up @@ -103,7 +113,7 @@ def __init__(self, renderer):

def html(self):
"""Build the HTML representation for IPython."""
id = random.randint(0, 2 ** 16)
id = random.randint(0, 2**16)
html = '<div id="vis%d"></div>' % id
html += "<script>\n"
html += VEGA_TEMPLATE % (json.dumps(self.specification), id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def test_path():


def test_Figure():
""" if the fig is not associated with a canvas, FakeRenderer shall
not fail. """
"""if the fig is not associated with a canvas, FakeRenderer shall
not fail."""
fig = plt.Figure()
ax = fig.add_subplot(111)
ax.add_patch(plt.Circle((0, 0), 1))
Expand Down
1,950 changes: 1,031 additions & 919 deletions packages/python/plotly/plotly/tests/test_orca/images/linux/fig1.eps

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0
%Produced by poppler pdftops version: 0.71.0 (http://poppler.freedesktop.org)
%Produced by poppler pdftops version: 22.02.0 (http://poppler.freedesktop.org)
%%Creator: Chromium
%%LanguageLevel: 2
%%DocumentSuppliedResources: (atend)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%!PS-Adobe-3.0 EPSF-3.0
%Produced by poppler pdftops version: 0.71.0 (http://poppler.freedesktop.org)
%Produced by poppler pdftops version: 22.02.0 (http://poppler.freedesktop.org)
%%Creator: Chromium
%%LanguageLevel: 2
%%DocumentSuppliedResources: (atend)
Expand Down
2 changes: 1 addition & 1 deletion packages/python/plotly/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ requirements:
- python
- pip
- jupyterlab =3
- nodejs
- nodejs =16
- setuptools
run:
- python
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests==2.12.4
tenacity==6.2.0
pytest==3.5.1
packaging
22 changes: 22 additions & 0 deletions test/percy/snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
static:
options:
waitForTimeout: 6000
execute:
beforeSnapshot: |
const stash = window._canvasStash = [];
Array.from(document.querySelectorAll('canvas')).forEach(c => {
const i = document.createElement('img');
i.src = c.toDataURL();
i.width = c.width;
i.height = c.height;
i.setAttribute('style', c.getAttribute('style'));
i.className = c.className;
i.setAttribute('data-canvasnum', stash.length);
stash.push(c);
c.parentElement.insertBefore(i, c);
c.parentElement.removeChild(c);
});
snapshot:
widths:
- 1280