Published
Edited
Mar 16, 2020
2 forks
6 stars
Normalized Stacked Bar Chart by g2/antv, transpose it
Dimension 2 and Measure 1Simple Chart create by G2
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const dimension = group == 'region'? 'color': 'region'
const w = Math.min(width, 640);
const container = html`<div></div>`;
const chart = new G2.Chart({
container,
width: w,
animate: false
});
chart.source(data);
chart.coord().transpose();
chart.intervalStack()
.position(`${group}*percent`)
.label('percent', percent => percent.toFixed(2) + '%', {
position: 'middle',
offset: 0,
textStyle:{fill: 'white'}
})
.color(dimension)
.tooltip(false)
chart.render();
return container;
}
Insert cell
Insert cell
Insert cell
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