Skip to main content

Embeded Python functions in pyecharts

Project description

https://api.travis-ci.org/pyecharts/pyecharts-javascripthon.svg?branch=master https://codecov.io/gh/pyecharts/pyecharts-javascripthon/branch/master/graph/badge.svg https://readthedocs.org/projects/pyecharts-javascripthon/badge/?version=latest

Introduction

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.

Usage

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

Credits

javascripthon: Alberto Berti

Dukpy: Alessandro Molina and Sviatoslav Sydorenko <https://github.com/webknjaz

Installation

You can install pyecharts-javascripthon via pip:

$ pip install pyecharts-javascripthon

or clone it and install it:

$ git clone https://github.com/pyecharts/pyecharts-javascripthon.git
$ cd pyecharts-javascripthon
$ python setup.py 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.

Source Distribution

pyecharts-javascripthon-0.0.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyecharts_javascripthon-0.0.2-py2.py3-none-any.whl (9.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyecharts-javascripthon-0.0.2.tar.gz.

File metadata

File hashes

Hashes for pyecharts-javascripthon-0.0.2.tar.gz
Algorithm Hash digest
SHA256 48163f48dec942eace9e11ccd7e50ed709f94d2024775f5123adab3cc7c2ebe1
MD5 b7a46e9f4614cf089223079fdc4efa1c
BLAKE2b-256 82451544603d47a06f67e7f08363ed0725a891f48b1c0059478ee7ced34b7f91

See more details on using hashes here.

File details

Details for the file pyecharts_javascripthon-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyecharts_javascripthon-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 21cd511041f5bfa482c6d490e438592462c11044efb87bb792df44ab4b599c84
MD5 4591f665b3ef7db65ab56ca33fa3b86b
BLAKE2b-256 31dd42a2ea373bc07b6a5ff2c73640d17fafdca40f267069cb6bf53baf452230

See more details on using hashes here.

Supported by

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