@vis-pilot/ssr
v0.1.0
Published
Server-side SVG rendering for vis-pilot.
Readme
@vis-pilot/ssr
Server-side rendering package for vis-pilot in Node.js.
Usage
import { render, renderVisPilotToSVG } from '@vis-pilot/ssr'
const vis = await render(
{
mode: 'text',
input: `
chart: line
title: Revenue (SSR)
x: month
y: value
data:
- month: Jan
value: 120
- month: Feb
value: 150
- month: Mar
value: 170
`
},
{ width: 960, height: 540 }
)
const svg = vis.toSVG()
const buffer = vis.toBuffer()
// You should destroy the SSR result when done.
vis.destroy()
// One-shot rendering shortcut.
const oneShotSVG = renderVisPilotToSVG(
{
mode: 'option',
input: {
title: { text: 'One-shot SVG' },
xAxis: { type: 'category', data: ['Jan', 'Feb', 'Mar'] },
yAxis: { type: 'value' },
series: [{ type: 'line', data: [120, 150, 170] }]
}
},
{ width: 640, height: 360 }
)