Published
Edited
Apr 28, 2022
1 fork
Insert cell
G2 = require("@antv/g2@4.0.2");
Insert cell
G2Plot = require("@antv/g2plot@1.0.1");
Insert cell
doc = html`<div style="width:330px; height:280px;"><div id="container"></div></div>`
Insert cell
G2PlotDemo = {
// for Observable Cell
const wrapper = html`<div style="text-align: left;"></div>`;
const container = html`<div style="height: 600px; width: 600px"></div>`
wrapper.appendChild(container);
yield wrapper;
// Demo Code
const data = [
{ type: '重庆', value: 101 },
{ type: '北京', value: 79 },
{ type: '上海', value: 62 },
{ type: '苏州', value: 41 },
{ type: '杭州', value: 36 },
{ type: '桂林', value: 31 },
{ type: '西安', value: 30 },
{ type: '洛阳', value: 28},
{ type: '无锡', value: 30 },
{ type: '上饶', value: 26 },
];

const rosePlot = new G2Plot.Rose(container, {
forceFit: true,
radius: 0.8,
innerRadius: 0.2,
data,
radiusField: 'value',
categoryField: 'type',
colorField: 'type',
label: { visible: true, type: 'outer', content: (text) => text.value},
padding: [0, 0, 0, 0],
legend: {
position: 'left',
}
});

rosePlot.render();
}
Insert cell


G2PlotDemo1 = {
// for Observable Cell
const wrapper = html`<div style="text-align: center;"></div>`;
const container = html`<div style="height: 600px; width: 600px"></div>`
wrapper.appendChild(container);
yield wrapper;
const liquidPlot = new G2Plot.Liquid(container, {
min: 0,
max: 100,
value: 88,
statistic: {
style:{
text: "88%\n比例啊啊",
fontSize: 80,
fontWeight: 300,
textAlign: 'center',
textBaseline: 'middle',
shadowColor: 'white',
shadowBlur: 10,
}
},
});

liquidPlot.render();

}
Insert cell


G2PlotDemo2= {
// for Observable Cell
const wrapper = html`<div style="text-align: center;"></div>`;
const container = html`<div style="height: 250px; width: 250px"></div>`
wrapper.appendChild(container);
yield wrapper;
const liquidPlot = new G2Plot.Liquid(container, {
min: 0,
max: 100,
value: 36.8,
statistic: {
style:{
text: "36.8%\n2010年",
fontSize: 30,
fontWeight: 30,
textAlign: 'center',
textBaseline: 'middle',
shadowColor: 'white',
shadowBlur: 10,
}
},
});

liquidPlot.render();
}


Insert cell


G2PlotDemo3= {
// for Observable Cell
const wrapper = html`<div style="text-align: center;"></div>`;
const container = html`<div style="height: 250px; width: 250px"></div>`
wrapper.appendChild(container);
yield wrapper;
const liquidPlot = new G2Plot.Liquid(container, {
min: 0,
max: 100,
value: 78.8,
statistic: {
style:{
text: "78.8%\n2018年",
fontSize: 30,
fontWeight: 30,
textAlign: 'center',
textBaseline: 'middle',
shadowColor: 'white',
shadowBlur: 10,
}
},
});

liquidPlot.render();
}


Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more