Skip to content

Commit c2a4e5e

Browse files
authored
0.1.31 (#22)
* chore: fix ruff errors * chore: add ruff cache to .gitignore * refactor: deprecate copy to clipboard * feat: pass additional **kwargs to requests.post * chore: format with black * chore: update github action * feat: bump version
1 parent 5e05325 commit c2a4e5e

File tree

9 files changed

+42
-71
lines changed

9 files changed

+42
-71
lines changed

.github/workflows/testing.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
33

4-
name: testing
4+
name: Linting and testing
55

66
on:
77
push:
88
branches: ["*"]
99
pull_request:
1010
branches: ["latest"]
11+
workflow_dispatch:
1112

1213
jobs:
13-
build:
14+
lint:
1415
runs-on: ubuntu-20.04
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
19-
2016
steps:
2117
- uses: actions/checkout@v3
22-
- name: Set up Python ${{ matrix.python-version }}
18+
- name: Set up Python 3
2319
uses: actions/setup-python@v3
2420
with:
25-
python-version: ${{ matrix.python-version }}
21+
python-version: "3.x"
2622
- name: Install dependencies
2723
run: |
2824
python -m pip install --upgrade pip
2925
python -m pip install flake8 pytest coverage
3026
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31-
- name: blacken
27+
- name: Check format is Black
3228
uses: psf/black@stable
3329
with:
3430
src: "./easychart"
@@ -38,6 +34,24 @@ jobs:
3834
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3935
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
4036
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
test:
38+
runs-on: ubuntu-20.04
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
43+
44+
steps:
45+
- uses: actions/checkout@v3
46+
- name: Set up Python ${{ matrix.python-version }}
47+
uses: actions/setup-python@v3
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
- name: Install dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
python -m pip install flake8 pytest coverage
54+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
4155
- name: Test with pytest
4256
run: |
4357
coverage run -m pytest tests/*

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,8 @@ dmypy.json
130130
#Mac files
131131
.DS_Store
132132

133-
notes.txt
133+
notes.txt
134+
135+
# Ruff
136+
.ruff_cache
137+
.ruff_cache/*

easychart/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import easychart.extensions as ext
1313
import easychart.rendering
1414

15-
__version__ = "0.1.30"
15+
__version__ = "0.1.31"
1616

1717

1818
def new(

easychart/ipynb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
try:
22
ip = get_ipython() # noqa: F821
3-
except:
3+
except Exception:
44
ip = None
55

66
if ip and (

easychart/models/chart.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ def draw(
11351135
"point": point
11361136
or (
11371137
None
1138-
if (x == y == None)
1138+
if (x is y is None)
11391139
else {"x": x, "y": y, "xAxis": xAxis, "yAxis": yAxis}
11401140
),
11411141
"x": xOffset,
@@ -1238,6 +1238,9 @@ def export(self, filename, *, theme=None, scale=2, throttle=None, **kwargs):
12381238
as to respect the rate limit of the export server
12391239
12401240
defaults to easychart.config.exporting['rate-limit'] or 10 seconds
1241+
1242+
**kwargs : dict (optional)
1243+
Additional arguments to pass to the HTTP request
12411244
"""
12421245
if filename[-3:] not in ["png", "jpg", "jpeg", "svg", "pdf"]:
12431246
raise ValueError(
@@ -1257,12 +1260,13 @@ def export(self, filename, *, theme=None, scale=2, throttle=None, **kwargs):
12571260
"scale": scale,
12581261
"globalOptions": easychart.themes.get(theme),
12591262
},
1263+
**kwargs,
12601264
)
12611265

12621266
if res.status_code == 429:
12631267
raise Exception(
12641268
textwrap.dedent(
1265-
f"""
1269+
"""
12661270
The export server responded with HTTP code 429, which means you are making too many export requests in too short a period of time.
12671271
12681272
Please increase the throttle value, or manually set a time.sleep between each export request.

easychart/models/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ def append(self, data=None, **kwargs):
9191
if isinstance(kwargs["index"], collections.abc.Iterable):
9292
data = data.values.tolist()
9393
elif isinstance(kwargs["index"], bool):
94-
if kwargs["index"] == False:
94+
if kwargs["index"] is False:
9595
data = data.values.tolist()
96-
if kwargs["index"] == True:
96+
if kwargs["index"] is True:
9797
data = data.reset_index().values.tolist()
9898
else:
9999
data = data.reset_index().values.tolist()

easychart/rendering.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import IPython
21
import os
32
import simplejson
43
import html
@@ -42,8 +41,7 @@ def render(charts) -> str:
4241
return f"""
4342
<iframe
4443
style="border:0;outline:none;width:{easychart.internals.Size(grid.width or easychart.config.rendering.container.width)};max-width:{easychart.internals.Size(easychart.config.rendering.container.get("max-width", "100%"))}"
45-
onload='javascript:(function(o){{o.style.height=Math.max(400, o.contentWindow.document.body.scrollHeight)+"px"; o.contentWindow.focus()}}(this));'
46-
allow="clipboard-read; clipboard-write"
44+
onload='javascript:(function(o){{o.style.height=Math.max(400, o.contentWindow.document.body.scrollHeight)+"px"}}(this));'
4745
srcdoc="{html.escape(template)}">
4846
</iframe>
4947
"""

easychart/template.jinja

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -83,57 +83,8 @@
8383
else {
8484
var chart = Highcharts.chart(
8585
`container[${i}]`,
86-
{
87-
...plot.chart,
88-
exporting:{
89-
...plot.chart.exporting,
90-
"menuItemDefinitions": {
91-
"copy": {
92-
onclick: function () {
93-
return callback()
94-
},
95-
text: 'Copy as PNG'
96-
}
97-
},
98-
"buttons": {
99-
"contextButton": {
100-
"menuItems": ["copy", "separator", "viewFullscreen", "printChart", "separator", "downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG",]
101-
}
102-
}
103-
}
104-
}
86+
plot.chart
10587
);
106-
107-
var callback = function (chart, options) {
108-
// copy chart to clipboard as PNG
109-
var callback = function () {
110-
var canvas = document.createElement('canvas');
111-
canvas.height = chart.chartHeight * options.scale;
112-
canvas.width = chart.chartWidth * options.scale;
113-
114-
var image = new Image(
115-
canvas.width,
116-
canvas.height
117-
);
118-
119-
image.onload = function () {
120-
canvas.getContext("2d").drawImage(image, 0, 0, image.width, image.height);
121-
122-
canvas.toBlob(blob => {
123-
return navigator.clipboard.write([
124-
new ClipboardItem({
125-
'image/png': blob
126-
})
127-
]).catch(e => {
128-
console.log("Error", e)
129-
});
130-
}, "image/png")
131-
};
132-
133-
image.src = 'data:image/svg+xml,' + encodeURIComponent(chart.getSVG());
134-
}
135-
return callback
136-
}(chart, { scale: 2 })
13788
}
13889
}
13990
catch(error){

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="easychart",
8-
version="0.1.30",
8+
version="0.1.31",
99
author="david.schenck@outlook.com",
1010
author_email="david.schenck@outlook.com",
1111
description="Highcharts meets python in your Jupyter notebook",

0 commit comments

Comments
 (0)