Skip to main content

Embeded Python functions in pyecharts

Project description


pyecharts-javascripthon helps translate Python functions into javascript ones. It uses javascripthon and dukpy to blend Python codes into javascript runtime. It supports python 2.7, 3.4, 3.5 and 3.6. It works on Linux, MacOS and Windows platforms.

Sample python function:

def renderItem(params, api):
    values = [api.value(0), api.value(1)]
    coord = api.coord(values)
    size = api.size([1, 1], values)
    return {
        "type": 'sector',
        "shape": {
            "cx": params['coordSys']['cx'],
            "startAngle": coord[3] - size[1] / 2

Compiled python functions:

function renderItem(params, api) {
    var coord, size, values;
    values = [api.value(0), api.value(1)];
    coord = api.coord(values);
    size = api.size([1, 1], values);
    return {"type": "sector", "shape": {"cx": params["coordSys"]["cx"], "startAngle": (coord[3] - (size[1] / 2))}};

From Python 2.7 to Python 3.4

Internet access is required because it uses javascripthon api as a free service. Down the line, community sponsorship will be required to cover the running cost of the service.

Because the service is still under development, the default api key and api host are subjected to change. When it does happen please declare these environment variables to continue:

for unix alike systems:

export SCRIPTHON_HOST=new_ip_address_or_domain_name
export SCRIPTION_API_TOKEN=new_api_key

for windows systems:

set SCRIPTHON_HOST=new_ip_address_or_domain_name
set SCRIPTION_API_TOKEN=new_api_key

Python 3.5 - 3.6

No internet access is required.


1. Only Python 3.5+ code can be transcompiled. If you use python 2.7 or 3.4, you are obliged to use generic Python codes so that python 2.7 and 3.4 interpreter do not complain.

  1. For browsers DOM object, please include some of these statements so as to ‘blind’ python interpreter:
from pyecharts_javascripthon.dom.objects import window    # for window object
from pyecharts_javascripthon.dom.objects import Document  # for Document object
from pyecharts_javascripthon.dom.objects import Date      # for Date object


javascripthon: Alberto Berti

Dukpy: Alessandro Molina and Sviatoslav Sydorenko <


You can install pyecharts-javascripthon via pip:

$ pip install pyecharts-javascripthon

or clone it and install it:

$ git clone
$ cd pyecharts-javascripthon
$ python install

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.

Files for pyecharts-javascripthon, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size pyecharts_javascripthon-0.0.3-py2.py3-none-any.whl (9.2 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size pyecharts-javascripthon-0.0.3.tar.gz (7.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page