{
G2.register("shape.interval.petal", petal);
const chart = new G2.Chart({
paddingLeft: 60,
paddingRight: 60,
width: 1000,
height: 600
});
chart.coordinate({ type: "theta" });
chart.data([
{ type: "分类一", value: 27 },
{ type: "分类二", value: 25 },
{ type: "分类三", value: 18 },
{ type: "分类四", value: 15 },
{ type: "分类五", value: 10 },
{ type: "Other", value: 5 }
]);
chart
.interval()
.transform({ type: "stackY" })
.encode("y", "value")
.encode("color", "type")
.encode("shape", "petal")
.style("offset", 0.5)
.style("ratio", 0.2)
.label({
text: (d, i, data) => d.type + "\n" + d.value,
radius: 0.9,
fontSize: 9,
dy: 12
})
.animate("enter", { type: "fadeIn" })
.legend(false);
await chart.render();
return chart.getContainer();
}