def test_liquid_svg_path(): shape = ( "path://M367.855,428.202c-3.674-1.385-7.452-1.966-11.146-1" ".794c0.659-2.922,0.844-5.85,0.58-8.719 c-0.937-10.407-7." "663-19.864-18.063-23.834c-10.697-4.043-22.298-1.168-29.9" "02,6.403c3.015,0.026,6.074,0.594,9.035,1.728 c13.626,5." "151,20.465,20.379,15.32,34.004c-1.905,5.02-5.177,9.115-9" ".22,12.05c-6.951,4.992-16.19,6.536-24.777,3.271 c-13.625" "-5.137-20.471-20.371-15.32-34.004c0.673-1.768,1.523-3.423" ",2.526-4.992h-0.014c0,0,0,0,0,0.014 c4.386-6.853,8.145-14" ".279,11.146-22.187c23.294-61.505-7.689-130.278-69.215-153" ".579c-61.532-23.293-130.279,7.69-153.579,69.202 c-6.371," "16.785-8.679,34.097-7.426,50.901c0.026,0.554,0.079,1.121," "0.132,1.688c4.973,57.107,41.767,109.148,98.945,130.793 c58." "162,22.008,121.303,6.529,162.839-34.465c7.103-6.893,17.826" "-9.444,27.679-5.719c11.858,4.491,18.565,16.6,16.719,28.643 " "c4.438-3.126,8.033-7.564,10.117-13.045C389.751,449.992," "382.411,433.709,367.855,428.202z" ) liquid = Liquid("水球图示例", width=1000, height=600) liquid.add( "Liquid", [0.6, 0.5, 0.4, 0.3], shape=shape, is_liquid_outline_show=False, ) liquid.render()
def create_charts(): page = Page() chart_init = { "width": WIDTH, "height": HEIGHT, } chart = Liquid("水球图-单数据", **chart_init) chart.add("Liquid", [0.6]) page.add(chart) chart = Liquid("水球图-多数据", **chart_init) chart.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False) page.add(chart) chart = Liquid("水球图-圆角", **chart_init) chart.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False, shape='roundRect') page.add(chart) chart = Liquid("水球图-箭头", **chart_init) chart.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False, shape='arrow') page.add(chart) chart = Liquid("水球图-动画静止", **chart_init) chart.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=False, shape='diamond') page.add(chart) return page
def run(opts): problem_num = '0' if '-r' in opts[len(opts) - 1]: # 题目数值范围 problem_num = opts[0][1] area = opts[1][1] for j in range(int(problem_num)): problem(area=int(area)) # 生成题目 # print(prints[j] + ' = ') write_to_file(answers, prints) elif '-n' in opts[0]: # 参数控制生成题目的个数(必须) problem_num = opts[0][1] for j in range(int(problem_num)): problem() # 不带 -r 参数就用默认参数生成题目 # print(prints[j] + ' = ') write_to_file(answers, prints) if '-e' in opts[0] or '-a' in opts[0]: # 对答案 txt_list = [] # 题目文件和答案文件 for i in opts: txt_list.append(i[1]) # Exercises.txt 和 Answers.txt r, w = compare(txt_list) accuracy = r / (r + w) # 正确率 liquid = Liquid("正确率(总{}道):".format( str(len(open('Answers.txt', 'r').readlines())))) # 生成水球图 liquid.add('Correct', [accuracy], is_liquid_outline_show=False) liquid.render('成绩水型球.html') nums = len(prints) problem_num = int(problem_num) return nums, problem_num
def test_liquid_diamond_shape(): liquid = Liquid("水球图示例") liquid.add( "Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=False, shape="diamond", ) assert "diamond" in liquid._repr_html_()
def draw_liquid(): liquid = Liquid("水球图示例") # liquid.add("Liquid", [0.6]) #liquid.add("Liquid", [0.8, 0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False) liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=True, shape='diamond') liquid.show_config() liquid.render()
def liqiud_html(self, chart_id, title, val): liquid = Liquid("{}-{}".format(self.datetime, title), title_pos="center", width="100%", title_color="white", title_text_size=14, height=300) liquid.chart_id = chart_id liquid.add("", [round(val / 100, 4)]) return liquid.render_embed()
def Analysis(lyric): module = 'wenzhi' action = 'TextSentiment' config = { 'Region': 'sz', 'secretId': 'AKIDBHCx49tBzc5eTIA6kFoddWUXQDbpq7JQ', 'secretKey': 'gCXHsHFD1eDjJgT7b3TkI4fu1wnjDYbU', 'method': 'post', } params = { 'content': lyric, # 需要分析的歌词 'type': 4, } try: service = QcloudApi(module, config) result = service.call(action, params) except Exception as e: import traceback print('traceback.format_exc():\n%s' % traceback.format_exc()) # 图1 result = eval(str(result, encoding="utf-8")) negative_value = round(result['negative'], 4) positive_value = round(result['positive'], 4) gauge = Gauge("Sentiment", background_color=None, title_color="#274C77", title_text_size=20) gauge.add("Probability of Negative Property", "Negative", value=negative_value * 100, legend_text_color="#274C77", legend_text_size=15, lable_color=["E7ECEF", "#274C77", "FB6107"]) # gauge.show_config() gauge.render('gauge.html') # 图2 liquid2 = Liquid(title="Probability of Positive Property", title_pos='center') liquid2.add("Probability of Positive Property", [positive_value, 0.5, 0.4, 0.3], is_liquid_outline_show=False, shape="pin", liquid_color=["E7ECEF", "#274C77", "FB6107"]) # liquid2.show_config() liquid2.render('pin.html')
def liquid_html(self, chart_id, title, val): """CPU水球图""" # 实例一个具体类型图表的对象,并配置基本项 liquid = Liquid(title="{}-{}".format(self.dt, title), title_pos='center', width='100%', title_color='white', title_text_size=14, height=300) # 绑定id liquid.chart_id = chart_id # 绑定参数 liquid.add("", [round(val / 100, 4)]) return liquid.render_embed() # 返回图表html代码
def liquid_html(self, chart_id, title, val): #基本配置 ''' :param title :param subtitle :param val 水球图的值 :return: html+css+js ''' liquid = Liquid( "{}-{}".format(self.dt, title), #标题的位置 title_pos="center", #图形的宽度比例 width='100%', #图形的高度 height=300, #标题的颜色 title_color="black", #标题的大小 px title_text_size=14, ) #打印图形,每个图形的id要不一致,图形id会变成js中的一个变量 liquid.chart_id = chart_id #水球图的其它参数 #data表示的是水球图中波纹的个数和高度,值是一个list #0.56 liquid.add(name='Liquid', data=[ round((val / 100), 2), round((val / 100), 2) / 2, round((val / 100), 2) / 4 ], shape="roundRect", is_liquid_outline_show=False) #render_embed把当前的liquid对象解析成html css js return liquid.render_embed()
def test_liquid(): # liquid default liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6]) liquid.render() # liquid multiple data liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False) assert "diamond" not in liquid._repr_html_() # liquid shape diamond liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=False, shape='diamond') assert "diamond" in liquid._repr_html_()
def test_liquid(): # liquid_0 liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6]) liquid.render() # liquid_1 liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False) liquid.render() # liquid_2 liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=False, shape='diamond') liquid.render()
from pyecharts import Liquid liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False) liquid.show_config() liquid.render()
def test_liquid_default(): liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6]) liquid.render()
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] funnel = Funnel('客户购买分析图') funnel.add('买车', attr, value, is_label_show=True, label_pos='inside', label_text_color='#fff') funnel.render('E:\\pye\\funel.html') # 在指定目录下生成文件 #coding:utf-8 from pyecharts import Liquid liquid = Liquid("水球图") liquid.add("Liquid", [0.8]) liquid.show_config() liquid.render('E:\\pye\\sq.html') # 在指定目录下生成文件
nodes =[{"name": "结点1", "symbolSize": 10}, {"name": "结点2", "symbolSize": 20}, {"name": "结点3", "symbolSize": 30}, {"name": "结点4", "symbolSize": 40}, {"name": "结点5", "symbolSize": 50}, {"name": "结点6", "symbolSize": 40}, {"name": "结点7", "symbolSize": 30}, {"name": "结点8", "symbolSize": 20}] links =[] for i in nodes: for j in nodes: links.append({"source": i.get('name'), "target": j.get('name')}) print(links) print(nodes) graph =Graph("关系图-环形布局示例") graph.add("", nodes, links, is_label_show=True, repulsion=8000, layout='circular', label_text_color=None) graph.show_config() graph.render(path="./data/02-03关系图.html") """ # 水球图 liquid = Liquid("水球图") liquid.add("Liquid", [0.6]) liquid.show_config() liquid.render(path='./data/03-01水球.html') # 圆形水球 liquid2 = Liquid("水球图示例") liquid2.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False) liquid2.show_config() liquid2.render(path='./data/03-02圆形水球.html') # 菱形水球 liquid3 = Liquid("水球图示例") liquid3.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=False, shape='diamond') liquid3.show_config()
def DrawLiquid(city_name): data = int(qr.get_data(city_name)['SD'].strip('%')) / 100 liquid = Liquid('%s城市湿度' % city_name) liquid.add('湿度', [data]) liquid.render('weatherLiquid.html')
""" 文件名: $NAME.py 日期: 22 作者: lvah 联系: [email protected] 代码描述: """ from pyecharts import Liquid import psutil # cpu_percent = psutil.cpu_percent() # print(cpu_percent) from pyecharts import Liquid # liquid = Liquid("xxxx") # liquid.add("Liquid", [0.6]) # liquid.render() from pyecharts import Liquid liquid = Liquid("xxxx") liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], shape='pin') liquid.render()
#encoding=utf-8 from pyecharts import Liquid liquid = Liquid("水球图示例") arg = 1 if arg == 1: liquid.add("Liquid", [0.6]) liquid.show_config() liquid.render() else: liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=False, shape='diamond') liquid.show_config() liquid.render()
from pyecharts import Liquid from liquidView.sours import * name =input("请输入姓名:") data = queryEmpSalary(name) # print("----------",data) if data is None: print("用户不存在") else: lidata = [] lidata.append(data) print(lidata) liObj = Liquid("员工工资占比图") liObj.add("员工工资占比", lidata) liObj.render(name + ".html")
from pyecharts import Page page = Page() #获得评分水球 from pyecharts import Liquid liquid = Liquid(title + "---猫眼最新" + str(n) + '位用户预测评分', title_color="#fff", title_pos="center", width=1800, height=700) nsum = 0 for i in range(0, len(rate)): nsum += i lrate = nsum / len(rate) liquid.add("评分值", [lrate / 100]) page.add_chart(liquid) print(nsum) print(lrate) print(len(rate)) print(rate) #生成观众评分图 from pyecharts import Pie attr = ["五星", "四星", "三星", "两星", "一星"] v1 = [ rate.count(5) + rate.count(4.5), rate.count(4) + rate.count(3.5), rate.count(3) + rate.count(2.5), rate.count(2) + rate.count(1.5), rate.count(1) + rate.count(0.5) ]
from pyecharts import Liquid liquid = Liquid("水球图示例") data = [0.6, 0.5, 0.4, 0.3] liquid.add("test_Liquid", data, is_liquid_outline_show=False) liquid.render(path="Liquid.html")
from pyecharts import Liquid liquid = Liquid("水球图", title_pos='center') # shape设置水球形状,可以自定义svg,is_liquid_animation开启动画,is_liquid_outline_show显示边框 liquid.add("水球", [0.8, 0.3], shape='roundRect', is_liquid_animation=True, is_liquid_outline_show=True) liquid.render("./liquid.html")
def test_more(): page = Page() # line line = Line("折线图示例") line.add( "最高气温", WEEK, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"], ) line.add( "最低气温", WEEK, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"], mark_line=["average"], ) # pie v1 = [11, 12, 13, 10, 10, 10] pie = Pie("饼图-圆环图示例", title_pos="center") pie.add( "", CLOTHES, v1, radius=[40, 75], label_text_color=None, is_label_show=True, legend_orient="vertical", legend_pos="left", ) page.add([line, pie]) # kline v1 = [ [2320.26, 2320.26, 2287.3, 2362.94], [2300, 2291.3, 2288.26, 2308.38], [2295.35, 2346.5, 2295.35, 2345.92], [2347.22, 2358.98, 2337.35, 2363.8], [2360.75, 2382.48, 2347.89, 2383.76], [2383.43, 2385.42, 2371.23, 2391.82], [2377.41, 2419.02, 2369.57, 2421.15], [2425.92, 2428.15, 2417.58, 2440.38], [2411, 2433.13, 2403.3, 2437.42], [2432.68, 2334.48, 2427.7, 2441.73], [2430.69, 2418.53, 2394.22, 2433.89], [2416.62, 2432.4, 2414.4, 2443.03], [2441.91, 2421.56, 2418.43, 2444.8], [2420.26, 2382.91, 2373.53, 2427.07], [2383.49, 2397.18, 2370.61, 2397.94], [2378.82, 2325.95, 2309.17, 2378.82], [2322.94, 2314.16, 2308.76, 2330.88], [2320.62, 2325.82, 2315.01, 2338.78], [2313.74, 2293.34, 2289.89, 2340.71], [2297.77, 2313.22, 2292.03, 2324.63], [2322.32, 2365.59, 2308.92, 2366.16], [2364.54, 2359.51, 2330.86, 2369.65], [2332.08, 2273.4, 2259.25, 2333.54], [2274.81, 2326.31, 2270.1, 2328.14], [2333.61, 2347.18, 2321.6, 2351.44], [2340.44, 2324.29, 2304.27, 2352.02], [2326.42, 2318.61, 2314.59, 2333.67], [2314.68, 2310.59, 2296.58, 2320.96], [2309.16, 2286.6, 2264.83, 2333.29], [2282.17, 2263.97, 2253.25, 2286.33], [2255.77, 2270.28, 2253.31, 2276.22], ] kline = Kline("K 线图示例") kline.add( "日K", ["2017/7/{}".format(i + 1) for i in range(31)], v1, is_datazoom_show=True, ) page.add(kline) # radar schema = [ ("销售", 6500), ("管理", 16000), ("信息技术", 30000), ("客服", 38000), ("研发", 52000), ("市场", 25000), ] v1 = [[4300, 10000, 28000, 35000, 50000, 19000]] v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] radar = Radar("雷达图示例") radar.config(schema) radar.add("预算分配", v1, is_splitline=True, is_axisline_show=True) radar.add( "实际开销", v2, label_color=["#4e79a7"], is_area_show=False, legend_selectedmode="single", ) page.add(radar) # scatter3d import random data = [ [ random.randint(0, 100), random.randint(0, 100), random.randint(0, 100), ] for _ in range(80) ] scatter3D = Scatter3D("3D 散点图示例", width=1200, height=600) scatter3D.add("", data, is_visualmap=True, visual_range_color=RANGE_COLOR) page.add(scatter3D) # wordcloud name = [ "Sam S Club", "Macys", "Amy Schumer", "Jurassic World", "Charter Communications", "Chick Fil A", "Planet Fitness", "Pitch Perfect", "Express", "Home", "Johnny Depp", "Lena Dunham", "Lewis Hamilton", "KXAN", "Mary Ellen Mark", "Farrah Abraham", "Rita Ora", "Serena Williams", "NCAA baseball tournament", "Point Break", ] value = [ 10000, 6181, 4386, 4055, 2467, 2244, 1898, 1484, 1112, 965, 847, 582, 555, 550, 462, 366, 360, 282, 273, 265, ] wordcloud = WordCloud(width=1300, height=620) wordcloud.add("", name, value, word_size_range=[30, 100], rotate_step=66) page.add(wordcloud) # liquid liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6]) page.add(liquid) assert len(page) == 7 assert isinstance(page[0], Line) assert ( ("echarts" in page.js_dependencies) or ("echarts.min" in page.js_dependencies) ) page.render()
funnel.add("商品", attr, value, is_label_show=True, label_pos="inside", label_text_color="#fff") funnel.render('funnel.html') # ---------------------------------------------------------------------------- # Gauge from pyecharts import Gauge,Liquid gauge = Gauge("仪表盘示例") gauge.add("业务指标", "完成率", 166.66, angle_range=[180, 0], scale_range=[0, 200], is_legend_show=False) gauge.render('Gauge.html') liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6]) liquid.render() # ---------------------------------------------------------------------------- # heatmap import random from pyecharts import HeatMap x_axis = [ "12a", "1a", "2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a", "12p", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p"] y_axis = [ "Saturday", "Friday", "Thursday", "Wednesday", "Tuesday", "Monday", "Sunday"] data = [[i, j, random.randint(0, 50)] for i in range(24) for j in range(7)] heatmap = HeatMap() heatmap.add("热力图直角坐标系", x_axis, y_axis, data, is_visualmap=True,
def test_more(): page = Page() # line line = Line("折线图示例") line.add( "最高气温", WEEK, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"], ) line.add( "最低气温", WEEK, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"], mark_line=["average"], ) # pie v1 = [11, 12, 13, 10, 10, 10] pie = Pie("饼图-圆环图示例", title_pos="center") pie.add( "", CLOTHES, v1, radius=[40, 75], label_text_color=None, is_label_show=True, legend_orient="vertical", legend_pos="left", ) page.add([line, pie]) # kline v1 = [ [2320.26, 2320.26, 2287.3, 2362.94], [2300, 2291.3, 2288.26, 2308.38], [2295.35, 2346.5, 2295.35, 2345.92], [2347.22, 2358.98, 2337.35, 2363.8], [2360.75, 2382.48, 2347.89, 2383.76], [2383.43, 2385.42, 2371.23, 2391.82], [2377.41, 2419.02, 2369.57, 2421.15], [2425.92, 2428.15, 2417.58, 2440.38], [2411, 2433.13, 2403.3, 2437.42], [2432.68, 2334.48, 2427.7, 2441.73], [2430.69, 2418.53, 2394.22, 2433.89], [2416.62, 2432.4, 2414.4, 2443.03], [2441.91, 2421.56, 2418.43, 2444.8], [2420.26, 2382.91, 2373.53, 2427.07], [2383.49, 2397.18, 2370.61, 2397.94], [2378.82, 2325.95, 2309.17, 2378.82], [2322.94, 2314.16, 2308.76, 2330.88], [2320.62, 2325.82, 2315.01, 2338.78], [2313.74, 2293.34, 2289.89, 2340.71], [2297.77, 2313.22, 2292.03, 2324.63], [2322.32, 2365.59, 2308.92, 2366.16], [2364.54, 2359.51, 2330.86, 2369.65], [2332.08, 2273.4, 2259.25, 2333.54], [2274.81, 2326.31, 2270.1, 2328.14], [2333.61, 2347.18, 2321.6, 2351.44], [2340.44, 2324.29, 2304.27, 2352.02], [2326.42, 2318.61, 2314.59, 2333.67], [2314.68, 2310.59, 2296.58, 2320.96], [2309.16, 2286.6, 2264.83, 2333.29], [2282.17, 2263.97, 2253.25, 2286.33], [2255.77, 2270.28, 2253.31, 2276.22], ] kline = Kline("K 线图示例") kline.add( "日K", ["2017/7/{}".format(i + 1) for i in range(31)], v1, is_datazoom_show=True, ) page.add(kline) # radar schema = [ ("销售", 6500), ("管理", 16000), ("信息技术", 30000), ("客服", 38000), ("研发", 52000), ("市场", 25000), ] v1 = [[4300, 10000, 28000, 35000, 50000, 19000]] v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] radar = Radar("雷达图示例") radar.config(schema) radar.add("预算分配", v1, is_splitline=True, is_axisline_show=True) radar.add( "实际开销", v2, label_color=["#4e79a7"], is_area_show=False, legend_selectedmode="single", ) page.add(radar) # scatter3d import random data = [ [ random.randint(0, 100), random.randint(0, 100), random.randint(0, 100), ] for _ in range(80) ] scatter3D = Scatter3D("3D 散点图示例", width=1200, height=600) scatter3D.add("", data, is_visualmap=True, visual_range_color=RANGE_COLOR) page.add(scatter3D) # wordcloud name = [ "Sam S Club", "Macys", "Amy Schumer", "Jurassic World", "Charter Communications", "Chick Fil A", "Planet Fitness", "Pitch Perfect", "Express", "Home", "Johnny Depp", "Lena Dunham", "Lewis Hamilton", "KXAN", "Mary Ellen Mark", "Farrah Abraham", "Rita Ora", "Serena Williams", "NCAA baseball tournament", "Point Break", ] value = [ 10000, 6181, 4386, 4055, 2467, 2244, 1898, 1484, 1112, 965, 847, 582, 555, 550, 462, 366, 360, 282, 273, 265, ] wordcloud = WordCloud(width=1300, height=620) wordcloud.add("", name, value, word_size_range=[30, 100], rotate_step=66) page.add(wordcloud) # liquid liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6]) page.add(liquid) assert len(page) == 7 assert isinstance(page[0], Line) assert ( ("echarts" in page.js_dependencies) or ("echarts.min" in page.js_dependencies) ) page.render()
line10 = Line('二次消费以上生命周期人数分布图') line10.add('天数/天', zhouqi['生命周期'].values, zhouqi['用户id'].values) line10.render(path=r'KPI/orders/生命周期人数分布图.html') line10 # 所有用户的平均生命周期为36天,中位数为0天,也就是超过一半的用户只消费了一次,这些用户是低质量用户。最大生命周期为576天,相当于这个数据集的总天数,说明该用户从开始到最后都有消费意愿的高质量用户 # In[173]: # 只消费一次占比 user = orders.groupby(['用户id'])['订单处理时间'].agg(['min', 'max']) num_consumption = (user['min'] == user['max']).value_counts() Percent = round(num_consumption / num_consumption.sum(), 4) from pyecharts import Liquid liquid = Liquid('只消费一次的消费者占比') liquid.add('', Percent, is_liquid_outline_show=False) liquid.render(path=r'KPI/orders/只消费一次的消费者占比.html') liquid # ##### 用户分层 # RFM模式中: # # R表示客户购买的时间有多远, # # F(Frequency)表示客户在时间内购买的次数, # # M(Monetary)表示客户在时间内购买的金额 # In[214]:
def test_liquid_multiple_data(): liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False) assert "diamond" not in liquid._repr_html_()
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> # Part 12 Create WaterBall with Pyecharts >>> from pyecharts import Liquid >>> lq=Liquid("WaterBall") >>> lq.add("Liquid", [0.8, 0.5, 0.2], is_liquid_outline_show=False, is_liquid_animation=True) <pyecharts.charts.liquid.Liquid object at 0x008C8F50> >>> lq.render() >>>
def img8(): liquid3 = Liquid("height", width="100%") liquid3.add("Liquid", [0.6]) return liquid3.render_embed()
def test_more(): page = Page() # line attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] line = Line("折线图示例") line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"]) line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"], mark_line=["average"]) page.add(line) # pie attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"] v1 = [11, 12, 13, 10, 10, 10] pie = Pie("饼图-圆环图示例", title_pos='center') pie.add("", attr, v1, radius=[40, 75], label_text_color=None, is_label_show=True, legend_orient='vertical', legend_pos='left') page.add(pie) # kline v1 = [[2320.26, 2320.26, 2287.3, 2362.94], [2300, 2291.3, 2288.26, 2308.38], [2295.35, 2346.5, 2295.35, 2345.92], [2347.22, 2358.98, 2337.35, 2363.8], [2360.75, 2382.48, 2347.89, 2383.76], [2383.43, 2385.42, 2371.23, 2391.82], [2377.41, 2419.02, 2369.57, 2421.15], [2425.92, 2428.15, 2417.58, 2440.38], [2411, 2433.13, 2403.3, 2437.42], [2432.68, 2334.48, 2427.7, 2441.73], [2430.69, 2418.53, 2394.22, 2433.89], [2416.62, 2432.4, 2414.4, 2443.03], [2441.91, 2421.56, 2418.43, 2444.8], [2420.26, 2382.91, 2373.53, 2427.07], [2383.49, 2397.18, 2370.61, 2397.94], [2378.82, 2325.95, 2309.17, 2378.82], [2322.94, 2314.16, 2308.76, 2330.88], [2320.62, 2325.82, 2315.01, 2338.78], [2313.74, 2293.34, 2289.89, 2340.71], [2297.77, 2313.22, 2292.03, 2324.63], [2322.32, 2365.59, 2308.92, 2366.16], [2364.54, 2359.51, 2330.86, 2369.65], [2332.08, 2273.4, 2259.25, 2333.54], [2274.81, 2326.31, 2270.1, 2328.14], [2333.61, 2347.18, 2321.6, 2351.44], [2340.44, 2324.29, 2304.27, 2352.02], [2326.42, 2318.61, 2314.59, 2333.67], [2314.68, 2310.59, 2296.58, 2320.96], [2309.16, 2286.6, 2264.83, 2333.29], [2282.17, 2263.97, 2253.25, 2286.33], [2255.77, 2270.28, 2253.31, 2276.22]] kline = Kline("K 线图示例") kline.add("日K", ["2017/7/{}".format(i + 1) for i in range(31)], v1) page.add(kline) # radar schema = [("销售", 6500), ("管理", 16000), ("信息技术", 30000), ("客服", 38000), ("研发", 52000), ("市场", 25000)] v1 = [[4300, 10000, 28000, 35000, 50000, 19000]] v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] radar = Radar("雷达图示例") radar.config(schema) radar.add("预算分配", v1, is_splitline=True, is_axisline_show=True) radar.add("实际开销", v2, label_color=["#4e79a7"], is_area_show=False, legend_selectedmode='single') page.add(radar) # scatter3d import random data = [[ random.randint(0, 100), random.randint(0, 100), random.randint(0, 100) ] for _ in range(80)] 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) # wordcloud name = [ 'Sam S Club', 'Macys', 'Amy Schumer', 'Jurassic World', 'Charter Communications', 'Chick Fil A', 'Planet Fitness', 'Pitch Perfect', 'Express', 'Home', 'Johnny Depp', 'Lena Dunham', 'Lewis Hamilton', 'KXAN', 'Mary Ellen Mark', 'Farrah Abraham', 'Rita Ora', 'Serena Williams', 'NCAA baseball tournament', 'Point Break' ] value = [ 10000, 6181, 4386, 4055, 2467, 2244, 1898, 1484, 1112, 965, 847, 582, 555, 550, 462, 366, 360, 282, 273, 265 ] wordcloud = WordCloud(width=1300, height=620) wordcloud.add("", name, value, word_size_range=[30, 100], rotate_step=66) page.add(wordcloud) # liquid liquid = Liquid("水球图示例") liquid.add("Liquid", [0.6]) page.add(liquid) page.render()
# 关闭数据库链接 def sql_close(): cur.close() conn.close() proc = 0.00 page = Page() # 爬取进度 liquid = Liquid('网页爬取进度') nowpro = sql_count() / 6977 proc = Decimal(nowpro).quantize(Decimal('0.00')) liquid.add("爬取进度", [str(proc)]) # 3D 柱状图 bar3d = Bar3D("豆瓣评分", width=1620, height=720) datalist = sql_select(0, 6977) # 书名 x_axis = [] y_axis = [] data = [] y = 0 x = 0 # 词库云 book_name = [] reviews = [] for book in datalist: