0.1.0
Hello World
Install via a package manager such as Yarn or NPM.
$ npm install @berryv/g2-ssr-nodeUse CLI to convert a G2 specification file named in bar.json into a png file named bar.png.
$ g2-ssr-node g2png -i ./bar.json -o bar.pngIn Node, use render to convert a G2 specification into a png file named bar.png.
const fs = require("fs");
const { render } = require("@berry/g2-ssr-node");
const spec = {
type: "interval",
data: [
{ genre: "Sports", sold: 275 },
{ genre: "Strategy", sold: 115 },
{ genre: "Action", sold: 120 },
{ genre: "Shooter", sold: 350 },
{ genre: "Other", sold: 150 },
],
encode: { x: "genre", y: "sold", color: "genre" },
};
render(spec).then((canvas) => {
const out = fs.createWriteStream("./bar.png");
const stream = canvas.createJPEGStream();
stream.pipe(out);
stream.on("finish", () => console.log("Convert successfully!"));
});