コード例 #1
0
def test_echarts_js_dependencies():
    env = EchartsEnvironment(pyecharts_config=PyEchartsConfig()
                             # pyecharts_config=PyEchartsConfig()
                             )
    tpl = env.get_template('tpl_demo.html')
    bar = create_demo_bar()
    html = tpl.render(bar=bar)
    # flake8: noqa
    write_utf8_html_file('my_tpl_demo4.html', html)
コード例 #2
0
def dataframe_line_plot(df, title='', path=None):
    option = {
        'title': {
            'text': title,
            'left': 'center'
        },
        'legend': {
            'show': True,
            'orient': 'vertical',
            'right': '9%',
            'top': '3%'
        },
        'xAxis': {
            'type': 'time',
            'axisLine': {
                'onZero': False
            }
        },
        'yAxis': {
            'axisLine': {
                'onZero': False
            }
        },
        'dataZoom': [{
            'type': 'slider',
            'xAxisIndex': 0,
            'start': 0,
            'end': 50
        }]
    }

    time = [ts.timestamp() / 0.001 for ts in df.index]
    series = []
    for channel in df.columns:
        values = df[channel].values.tolist()
        data = [(t, x) for t, x in zip(time, values)]
        series.append({
            'type': 'line',
            'showSymbol': False,
            'name': channel,
            'data': data
        })
    option.update({'series': series})

    line_plot = Line()
    line_plot._option.update(option)

    conf = PyEchartsConfig(echarts_template_dir='html',
                           jshost='js',
                           force_js_embed=False)
    env = EchartsEnvironment(pyecharts_config=conf)
    tpl = env.get_template('template.html')
    html = tpl.render(chart=line_plot)
    write_utf8_html_file(path, html)
コード例 #3
0
    def genReport(self, filetype="html", timeout=60):
        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, is_toolbox_show=False)
        bar.add("商家B", attr, v2, is_stack=True)

        config = PyEchartsConfig(echarts_template_dir=Report.TEMPLATE_DIR)
        env = EchartsEnvironment(pyecharts_config=config)
        tpl = env.get_template(Report.REPORT_HTML)
        html = tpl.render(bar=bar)
        name = 'report_%s'%self.getUID()
        write_utf8_html_file("%s/%s.html"%(Report.OUT_DIR, name), html)
        
        if "pdf"==filetype:
            cmd = "phantomjs make_pdf.js %s"%name
            self.PopenWithTimeout(cmd, cwd=Report.OUT_DIR, timeout=timeout)
コード例 #4
0
# -*- coding: utf-8 -*-
"""
@author:XuMing([email protected])
@description: 
"""

from __future__ import unicode_literals

from pyecharts import Bar
from pyecharts.conf import PyEchartsConfig
from pyecharts.engine import EchartsEnvironment
from pyecharts.utils import write_utf8_html_file

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)

config = PyEchartsConfig(echarts_template_dir='./',
                         jshost='https://cdn.bootcss.com/echarts/3.6.2')
env = EchartsEnvironment(pyecharts_config=config)
tpl = env.get_template('tpl.html')

html = tpl.render(bar=bar)
write_utf8_html_file('my_tpl_demo2.html', html)
コード例 #5
0
# coding=utf8

from __future__ import unicode_literals

from pyecharts import Bar
from pyecharts.conf import PyEchartsConfig
from pyecharts.engine import EchartsEnvironment
from pyecharts.utils import write_utf8_html_file

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)
config = PyEchartsConfig(echarts_template_dir='my_tpl', jshost='https://cdn.bootcss.com/echarts/3.6.2')
env = EchartsEnvironment(pyecharts_config=config)
tpl = env.get_template('tpl_demo.html')
html = tpl.render(bar=bar)
write_utf8_html_file('my_tpl_demo2.html', html)
コード例 #6
0
from __future__ import unicode_literals

from pyecharts import Bar
from pyecharts.conf import PyEchartsConfig
from pyecharts.engine import EchartsEnvironment
from pyecharts.utils import write_utf8_html_file

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)
config = PyEchartsConfig(echarts_template_dir='my_tpl',
                         jshost='https://cdn.bootcss.com/echarts/3.6.2')
env = EchartsEnvironment(pyecharts_config=config)
tpl = env.get_template('tpl_demo.html')
html = tpl.render(bar=bar)
write_utf8_html_file('my_tpl_demo2.html', html)
コード例 #7
0
ファイル: pyechart_demo1.py プロジェクト: kaikee-Snow/Pylib
from __future__ import unicode_literals
from pyecharts import Bar
from pyecharts.conf import PyEchartsConfig
from pyecharts.engine import EchartsEnvironment
from pyecharts.utils import write_utf8_html_file

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)
config = PyEchartsConfig(echarts_template_dir='my_tpl',
                         jshost='https://cdn.bootcss.com/echarts/3.6.2')
env = EchartsEnvironment(pyecharts_config=config)
tpl = env.get_template(r'D:\python\tpl_demo.html')
html = tpl.render(bar=bar)
write_utf8_html_file('my_tpl_demo2.html', html)
コード例 #8
0
#coding=utf-8
from __future__ import unicode_literals

from pyecharts import Line
from pyecharts.conf import PyEchartsConfig
from pyecharts.engine import EchartsEnvironment
from pyecharts.utils import write_utf8_html_file

attr = ["2018/03/11", "2018/03/18", "2018/03/25", "2018/04/01", "2018/04/08"]
selectedColumn = "Visitor Count"
column = 'Column: {}'.format(selectedColumn)
line = Line(column)
v1 = [661.0, 359.0, 358.0, 536.0, 391.0]
v2 = [102.0, 906.0, 84.0, 878.0, 115.0]
line.add("VP1", attr, v1, mark_point=["average", "max", "min"])
line.add("VP2", attr, v2, mark_point=["average", "max", "min"])
line.add("Filter",
         attr, [430] * len(v1),
         is_fill=True,
         area_opacity=0.3,
         is_smooth=True)  #,is_toolbox_show=False
config = PyEchartsConfig(echarts_template_dir='./')
env = EchartsEnvironment(pyecharts_config=config)
tpl = env.get_template('chart_template.html')
html = tpl.render(line=line)
write_utf8_html_file('chart_out.html', html)