0.2.0 • Published 24 days ago

@antv/g2-extension-3d v0.2.0

Weekly downloads
-
License
-
Repository
github
Last release
24 days ago

g2-extension-3d

The threed lib for G2.

Getting Started

Create a renderer and register relative plugins which provides 3D rendering capabilities:

import { Renderer as WebGLRenderer } from "@antv/g-webgl";
import { Plugin as ThreeDPlugin } from "@antv/g-plugin-3d";
import { Plugin as ControlPlugin } from "@antv/g-plugin-control";

const renderer = new WebGLRenderer();
renderer.registerPlugin(new ThreeDPlugin());
renderer.registerPlugin(new ControlPlugin());

Then extend the runtime of G2 with 3D lib:

import { threedlib } from "@antv/g2-extension-3d";
import { Runtime, corelib, extend } from "@antv/g2";

const Chart = extend(Runtime, { ...corelib(), ...threedlib() });
const chart = new Chart({
  container: "container",
  renderer,
  depth: 400,
});

Now we can use 3D marks like this:

chart.point3D().data({});

⚠️ For now we only support Chart API and leave the Spec usage in the future.

Scatter

DEMO

Line

DEMO

Bar

DEMO

Surface

DEMO

Use surface3D mark:

chart
  .surface3D()
  .data(points)
  .encode("x", "x")
  .encode("y", "y")
  .encode("z", "z")
  .encode("color", "z")
  .coordinate({ type: "cartesian3D" })
  .scale("x", { nice: true })
  .scale("y", { nice: true })
  .scale("z", { nice: true })
  .scale("color", { palette: "spectral" })
  .legend(false)
  .axis("x", { gridLineWidth: 1 })
  .axis("y", { gridLineWidth: 1, titleBillboardRotation: -Math.PI / 2 })
  .axis("z", { gridLineWidth: 1 })
  .style({
    palette: "spectral",
  });

Run Test Cases

To run playwright, you must download new browsers first:

$npx playwright install
0.2.0

24 days ago

1.0.0

1 month ago

0.1.6

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.1-beta.2

6 months ago

0.1.1-beta.1

6 months ago

0.1.0

6 months ago