Published
Edited
Mar 15, 2021
Insert cell
Insert cell
Insert cell
echarts = require('echarts');
Insert cell
{
// 创建 dom 容器
const container = html`<div style="width:${width + 'px'};height:${height + 'px'}"></div>`;
// 初始化
const chart = echarts.init(container);

// 配置信息
const option = {
xAxis: {
type: 'category',
data: data.map(datum => datum.browser),
axisLabel: {
// 强制显示所有 label
interval: 0,
}
},
tooltip: {},
yAxis: {
type: 'value'
},
series: [{
data: data.map(datum => datum.percent),
type: 'bar',
color: 'steelblue',
label: {
show: true,
position: 'top',
formatter: '{c}%',
}
}]
};

// 应用配置
chart.setOption(option);
return container;
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more