def bar_graphic_image_component() -> Bar: c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-Graphic Image 组件示例"), graphic_opts=[ opts.GraphicImage( graphic_item=opts.GraphicItem( id_="logo", right=20, top=20, z=-10, bounding="raw", origin=[75, 75], ), graphic_imagestyle_opts=opts.GraphicImageStyleOpts( image="http://echarts.baidu.com/images/favicon.png", width=150, height=150, opacity=0.4, ), ) ], ) ) return c
def test_bar_graphic(fake_writer): c = ( Bar() .add_xaxis(["A", "B", "C"]) .add_yaxis("series0", [1, 2, 4]) .set_global_opts( graphic_opts=[ opts.GraphicImage( graphic_item=opts.GraphicItem( id_="logo", right=20, top=20, z=-10, bounding="raw", origin=[75, 75], ), graphic_imagestyle_opts=opts.GraphicImageStyleOpts( image="http://echarts.baidu.com/images/favicon.png", width=150, height=150, opacity=0.4, ), ) ] ) ) c.render() file_name, content = fake_writer.call_args[0] assert_equal("render.html", file_name) assert_in("graphic", content)
def __init__(self,fields, title, subtitle='', y_name='', x_name=''): # 加入字段为了用来指定stack时的值 self.fields=fields self.y_name = y_name self.x_name = x_name self.title = title self.subtitle = subtitle self.init_opts = opts.InitOpts(theme=ThemeType.LIGHT) self.logo = [ opts.GraphicImage( graphic_item=opts.GraphicItem( id_='logo', right=20, top=20, z=-10, bounding="raw", origin=[75, 75] ), graphic_imagestyle_opts=opts.GraphicImageStyleOpts( image="logo.png", width=110, height=110, opacity=0.4 ) ) ]
def bar_graphic_image_with_js_component() -> Grid: bar = ( Bar(init_opts=opts.InitOpts(chart_id="1234")) .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-Graphic Image(旋转功能)组件示例"), graphic_opts=[ opts.GraphicImage( graphic_item=opts.GraphicItem( id_="logo", right=20, top=20, z=-10, bounding="raw", origin=[75, 75], ), graphic_imagestyle_opts=opts.GraphicImageStyleOpts( image="http://echarts.baidu.com/images/favicon.png", width=150, height=150, opacity=0.4, ), ) ], ) ) c = ( Grid(init_opts=opts.InitOpts(chart_id="1234")) .add( chart=bar, grid_opts=opts.GridOpts(pos_left="5%", pos_right="4%", pos_bottom="5%"), ) .add_js_funcs( """ var rotation = 0; setInterval(function () { chart_1234.setOption({ graphic: { id: 'logo', rotation: (rotation += Math.PI / 360) % (Math.PI * 2) } }); }, 30); """ ) ) return c
bar = (Bar(init_opts=opts.InitOpts(chart_id="1234")).add_xaxis(Faker.choose( )).add_yaxis("商家A", Faker.values()).add_yaxis( "商家B", Faker.values()).set_global_opts( title_opts=opts.TitleOpts(title="Bar-Graphic Image(旋转功能)组件示例"), graphic_opts=[ opts.GraphicImage( graphic_item=opts.GraphicItem(id_="logo", right=20, top=20, z=-10, bounding="raw", origin=[75, 75]), graphic_imagestyle_opts=opts.GraphicImageStyleOpts( image="https://www.echartsjs.com/zh/images/favicon.png", width=150, height=150, opacity=0.4, ), ) ], )) c = (Grid(init_opts=opts.InitOpts(chart_id="1234")).add( chart=bar, grid_opts=opts.GridOpts(pos_left="5%", pos_right="4%", pos_bottom="5%"), ).add_js_funcs(""" var rotation = 0; setInterval(function () { chart_1234.setOption({ graphic: { id: 'logo', rotation: (rotation += Math.PI / 360) % (Math.PI * 2)
bar = (Bar(init_opts=opts.InitOpts(chart_id="1234")).add_xaxis( Faker.choose()).add_yaxis("商家A", Faker.values()).add_yaxis( "商家B", Faker.values()).set_global_opts( title_opts=opts.TitleOpts(title="Bar-Graphic Image(旋转功能)组件示例"), graphic_opts=[ opts.GraphicImage( graphic_item=opts.GraphicItem(id_="logo", right=20, top=20, z=-10, bounding="raw", origin=[75, 75]), graphic_imagestyle_opts=opts.GraphicImageStyleOpts( image="http://echarts.baidu.com/images/favicon.png", width=150, height=150, opacity=0.4, ), ) ], )) c = (Grid(init_opts=opts.InitOpts(chart_id="1234")).add( chart=bar, grid_opts=opts.GridOpts(pos_left="5%", pos_right="4%", pos_bottom="5%"), ).add_js_funcs(""" var rotation = 0; setInterval(function () { chart_1234.setOption({ graphic: { id: 'logo', rotation: (rotation += Math.PI / 360) % (Math.PI * 2)
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = (Bar().add_xaxis(Faker.choose()).add_yaxis( "商家A", Faker.values()).add_yaxis("商家B", Faker.values()).set_global_opts( title_opts=opts.TitleOpts(title="Bar-Graphic Image 组件示例"), graphic_opts=[ opts.GraphicImage( graphic_item=opts.GraphicItem(id_="logo", right=20, top=20, z=-10, bounding="raw", origin=[75, 75]), graphic_imagestyle_opts=opts.GraphicImageStyleOpts( image="https://echarts.apache.org/zh/images/favicon.png", width=150, height=150, opacity=0.4, ), ) ], ).render("graphic_image.html"))