node2:/root/fenxi#cat k15.py
import datetime
import random
from pyecharts import options as opts
from pyecharts.charts import Calendar
from pyecharts.charts import Funnel, Page
from pyecharts.faker import Faker
import pyecharts.options as opts
from pyecharts.faker import Faker
from pyecharts.charts import Line
import pyecharts.options as opts
from pyecharts.faker import Faker
from pyecharts.charts import Line
def line_base() -> Line:
c = (
Line()
.add_xaxis(Faker.choose())
.add_yaxis("商家A", Faker.values())
.add_yaxis("商家B", Faker.values())
.set_global_opts(title_opts=opts.TitleOpts(title="Line-基本示例"))
)
return c
print (Faker.choose())
print (type(Faker.choose()))
print (Faker.values())
print (type(Faker.values()))
line_base().render("k15.html")
node2:/root/fenxi#python3 k15.py
['可乐', '雪碧', '橙汁', '绿茶', '奶茶', '百威', '青岛']
<class 'list'>
[75, 33, 135, 68, 110, 104, 108]
<class 'list'>
node2:/root/fenxi#cat k14.py
import datetime
import random
from pyecharts import options as opts
from pyecharts.charts import Calendar
from pyecharts.charts import Funnel, Page
from pyecharts.faker import Faker
import pyecharts.options as opts
from pyecharts.faker import Faker
from pyecharts.charts import Line
def line_base() -> Line:
c = (
Line()
.add_xaxis(["20191208","20191209","20191210","20191211","20191212","20191213"])
.add_yaxis("商家A", [0.99,1.00,0.85,0.98,0.89,0.96], linestyle_opts=opts.LineStyleOpts(width=2) )
.add_yaxis("商家B", [1.00,0.67,0.87,0.27,1.00,0.34], linestyle_opts=opts.LineStyleOpts(width=2) )
.set_global_opts(
title_opts=opts.TitleOpts(title='line 对数轴示例'),
xaxis_opts=opts.AxisOpts(name='x'),# 设置x轴名字属性
yaxis_opts=opts.AxisOpts(
type_='log', # 设置类型
name='y', # 设置y轴名字属性
splitline_opts=opts.SplitLineOpts(is_show=True),# 这里将分割线显示
is_scale=True # 这里范围设置true是显示线的顶端,设置为False的话就只会显示前2个数值
)
)
)
return c
line_base().render("k14.html")