Skip to main content

renders pyecharts as image

Project description

https://api.travis-ci.org/chfw/pyecharts-snapshot.svg?branch=master https://codecov.io/gh/chfw/pyecharts-snapshot/branch/master/graph/badge.svg

Introduction

pyecharts-snapshot renders the output of pyecharts as a png image.

Quick usage:

$ snapshot render.html

And you will get:

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

Please find the corresponding code in examples folder.

Test status

Fully tested on pypy, python 2.6, 2.7, 3.3, 3.4, 3.5 and 3.6.

Constraints

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

Installation

Tools dependencies

Please install a node.js binary to your operating system. Simply download the tar ball, extract it and place its bin folder in your PATH.

Next, you will need to issue a magic command:

$ npm install -g phantomjs

At the end, please verify if it is there:

$ which phantomjs

If you see it there, continue. Otherwise, start from the begining, ask for help or thank you for your attention.

Package installation

You can install it via pip:

$ pip install pyecharts-snapshot

or clone it and install it:

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

Usages

Programmatical usage is simple:

from pyecharts_snapshot.main import make_a_snapshot

...
somechart.render()
make_a_snapshot('render.html', 'cool_snapshot.png')

Here’s a fully working example code:

# coding=utf-8
from __future__ import unicode_literals
from pyecharts import Bar
from pyecharts_snapshot.main import make_a_snapshot

attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图数据堆叠示例")
bar.add("商家A", attr, v1, is_stack=True)
bar.add("商家B", attr, v2, is_stack=True)
bar.render()
make_a_snapshot('render.html', 'snapshot.png')

Here is the snapshot:

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

Change log

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-0.0.1.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

pyecharts_snapshot-0.0.1-py2.py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 2 Python 3

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