def home(): _pie = pie_chart(w=260, h=240, is_show=False, is_toolbox_show=False) pie_javascript_snippet = TRANSLATOR.translate(_pie.options) _bar = bar_chart(w=220, h=220, is_show=False, is_toolbox_show=False) pie_javascript_snippet = TRANSLATOR.translate(_pie.options) return render_template( 'home.html', host=REMOTE_HOST, script_list=_pie.get_js_dependencies(), # 渲染图表 pie_chart=_pie.render_embed(), bar_chart=_bar.render_embed())
def attack_status(attacks, is_reload=0): attack_type = list(attacks.keys()) attack_count = list(attacks.values()) status = Pie(' 攻击事件总览\n -----------------', width="100%", height="100%", title_pos="left", title_top=40, title_color="#6cb7c9") # attack_type = ['SQL注入', 'XSS跨站', '暴力破解', 'DoS', '木马后门'] # attack_num = [90, 30, 102, ```3`0, `20] status.add("", attack_type, attack_count, radius=[30, 38], label_text_color=None, legend_orient='vertical', center=[50, 60], is_legend_show=False, is_toolbox_show=False, is_label_show=False) if is_reload: option = status.get_options() option = TRANSLATOR.translate(option) option = option.as_snippet() return option else: return status
def generate_js_content(*charts): """ Generate the initial code fragment for one or some chart instances. """ contents = [] for chart in charts: FUNCTION_TRANSLATOR.reset() for handler in chart.event_handlers.values(): FUNCTION_TRANSLATOR.feed(handler) javascript_snippet = TRANSLATOR.translate(chart.options) kwargs = dict( chart_id=chart.chart_id, renderer=chart.renderer, theme=chart.theme, custom_function=javascript_snippet.function_snippet, options=javascript_snippet.option_snippet, ) js_content = CHART_CONFIG_FORMATTER.format(**kwargs) for event_name, handler in chart.event_handlers.items(): # please note handler has been translated in previous block event_args = dict( event_name=event_name, chart_id=chart.chart_id, handler_name=handler.__name__, ) js_content += CHART_EVENT_FORMATTER.format(**event_args) contents.append(js_content) contents = "\n".join(contents) return contents
def create_bar(self, v): bar = Bar(TITLE_TEXT, TITLE_SUBTEXT) bar.add('商家1', ATTR, v, is_more_utils=True) bar.add('商家2', ATTR, v, is_more_utils=True) snippet = TRANSLATOR.translate(bar.options) options = snippet.as_snippet() return options
def stream_status(streams, is_reload=0): grid = Grid(width="100%", height="100%") # stream_time = ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', # '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', # '22:00', '23:00', '24:00'] # stream_in = [13, 6, 22, 5, 58, 3, 75, 98, 48, 83, 8, 38, 89, 99, 8, 21, 77, 86, 47, 76, 31, 92, 77, 47, 0] # stream_out = [5, 81, 99, 83, 55, 89, 58, 5, 38, 76, 46, 17, 68, 4, 12, 81, 2, 73, 54, 71, 50, 28, 90, 46, 0] stream_time = list(streams.keys()) val = list(streams.values()) stream_in = [v[0] for v in val] stream_out = [v[1] for v in val] stream = Line(' 进出口流量统计\n -------------------', width="100%", height="100%", title_color="#6cb7c9", title_pos="left", title_top=10) stream.add("入口流量", stream_time, stream_in, is_fill=True, line_opacity=1, line_color="#6cb7c9", label_color=["#6cb7c9", "#344356"], area_opacity=0.7, is_smooth=True, is_toolbox_show=False, is_yaxis_show=False) stream.add("出口流量", stream_time, stream_out, is_fill=True, area_color='#000', area_opacity=0.4, is_smooth=True, is_toolbox_show=False, is_yaxis_show=False, is_legend_show=True, legend_text_color="#6cb7c9", xaxis_line_color="#6cb7c9") grid.add(stream, grid_bottom=30, grid_left=30, grid_top=50, grid_right=30) if is_reload: option = grid.get_options() option = TRANSLATOR.translate(option) option = option.as_snippet() return option else: return grid
def requests_status(requests, is_reload=0): country = list(requests.keys())[:10] counts = list(requests.values())[:10] # country = ['美国', '中国', '英国', '俄罗斯', '法国', '印度', '韩国', '巴西', '澳大利亚'][::-1] # times = [120, 70, 60, 50, 43, 12, 2, 2, 1][::-1] request = Bar(' 请求IP来源\n --------------', width="100%", height="100%", title_color="#6cb7c9", title_pos="left", title_top=10) request.add('', country, counts, is_convert=True, is_toolbox_show=False, is_yaxis_show=False, is_label_show=True, label_pos="right", xaxis_line_color="#6cb7c9", label_color="#fff", is_legend_show=True) if is_reload: option = request.get_options() option = TRANSLATOR.translate(option) option = option.as_snippet() return option return request
def create_chart(chart_type, height): datas = json.loads(str(request.data, 'utf-8')) title = datas.get('title') datas = datas.get('datas') if chart_type == 'bar': chart = build_chart_bar(title, datas) elif chart_type == 'pie': chart = build_chart_pie(title, datas) elif chart_type == 'guage': chart = build_chart_gauge(title, datas) else: chart = None abort(404) javascript_snippet = TRANSLATOR.translate(chart.options) html = render_template( 'pyecharts2.html', chart_id=chart.chart_id, my_title=u"明州体检", host='/static', renderer=chart.renderer, my_width="100%", my_height=height, custom_function=javascript_snippet.function_snippet, options=javascript_snippet.option_snippet, script_list=chart.get_js_dependencies()) tmp_path = app.config['UPLOAD_FOLDER_TMP'] tmp_filename = os.path.join( tmp_path, "%s_%s_%s.html" % (title, chart_type, cur_timep())) with open(tmp_filename, "w", encoding="UTF-8") as f: f.write(html) return jsonify({ 'code': 1, 'mes': '创建图表成功', 'data': os.path.basename(tmp_filename) })
def hello(): print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) # s3d = scatter3d() # return render_template( # "bbspyecharts.html", # myechart=s3d.render_embed(), # host=REMOTE_HOST, # script_list=s3d.get_js_dependencies(), # ) _bar = data_mix() # bar_chart() javascript_snippet = TRANSLATOR.translate(_bar.options) return render_template( "bbsResize.html", chart_id=_bar.chart_id, host=REMOTE_HOST, renderer=_bar.renderer, my_width="100%", my_height=600, custom_function=javascript_snippet.function_snippet, options=javascript_snippet.option_snippet, script_list=_bar.get_js_dependencies(), )
def NoneSelect(self): bar = Bar("", "") # v1 = {} X = [ "Active Vertex Detection", "Active Vertex collection", "Message Generation" ] Ave = [0, 0, 0] Max = [-1, -1, -1] Min = [1000000, 100000, 1000000] for i in range(4): Ave[0] += active_time_info[i] / 4.0 Ave[1] += get_data_time_info[i] / 4.0 Ave[2] += dcal_time_info[i] / 4.0 Max[0] = max(Max[0], active_time_info[i]) Max[1] = max(Max[1], get_data_time_info[i]) Max[2] = max(Max[2], dcal_time_info[i]) Min[0] = min(Min[0], active_time_info[i]) Min[1] = min(Min[1], get_data_time_info[i]) Min[2] = min(Min[2], dcal_time_info[i]) bar.add('Minimum', X, Min, is_more_utils=True) bar.add('Average', X, Ave, is_more_utils=True) bar.add('Maximum', X, Max, is_more_utils=True) snippet = TRANSLATOR.translate(bar.options) options = snippet.as_snippet() return options
def OnlyPartition(self): item = self.ui.SelectPartition.selectedItems() if item == []: row = 0 else: row = int(item[0].text(0)[-1]) line = Line("", "") # main Title and sub title X = [] for i in range(1, len(active_time_list[0]) + 1): X.append(i) line.add("Active Vertex Detection", X, active_time_list[row], is_smooth=True, mark_line=["max"], line_width=2) line.add("Active Vertex Collection", X, get_data_time_list[row], is_smooth=True, mark_line=["max"], line_width=2) line.add("Message Generation", X, dcal_time_list[row], is_smooth=True, mark_line=["max"], xaxis_name="Iteration",\ yaxis_name="Time(s)",label_text_size=labelsize,label_color=None,legend_text_size=labelsize,xaxis_name_size=xysize,yaxis_name_size=xysize,line_width=2) snippet = TRANSLATOR.translate(line.options) options = snippet.as_snippet() self.writelog("Showing all iterations by partition ... ") return options
def generate_js_content(*charts): """ Generate the initial code fragment for one or some chart instances. """ contents = [] for chart in charts: FUNCTION_TRANSLATOR.reset() for handler in chart.event_handlers.values(): FUNCTION_TRANSLATOR.feed(handler) javascript_snippet = TRANSLATOR.translate(chart.options) kwargs = dict( chart_id=chart.chart_id, renderer=chart.renderer, theme=chart.theme, custom_function=javascript_snippet.function_snippet, options=javascript_snippet.option_snippet, ) js_content = CHART_CONFIG_FORMATTER.format(**kwargs) for event_name, handler in chart.event_handlers.items(): # please note handler has been translated in previous block event_args = dict( event_name=event_name, chart_id=chart.chart_id, handler_name=handler.__name__, ) js_content += CHART_EVENT_FORMATTER.format(**event_args) contents.append(js_content) contents = "\n".join(contents) return contents
def Create_Overall_Iteration_Time(self): line = Line( "", "", ) # main Title and sub title X = [] for i in range(1, len(sync_point_time) + 1): X.append(i) line.add("GraphX synchronization", X, sync_point_time, is_smooth=True, mark_line=["max"], line_width=2) line.add("GraphX maintenance", X, sync_edge_time, is_smooth=True, mark_line=["max"], line_width=2) line.add("Computation", X, cal_time, is_smooth=True, mark_line=["max"], line_width=2) line.add("Result aggregation", X, tot_time, is_smooth=True, mark_line=["max"], xaxis_name="Iteration", yaxis_name="Time(s)",\ label_text_size=labelsize,label_color=None,legend_text_size=labelsize,xaxis_name_size=xysize,yaxis_name_size=xysize,line_width=2) snippet = TRANSLATOR.translate(line.options) options = snippet.as_snippet() print(options) return options
def chart_view02(): # 从mongo中获取数据 (x, y) = BidNotice.get_records_group_by_source_ch() bar = Bar("发布单位分析图") bar.add("发布单位", x, y, is_label_show=True, is_datazoom_show=True, datazoom_type='both', datazoom_range=[0, 20]) javascript_snippet = TRANSLATOR.translate(bar.options) # 将bar的属性设置翻译为js脚本 return render_template( template_name_or_list="pyecharts.html", chart_id=bar.chart_id, host=REMOTE_HOST, renderer=bar.render, my_width="100%", # 默认设置,定义图表的宽度 my_height=600, # 默认设置,定义图表的高度 custom_function=javascript_snippet. function_snippet, # 默认设置,保存图片的方法,似乎基于node.js options=javascript_snippet.option_snippet, # 默认设置, script_list=bar.get_js_dependencies(), # 默认设置,需要动态加载的js文件 )
def create_radar(self, v): #绘制雷达图 radar = Radar(self.TITLE_TEXT, self.TITLE_SUBTEXT) schema = [ ("口头语言", 5), ("原创性", 5), ("问题敏感度", 5), ("逻辑思维", 5), ("数学能力", 5), ("人际沟通", 5) ] radar.config(schema) v1 = [v] v2 = [[2,3,5,4,2,1]] radar.add( "第一次推荐输入", v1, is_splitline = True, is_axisline_show = True, is_label_show=True, area_opacity = 0.2 ) radar.add( "第二次推荐输入", v2, label_color=["#4e79a7"], is_area_show= False, legend_selectedmode='single', area_opacity = 0.5 ) snippet = TRANSLATOR.translate(radar.options) options = snippet.as_snippet() return options
def chart_view04(): # 从mongo中获取数据 (x, y) = BidNotice.get_records_group_by_timestamp(days_before=-30) # 设置bar图形的基本属性 bar = Bar("招标公告爬取时间图", "From: cmccb2b") bar.use_theme('light') bar.add( "爬取日期", x, y, # 从Mongo读取的数据存放在这里 is_stack=False, is_datazoom_show=True, # 设置bar图形的datazoom的拖拽效果 datazoom_type="both", datazoom_range=[80, 100]) javascript_snippet = TRANSLATOR.translate(bar.options) # 将bar的属性设置翻译为js脚本 # bar.print_echarts_options() # 该行只为了打印配置项,方便调试时使用 return render_template( "pyecharts.html", # 自定义,位于templates/的模版文件 chart_id=bar.chart_id, # 默认设置, host=REMOTE_HOST, # 常量定义,存放js文件的url地址 renderer=bar.renderer, # 默认设置, my_width="100%", # 默认设置,定义图表的宽度 my_height=600, # 默认设置,定义图表的高度 custom_function=javascript_snippet. function_snippet, # 默认设置,保存图片的方法,似乎基于node.js options=javascript_snippet.option_snippet, # 默认设置, script_list=bar.get_js_dependencies(), # 默认设置,需要动态加载的js文件 )
def create_line(self, x_list, y_list): y_list1, y_list2, y_list3 = y_list line = Line('算力曲线', '') line.add("平均算力", x_list, y_list1, is_smooth=True, mark_line=["max", "average"]) line.add("理论算力", x_list, y_list2, is_smooth=True, mark_line=["max", "average"]) line.add("短期算力", x_list, y_list3, is_smooth=True, mark_line=["max", "average"]) snippet = TRANSLATOR.translate(line.options) options = snippet.as_snippet() self.view.page().runJavaScript(f''' myChart2.clear(); var option = eval({options}); myChart2.setOption(option); ''')
def create_line_bar(self, v): line = Line(TITLE_TEXT, TITLE_SUBTEXT) line.add("商家", ATTR, v, is_smooth=True, mark_line=["max", "average"]) bar = Bar(TITLE_TEXT, TITLE_SUBTEXT) bar.add('商家', ATTR, v, is_more_utils=True) bar.overlap(line) snippet = TRANSLATOR.translate(bar.options) options = snippet.as_snippet() return options
def create_bar(self, v): bar = Bar(self.TITLE_TEXT, self.TITLE_SUBTEXT) bar.add('Science', self.ATTR, v, is_more_utils=True) bar.add('Engineering', self.ATTR, v, is_more_utils=True) bar.add('Technology', self.ATTR, v, is_more_utils=True) bar.add('Mathematics', self.ATTR, v, is_more_utils=True) snippet = TRANSLATOR.translate(bar.options) options = snippet.as_snippet() return options
def render(): _overlap = render_picture() return render_template('chart.html', chart_id=_overlap.chart_id, host=REMOTE_HOST, my_width="100%", my_height=800, my_option=TRANSLATOR.translate( _overlap.options).as_snippet(), script_list=_overlap.get_js_dependencies())
def test_basic_usage(): def my_fmt(x): return x + 5 def my_fmt2(x, z, y): return '{x},{y},{z}'.format(x=x, y=y, z=z) source = {'a': '23', 'b': my_fmt, 'c': my_fmt2, 'd': '-=>test<=-'} snippet = TRANSLATOR.translate(source) assert 'function my_fmt' in snippet.function_snippet assert 'function my_fmt2' in snippet.function_snippet assert 'function test' not in snippet.function_snippet assert '"my_fmt"' not in snippet.option_snippet assert '"my_fmt2"' not in snippet.option_snippet assert '"-=>test<=-"' in snippet.option_snippet source2 = {'e': my_fmt} snippet = TRANSLATOR.translate(source2) assert 'function my_fmt' in snippet.function_snippet assert '"my_fmt"' not in snippet.option_snippet
def post(self, request, **kwargs): echarts = self.get_echarts_instance(**kwargs) datas = {} # logger.debug('echarts keys:', echarts.keys()) for name, chart in echarts.items(): datas[name] = TRANSLATOR.translate(chart.options).as_snippet() # logger.debug(name, chart.options['legend']) # logger.debug('*'*100) return JsonResponse(data=datas, safe=False)
def test_date(): a_date = datetime.date(2018, 4, 20) option = {'date': a_date} expected = """ { "date": "2018-04-20" } """ actual = TRANSLATOR.translate(option) eq_(actual.option_snippet, dedent(expected).strip())
def create_line_bar(self, v): line = Line(self.TITLE_TEXT, self.TITLE_SUBTEXT) line.add("属性", self.ATTR, v, is_smooth=True, mark_line=["max", "average"]) bar = Bar(self.TITLE_TEXT, self.TITLE_SUBTEXT) bar.add('属性', self.ATTR, v, is_more_utils=True) overlap = Overlap() overlap.add(line) overlap.add(bar) snippet = TRANSLATOR.translate(overlap.options) options = snippet.as_snippet() return options
def edit_chart(id): if request.method == 'GET': chart = ChartInfo.query.get(id) data = query_engine.query_all(chart.select_sql) chart_view = ChartView.create_instance("pyecharts", chart.chart_type, title=chart.title) for item in chart.yaxis.split(','): chart_view.add(item, data[chart.xaxis].tolist(), data[item].tolist(), xaxis_name=chart.x_axis_name, yaxis_name=chart.y_axis_name, is_datazoom_show=chart.is_data_zoom, is_visualmap=chart.is_visual_map, xaxis_name_pos='end', yaxis_name_pos='end', yaxis_name_gap=40, is_convert=chart.is_convert, maptype='china', geo_normal_color="#E5E7E9", geo_emphasis_color="#CACFD2") javascript_snippet = TRANSLATOR.translate(chart_view.options) return baseapi.success( data="true", xy_axis=data.columns.values.tolist(), custom_function=javascript_snippet.function_snippet, options=javascript_snippet.option_snippet, chart_info=chart.serialize()) elif request.method == 'POST': title = request.form.get('chartTitle') chart_type = request.form.get('chartType') x_axis_name = request.form.get('xaxisName') y_axis_name = request.form.get('yaxisName') xaxis = request.form.get('xaxis') yaxis = request.form.getlist('yaxis') data_zoom = request.form.get('isDataZoom') == 'on' visual_map = request.form.get('isVisualMap') == 'on' is_convert = request.form.get('isConvert') == 'on' is_public = request.form.get('isPublic') == 'on' chart = ChartInfo.query.get(id).update(title=title, chart_type=chart_type, x_axis_name=x_axis_name, y_axis_name=y_axis_name, xaxis=xaxis, yaxis=yaxis, data_zoom=data_zoom, visual_map=visual_map, is_convert=is_convert, is_public=is_public) db.session.commit() return baseapi.success("true")
def create_bar(self, x_list, y_list): # bar = Bar() # bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) # bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) bar = Bar('ETH每日收益', '') bar.add('ETH', x_list, y_list, is_more_utils=True) snippet = TRANSLATOR.translate(bar.options) options = snippet.as_snippet() self.view.page().runJavaScript(f''' myChart1.clear(); var option = eval({options}); myChart1.setOption(option); ''')
def createKlines(self): overlap = Overlap() for quote in self.quote_data: line = Line(quote['title']) line.add('open', quote['date'], quote['open'], is_smooth=True) line.add('close', quote['date'], quote['close'], is_smooth=True) line.add('high', quote['date'], quote['high'], is_smooth=True) line.add('low', quote['date'], quote['low'], is_smooth=True) overlap.add(line) snippet = TRANSLATOR.translate(overlap.options) options = snippet.as_snippet() return options
def hello(): _bar = bar_chart() javascript_snippet = TRANSLATOR.translate(_bar.options) return render_template( "pyecharts.html", chart_id=_bar.chart_id, host=REMOTE_HOST, renderer=_bar.renderer, my_width=250, my_height=600, custom_function=javascript_snippet.function_snippet, options=javascript_snippet.option_snippet, script_list=_bar.get_js_dependencies(), )
def hello(chartname): sc_map = scatter_map(chartname) javascript_snippet = TRANSLATOR.translate(sc_map.options) return render_template( 'charts.html', host=LOCAL_HOST, chart_id=sc_map.chart_id, renderer=sc_map.renderer, my_width="100%", my_height="450", custom_function=javascript_snippet.function_snippet, options=javascript_snippet.option_snippet, script_list=sc_map.get_js_dependencies(), chart_name=chartname, )
def create_pie(self, v=None): from pyecharts import options as opts from pyecharts.charts import Bar print('create_pie') bar = Bar("test", 'TITLE_SUBTEXT') bar.add('商家1', ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], ['12', '50', '20', '25', '10'], is_more_utils=True) bar.add('商家2', ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], ['12', '50', '20', '25', '10'], is_more_utils=True) snippet = TRANSLATOR.translate(bar.options) options = snippet.as_snippet() return options
def create_sankey(self, v): #绘制桑基图 sankey = Sankey(self.TITLE_TEXT, self.TITLE_SUBTEXT,width=1200, height=600) category1,category2,category3,category4,category5,category6=self.ATTR[0],self.ATTR[1],self.ATTR[2],self.ATTR[3],self.ATTR[4],self.ATTR[5] nodes = [ {'name': 'Java软件开发'}, {'name': '前端技术'}, {'name': '移动端技术'}, {'name': '自然语言处理'}, {'name': 'Python数据分析'}, {'name': '数据可视化'}, {'name': '量化交易'},{'name': '算法工程'},{'name': '算法优化'}, {'name': '机器学习开发'},{'name': '运维工程'},{'name': '云计算开发'}, {'name': '软件UI设计'},{'name': '计算机视觉'},{'name': '产品经理'},{'name': '深度学习'} ] links = [ {'source': 'Java软件开发', 'target': '前端技术', 'value': 5}, {'source': '前端技术', 'target': '移动端技术', 'value': 12}, {'source': 'Python数据分析', 'target': '自然语言处理', 'value': 10}, {'source': 'Python数据分析', 'target': '数据可视化', 'value': 8}, {'source': '自然语言处理', 'target': '算法工程', 'value': 15}, {'source': '算法工程', 'target': '算法优化', 'value': 15}, {'source': '自然语言处理', 'target': '算法优化', 'value': 30}, {'source': '量化交易', 'target': '算法优化', 'value': 10}, {'source': '自然语言处理', 'target': '移动端技术', 'value': 14}, {'source': '机器学习开发', 'target': '自然语言处理', 'value': 14}, {'source': '机器学习开发', 'target': '算法工程', 'value': 20}, {'source': '软件UI设计', 'target': '移动端技术', 'value': 15}, {'source': '深度学习', 'target': '计算机视觉', 'value': 12}, {'source': '计算机视觉', 'target': '算法优化', 'value': 10}, {'source': '运维工程', 'target': '云计算开发', 'value': 15}, {'source': '前端技术', 'target': '云计算开发', 'value': 20}, {'source': '云计算开发', 'target': '产品经理', 'value': 3}, {'source': '移动端技术', 'target': '产品经理', 'value': 10}, {'source': '算法优化', 'target': '产品经理', 'value': 7}, {'source': '计算机视觉', 'target': '产品经理', 'value': 6}, {'source': '数据可视化', 'target': '产品经理', 'value': 5}, ] sankey.add( "技能树", nodes, links, line_opacity=0.2, line_curve=0.5, line_color="source", is_label_show=True, label_pos="right", ) snippet = TRANSLATOR.translate(sankey.options) options = snippet.as_snippet() return options
def reload_data(addrs, local, dataset, ip_from): local_coord = local[0] local_city = local[1] road = [] # 实例化世界地图 world = GeoLines('', **style.init_style) try: # 添加本机坐标 world.add_coordinate(local_city, local_coord[0], local_coord[1]) except: # 重复添加可能会出错? pass if addrs: for ips in addrs: ips = loads(ips) ip = list(ips.keys())[0] is_evil = list(ips.values())[0] try: info = dataset.city(ip) ip_city = info.city.name ip_country = info.country.name # 经纬度 ip_coord = [info.location.longitude, info.location.latitude] if ip_city and ip_country: world.add_coordinate(ip_city, ip_coord[0], ip_coord[1]) path = [ip_city, local_city] road.append(path) if ip_country not in ip_from: ip_from[ip_country] = 1 else: ip_from[ip_country] += 1 except: pass else: road = [['Los Angeles', local_city]] world.add('', road, **style_geo) option = world.get_options() # options中存在 Tooltip 对象,无法直接使用 json.dumps 转换,需要理由 pyecharts 的 TRANSLATOR API函数 option = TRANSLATOR.translate(option) option = option.as_snippet() return option, ip_from
def print_echarts_options(self): """ 打印输出图形所有配置项 """ snippet = TRANSLATOR.translate(self.options) print(snippet.as_snippet())