这里是js配置对象
option = {
legend: {},
tooltip: {},
dataset: {
source: [
['product', '2015', '2016', '2017'],
['Matcha Latte', 43.3, 85.8, 93.7],
['Milk Tea', 83.1, 73.4, 55.1],
['Cheese Cocoa', 86.4, 65.2, 82.5],
['Walnut Brownie', 72.4, 53.9, 39.1]
]
},
xAxis: { type: 'category', name: '121' },
yAxis: {},
series: [
// These series are in the first grid.
{ type: 'line', seriesLayoutBy: 'row' },
{ type: 'line', seriesLayoutBy: 'row' },
{ type: 'line', seriesLayoutBy: 'row' },
{ type: 'line', seriesLayoutBy: 'row' }
]
};
渲染结果如下:
下面是python配置
from pyecharts import options as opts
from pyecharts.charts import Bar
bartest = Line().add_dataset(
source=[
["product", "2015", "2016", "2017"],
["Matcha Latte", 43.3, 85.8, 93.7],
["Milk Tea", 83.1, 73.4, 55.1],
["Cheese Cocoa", 86.4, 65.2, 82.5],
["Walnut Brownie", 72.4, 53.9, 39.1],
]
) \
.add_yaxis(series_name="2015", y_axis=[]) \
.add_yaxis(series_name="2016", y_axis=[]) \
.add_yaxis(series_name="2017", y_axis=[]) \
.set_global_opts(
xaxis_opts=opts.AxisOpts(type_="category"),
)
bartest.render_notebook()
# pprint.pprint(bartest.dump_options_with_quotes())
# bartest.dump_options_with_quotes()
渲染结果如下,是空的,dump出配置对象后到js的echarts中排查发现是设置y_axis为空数组导致,但是如果是Bar图表就不会有这个问题:
现在我想实现的是
- Pyecharts的Line图表支持source
- 设置Line图表中series.seriesLayoutBy这个属性为row
pyecharts这边好像没有看到line图表demo是怎么设置的。上面python的配置通过 bartest.dump_options_with_quotes()
导出之后并没有看到 series
对象中存在 seriesLayoutBy
。但是Bar图表中是可以设置的只是Line图表中没有看到