def create_charts(): page = Page() style = Style( width=WIDTH, height=HEIGHT ) _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) chart = Line3D("3D 折线图-默认", **style.init_style) chart.add("", _data, is_visualmap=True, visual_range_color=RANGE_COLOR, visual_range=[0, 30], grid3d_rotate_sensitivity=5) page.add(chart) _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) chart = Line3D("3D 折线图-自动旋转", **style.init_style) chart.add("", _data, is_visualmap=True, visual_range_color=RANGE_COLOR, visual_range=[0, 30], is_grid3d_rotate=True, grid3d_rotate_speed=180) page.add(chart) return page
def test_line3d(): # line3D_0 import math _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) range_color = ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'] line3d = Line3D("3D 折线图示例", width=1200, height=600) line3d.add("", _data, is_visualmap=True, visual_range_color=range_color, visual_range=[0, 30], grid3d_rotate_sensitivity=5) line3d.render() # line3D_1 import math _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) range_color = ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'] line3d = Line3D("3D 折线图示例", width=1200, height=600) line3d.add("", _data, is_visualmap=True, visual_range_color=range_color, visual_range=[0, 30], is_grid3d_rotate=True, grid3d_rotate_speed=180) line3d.render()
def line3d(request): _data = [] template = loader.get_template('chart/chart.html') for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) range_color = [ '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026' ] line3d = Line3D("3D line plot demo", width=1200, height=600) line3d.add("", _data, is_visualmap=True, visual_range_color=range_color, visual_range=[0, 30], is_grid3D_rotate=True, grid3D_rotate_speed=180) context = dict(myechart=line3d.render_embed(), host=REMOTE_HOST, script_list=line3d.get_js_dependencies()) return HttpResponse(template.render(context, request))
def test_line3d_default(): _data = list(create_line3d_data()) line3d = Line3D("3D 折线图示例", width=1200, height=600) line3d.add("", _data, is_visualmap=True, visual_range_color=RANGE_COLOR, visual_range=[0, 30], grid3d_rotate_sensitivity=5) line3d.render()
def test_line3d_rotate_automatically_speedup(): _data = list(create_line3d_data()) line3d = Line3D("3D 折线图示例", width=1200, height=600) line3d.add("", _data, is_visualmap=True, visual_range_color=RANGE_COLOR, visual_range=[0, 30], is_grid3d_rotate=True, grid3d_rotate_speed=180) line3d.render()
def test_line3d(): # line3d default import math _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) line3d = Line3D("3D 折线图示例", width=1200, height=600) line3d.add("", _data, is_visualmap=True, visual_range_color=RANGE_COLOR, visual_range=[0, 30], grid3d_rotate_sensitivity=5) line3d.render() # line3d rotate automatically speedup _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) line3d = Line3D("3D 折线图示例", width=1200, height=600) line3d.add("", _data, is_visualmap=True, visual_range_color=RANGE_COLOR, visual_range=[0, 30], is_grid3d_rotate=True, grid3d_rotate_speed=180) line3d.render()
def line3d(): _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) range_color = [ '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'] line3d = Line3D("3D line plot demo", width=1200, height=600) line3d.add("", _data, is_visualmap=True, visual_range_color=range_color, visual_range=[0, 30], is_grid3D_rotate=True, grid3D_rotate_speed=180) return line3d
def test_line3d_default(patched): fixture = "line3d_options.json" patched.return_value = "1" _data = list(create_line3d_data()) line3d = Line3D("3D 折线图示例", width=1200, height=600) line3d.add( "", _data, is_visualmap=True, visual_range_color=RANGE_COLOR, visual_range=[0, 30], grid3d_rotate_sensitivity=5, ) actual_options = dumps_actual_options(line3d.options) expected = get_fixture_content(fixture) for a, b in zip(actual_options.split("\n"), expected.split("\n")): eq_(a.strip(), b.strip())
def test_line3d_must_use_canvas(): line3d = Line3D("3D 折线图示例", width=1200, height=600) eq_(line3d.renderer, 'canvas')
line.add("商家B", attr, v2, symbol=None, area_color='#000', **l_style) line.render('area.html') # 3D line import math _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) from pyecharts import Line3D line3d = Line3D("3D 折线图示例") line3d.add("", _data, is_visualmap=True, visual_range=[0, 30]) line3d.render() # ---------------------------------------------------------------------------- # Bar chart # supper simple example bar = Bar('PUBG') bar.add('Time', df.Name, df.Time,bar_category_gap='70%') bar.render() # version 2 (another type & more utils) bar = Bar('PUBG') bar.add('Time', df.Name, df.Time, is_more_utils=True, is_datazoom_show=True, datazoom_type='both') # is_more_utils means more functions beside the chart
range_color = [ '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026' ] scatter3D = Scatter3D("3D 散点图示例", width=1200, height=600) scatter3D.add("", data, is_visualmap=True, visual_range_color=range_color) page.add(scatter3D) page.render('E:\\pye\\scatter.html') # 在指定目录下生成文件 #coding:utf-8 import sys from pyecharts import Line3D # 3D折线图 data = [[1, 2, 3, 4], [1, 2, 3, 4], [0, 4, 8, 16]] Line3D = Line3D("3D 折线图示例", width=1200, height=600) Line3D.add("", data, is_visualmap=True) Line3D.render('E:\\pye\\line3d.html') # 在指定目录下生成文件 #coding:utf-8 from pyecharts import Gauge # 仪表盘 gauge = Gauge('项目完成进度') gauge.add('进度表', '完成率', 88.88) gauge.render('E:\\pye\\gauge.html') # 在指定目录下生成文件 #coding:utf-8 from pyecharts import Funnel # 漏斗图 attr = ['认知', '了解', '认可', '考虑', '意向', '购买'] value = [120, 100, 80, 60, 40, 20]
# -*- coding: utf-8 -*- """ Created on Thu Aug 10 17:12:44 2017 @author: 17549 """ from pyecharts import Line3D import math _data=[] for t in range(0,25000): _t=t/1000 x=(1+0.25*math.cos(75*_t))*math.cos(_t) y=(1+0.25*math.cos(75*_t))*math.sin(_t) z=_t+2.0*math.sin(75*_t) _data.append([x,y,z]) range_color=['#313695','#4575b4','#74add1','#abd9e9','#e0f3f8','#ffffbf', '#fee090','#fdae61','#f46d43','#d73027','#a50026'] line3d=Line3D("3D折线图升级",width=1200,height=600) line3d.add("",_data,is_visualmap=True,visual_range_color=range_color, visual_range=[0,30],is_grid3D_rotate=True,grid3D_rotate_speed=180) line3d.show_config() line3d.render(r"E:\6_3D折线图升级.html")
from pyecharts import Line3D import math _data = [] for t in range(0, 25000): _t = t / 1000 x = (1 + 0.25 * math.cos(75 * _t) * math.cos(_t)) y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) _data.append([x, y, z]) range_color = [ '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026' ] line3d = Line3D("Line 3D 折线图示例", width=1200, height=600) line3d.add("test", _data, is_visualmap=True, visual_range_color=range_color, visual_range=[0, 30], is_grid3d_rotate=True) line3d.render(path="Line3d.html")
''' 绘制3D曲线图 ''' from pyecharts import Line3D import math data = [] for t in range(0, 30000): _t = t / 1000 x = (1 + 0.3 * math.cos(80 * _t)) * math.cos(_t) y = (1 + 0.3 * math.cos(80 * _t)) * math.sin(_t) z = _t + 2.0 * math.sin(75 * _t) data.append([x, y, z]) range_colors = [ '#323799', '#457745', '#7543ad', '#e0f3f8', '#ffffbf', '#fee091', '#fdda66', '#d73028' ] line3d = Line3D('3D折线', width=1200, height=600) line3d.add("", data, is_visualmap=True, visual_range_color=range_colors, visual_range=[0, 30], grid3d_rotate_sensitivity=2) line3d.render('line3d.html')
def test_line3d_must_use_canvas(): line3d = Line3D() eq_(line3d.renderer, "canvas")
def DayCharts(datas): page = Page() style = Style() data_winds = [] data_temps = [] data_fees = [] zero_time = datetime.datetime.now() + datetime.timedelta(minutes=5) for data in datas: data['isnew'] = True if zero_time.strftime("%Y-%m-%d %H:%M") > data['time'].strftime( "%Y-%m-%d %H:%M"): zero_time = data['time'] for data in datas: if data['state'] == 'True' and data['isnew']: data_wind = [] data_temp = [] x = data['room_id'] y = (data['time'] - zero_time).seconds / 60 data_wind.append([x, y, data['expect_wind']]) data_temp.append([x, y, data['expect_temp']]) data['isnew'] = False for data_1 in datas: if (data_1['isnew'] and data_1['room_id'] == data['room_id'] and data_1['state'] == 'False'): x = data_1['room_id'] y = (data_1['time'] - zero_time).seconds / 60 data_wind.append([x, y, data['expect_wind']]) data_temp.append([x, y, data['expect_temp']]) data_1['isnew'] = False break data_winds.append(data_wind) data_temps.append(data_temp) for data in datas: data['isnew'] = True for data in datas: if data['isnew']: data_fee = [] x = data['room_id'] y = (data['time'] - zero_time).seconds / 60 data_fee.append([x, y, data['fee']]) data['isnew'] = False for data_1 in datas: if (data_1['isnew'] and data_1['room_id'] == data['room_id']): x = data_1['room_id'] y = (data_1['time'] - zero_time).seconds / 60 data_fee.append([x, y, data_1['fee']]) data_1['isnew'] = False data_fees.append(data_fee) chart = Line3D("3D 折线图-送风请求", **style.init_style) for data_wind in data_winds: chart.add("", data_wind, is_visualmap=True, visual_range=[0, 30], xaxis3d_name='room_id', yaxis3d_name='minutes', zaxis3d_name='wind_speed', xaxis3d_max=5, zaxis3d_max=3) page.add(chart) chart = Line3D("3D 折线图-设定温度", **style.init_style) for data_temp in data_temps: chart.add("", data_temp, is_visualmap=True, visual_range=[0, 30], xaxis3d_name='room_id', yaxis3d_name='minutes', zaxis3d_name='expect_temperature', xaxis3d_max=5, zaxis3d_max=30) page.add(chart) chart = Line3D("3D 折线图-费用总和", **style.init_style) for data_fee in data_fees: chart.add("", data_fee, is_visualmap=True, visual_range=[0, 30], xaxis3d_name='room_id', yaxis3d_name='minutes', zaxis3d_name='costs', xaxis3d_max=5) page.add(chart) page.render("./DayChart.html") os.system("DayChart.html")