Published
Edited
Mar 15, 2021
Insert cell
Insert cell
Insert cell
G2 = require('@antv/g2')
Insert cell
{
// 创建容器
const container = html`<div></div>`;
// 创建 Chart
const chart = new G2.Chart({
container,
width,
height,
padding: 50,
})
// 初始化数据
chart.data(data);
// 图形语法配置图表
chart
.interval()
.position("browser*percent")
.label('percent', (value => ({
content: `${value}%`,
})))
.color('steelblue');
// 渲染图表
chart.render();
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