Skip to main content

renders pyecharts output as image

Project description

https://api.travis-ci.org/pyecharts/pyecharts-snapshot.svg https://codecov.io/github/pyecharts/pyecharts-snapshot/coverage.png https://badge.fury.io/py/pyecharts-snapshot.svg https://pepy.tech/badge/pyecharts-snapshot/month https://img.shields.io/github/stars/pyecharts/pyecharts-snapshot.svg?style=social&maxAge=3600&label=Star https://img.shields.io/static/v1?label=continuous%20templating&message=%E6%A8%A1%E7%89%88%E6%9B%B4%E6%96%B0&color=blue&style=flat-square https://img.shields.io/static/v1?label=coding%20style&message=black&color=black&style=flat-square

News - 16.04.2019

Since 0.2.0, NO LONGER, phantomjs is required! NO LONGER, it supports python 2.7

BUT, the capability to render pyecharts in a script has been merged into pyecharts 1.0.0. And the dependency on phantomjs has been sprawn as: snapshot-phantomjs .

If you love to use ‘snapshot’ command line, please continue to use this project.

Introduction

pyecharts-snapshot renders the output of pyecharts/echarts.js as a png, jpeg, gif, eps, svg image, raw base64 encoding or a pdf file at command line.

Usage

Get png:

$ snapshot render.html

And you will get:

https://raw.githubusercontent.com/pyecharts/pyecharts-snapshot/master/images/demo.png

Get pdf:

$ snapshot render.html pdf

And you will get:

https://raw.githubusercontent.com/pyecharts/pyecharts-snapshot/master/images/demo_in_pdf.png

And here the code to generate it

Get svg:

$ snapshot render.html svg

Please be aware that render.html should have configure echarts to do svg rendering. This library, being stupid, does not make canvas rendered image as svg rendered. Here is an example svg file.

Usage details

Command line options:

$ snapshot output.html [png|jpeg|gif|svg|pdf] [delay] [pixel ratio]

where:

delay tells pyecharts-snapshot to take a snapshot after some time measured in seconds. It is needed only when your snapshot is partial because the chart animation takes long than 1.5 second(default). pixel ratio tells pyecharts-snapshot to use a different pixel ratio when generate the image. It defaults to 2.

Programmatical usage is simple:

...
somechart.render(path='cool_snapshot.png')  # delay=1, pixel_ratio=3) 1 second delay, 3 as pixel ratio

where delay as an optional parameter can be given to specify delay_in_seconds.

Coffee

Please buy me a coffee if you think this library helped.

Installation

You can install pyecharts-snapshot via pip:

$ pip install pyecharts-snapshot

or clone it and install it:

$ git clone https://github.com/pyecharts/pyecharts-snapshot.git
$ cd pyecharts-snapshot
$ python setup.py install

And you need to do:

$ pyppeteer-install

Test status

Fully tested on 3.6, 3.7 and 3.8-dev.

Constraints

Only one image at a time. No 3D image support

Design Considerations

  1. Ghost.Py: very hard to install on my own. Dropped

Maintenance Instructions

  1. install pyecharts-snapshot

  2. make demo

  3. take screenshots of grid.pdf and snapshot.pdf in examples folder

docker image: arm use firfox is ok

FROM mcr.microsoft.com/playwright/python:v1.28.0-focal
RUN apt install gcc python3-dev libhdf5-dev -y  # psutils

Contributors in alphabetical order

  1. chengjiandong

  2. chfw Author

Change log

0.2.0 - 17.04.2019

Added

  1. use pyppeteer, pythonic puppeteer for rendering pyecharts image

Removed

  1. python 2, 3.5- support

  2. no more phantomjs dependency

  3. programmatic rendering capability is removed. NO longer it is integrated with pyecharts

0.1.10 - 16.12.2018

Added

  1. #33: Support base64 encoding

0.1.9 - 13.11.2018

Added

  1. Support eps

Updated

  1. Loosen the requirement on lml

0.1.8 - 12.09.2018

Fixed

  1. #28: pixel_ratio as a parameter

0.1.7 - 31.05.2018

Fixed

  1. #23: phantomjs on windows does not like absolute path but file uri formatted ones

0.1.6 - 16.05.2018

Updated

  1. use system temp file instead of current working folder for tmp files

0.1.5 - 11.04.2018

Updated

  1. better error verbose when phantomjs fails to generate output

0.1.4 - 26.03.2018

Added

  1. Tighter integration with pyecharts 0.4.2. SnapshotEnvironment extends the rendering capability of pyecharts

  2. #16: phantomjs check fails on windows

  3. #14: if the output file name has a path, this library fails over

0.1.3 - 12.03.2018

Added

  1. svg support for pyecharts 0.4.0

0.1.2 - 21.12.2017

Updated

  1. #9: delay 1.5 seconds

0.1.1 - 17.12.2017

Updated

  1. higher resolution screenshots for all platforms: windows and linux.

0.1.0 - 15.12.2017

Updated

  1. support Mac OS Retina display, high resolution screenshots

0.0.11 - 2.11.2017

Updated

  1. #7: helpful error message on missing phantomjs.

0.0.10 - 23.10.2017

Updated

  1. pyexcel pyexcel#105, remove gease from setup_requires, introduced by 0.0.9.

0.0.9 - 21.10.2017

Updated

  1. #6: show better

0.0.8 - 08.09.2017

Updated

  1. #5: fix

0.0.7 - 26.08.2017

Updated

  1. Save the output of pyecharts to gif file

0.0.6 - 25.08.2017

Updated

  1. Allow user to specify a custom delay period in seconds. Default is 0.5s

0.0.5 - 22.08.2017

0.0.4 - 19.08.2017

Updated

  1. #1: Support

0.0.3 - 19.08.2017

Updated

  1. Remove download image arrow on the output file

0.0.2 - 18.08.2017

Added

  1. Save the output of pyecharts to pdf file

0.0.1 - 17.08.2017

Added

  1. Save the output of pyecharts to png file

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyecharts-snapshot-pro-0.2.9.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

pyecharts_snapshot_pro-0.2.9-py2.py3-none-any.whl (8.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyecharts-snapshot-pro-0.2.9.tar.gz.

File metadata

File hashes

Hashes for pyecharts-snapshot-pro-0.2.9.tar.gz
Algorithm Hash digest
SHA256 3f9fc3d7ffebe81eb995cddb90fe609fd4a59dd68ec97fa06019700fac1a9247
MD5 c0ff0ae75e97e4fdcaa016302e211fc6
BLAKE2b-256 364ee3340dc3e30a4a1ae55be35accf93e2fbf383f6a1c1051b4e31124c1c439

See more details on using hashes here.

File details

Details for the file pyecharts_snapshot_pro-0.2.9-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyecharts_snapshot_pro-0.2.9-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1b991f1024d407f6ca5ffdcf2633634c8df7ef196de28ab002ac2a989da2aa90
MD5 21a2de580d7445bb22e8afe1e9069af4
BLAKE2b-256 635ae56363921fcedcb690557330cb45b75f9b2319ae797814b1ba72824db18e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page