Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b5563f5

Browse filesBrowse files
michaelbabynjonmmease
authored andcommitted
Emf support for online image export (plotly#1306)
* add emf to images test suite * add scale tests for plot_ly images
1 parent bdafae8 commit b5563f5
Copy full SHA for b5563f5

File tree

Expand file treeCollapse file tree

2 files changed

+7
-12
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-12
lines changed

‎plotly/plotly/plotly.py

Copy file name to clipboardExpand all lines: plotly/plotly/plotly.py
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def get(figure_or_data, format='png', width=None, height=None, scale=None):
712712
describes a plotly figure.
713713
Same argument used in `py.plot`, `py.iplot`,
714714
see https://plot.ly/python for examples
715-
- format: 'png', 'svg', 'jpeg', 'pdf'
715+
- format: 'png', 'svg', 'jpeg', 'pdf', 'emf'
716716
- width: output width
717717
- height: output height
718718
- scale: Increase the resolution of the image by `scale`
@@ -730,7 +730,7 @@ def get(figure_or_data, format='png', width=None, height=None, scale=None):
730730
# TODO: format is a built-in name... we shouldn't really use it
731731
figure = tools.return_figure_from_figure_or_data(figure_or_data, True)
732732

733-
if format not in ['png', 'svg', 'jpeg', 'pdf']:
733+
if format not in ['png', 'svg', 'jpeg', 'pdf', 'emf']:
734734
raise exceptions.PlotlyError(
735735
"Invalid format. This version of your Plotly-Python "
736736
"package currently only supports png, svg, jpeg, and pdf. "
@@ -760,7 +760,8 @@ def get(figure_or_data, format='png', width=None, height=None, scale=None):
760760
if ('content-type' in headers and
761761
headers['content-type'] in ['image/png', 'image/jpeg',
762762
'application/pdf',
763-
'image/svg+xml']):
763+
'image/svg+xml',
764+
'image/emf']):
764765
return response.content
765766
elif ('content-type' in headers and
766767
'json' in headers['content-type']):
@@ -809,7 +810,7 @@ def save_as(cls, figure_or_data, filename, format=None, width=None,
809810
"""Save a image of the plot described by `figure_or_data` locally as
810811
`filename`.
811812
812-
Valid image formats are 'png', 'svg', 'jpeg', and 'pdf'.
813+
Valid image formats are 'png', 'svg', 'jpeg', 'pdf' and 'emf'.
813814
The format is taken as the extension of the filename or as the
814815
supplied format.
815816
@@ -819,7 +820,7 @@ def save_as(cls, figure_or_data, filename, format=None, width=None,
819820
Same argument used in `py.plot`, `py.iplot`,
820821
see https://plot.ly/python for examples
821822
- filename: The filepath to save the image to
822-
- format: 'png', 'svg', 'jpeg', 'pdf'
823+
- format: 'png', 'svg', 'jpeg', 'pdf', 'emf'
823824
- width: output width
824825
- height: output height
825826
- scale: Increase the resolution of the image by `scale` amount

‎plotly/tests/test_plot_ly/test_image/test_image.py

Copy file name to clipboardExpand all lines: plotly/tests/test_plot_ly/test_image/test_image.py
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _test(self):
5959
return _test
6060

6161
kwargs = {
62-
'format': ['png', 'jpeg', 'pdf', 'svg'],
62+
'format': ['png', 'jpeg', 'pdf', 'svg', 'emf'],
6363
'width': [None, 300],
6464
'height': [None, 300],
6565
'scale': [None, 5]
@@ -70,12 +70,6 @@ def _test(self):
7070
for test_generator in [_generate_image_get_returns_valid_image_test,
7171
_generate_image_save_as_saves_valid_image]:
7272

73-
if args[0] in ['jpeg', 'pdf', 'svg'] and args[3] is not None:
74-
# Shouldn't need to skip these tests, the server should
75-
# be responding with a 400 level error since scale isn't supported,
76-
# but it doesn't yet, so just skip them
77-
continue
78-
7973
_test = test_generator(*args)
8074
arg_string = ', '.join([str(a) for a in args])
8175
test_name = test_generator.__name__.replace('_generate', 'test')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.