function g2() {
const chart = new G2.Chart({
renderer
});
chart
.point()
.data(data)
.encode("x", "Horsepower")
.encode("y", "Miles_per_Gallon")
.encode("z", "Weight_in_lbs")
.encode("size", "Origin")
.encode("color", "Cylinders")
.encode("shape", "point")
.coordinate({ type: "cartesian3D" })
.scale("x", { nice: true })
.scale("y", { nice: true })
.scale("z", { nice: true })
.legend(false)
.axis("x", { gridLineWidth: 2 })
.axis("y", { gridLineWidth: 2, titleBillboardRotation: -Math.PI / 2 })
.axis("z", { gridLineWidth: 2 })
.style("fillOpacity", 0.8);
chart.render().then(() => {
const { canvas } = chart.getContext();
const camera = canvas.getCamera();
camera.setPerspective(0.1, 5000, 45, 500 / 500);
camera.setType(G.CameraType.ORBITING);
});
invalidation.then(() => chart.destroy());
return chart.getContainer();
}