vega / react-vega

Convert Vega spec into React class conveniently
http://vega.github.io/react-vega/
Other
373 stars 67 forks source link

[Question] Does it support server side rendering? #604

Open ZeRego opened 2 months ago

ZeRego commented 2 months ago

I want to render in the server a react page that includes a Vega chart. Is this possible?

At the moment the example code only returns an empty div.

<div style="width:100%;height:100%;min-height:300px"/>

Server

const html = renderToStaticMarkup(<VegaViz spec={vegaSpec}/>);

Component

const VegaViz = ({spec}: { spec: vega.Spec }) => {
    return (
        <Vega
            style={{
                width: '100%',
                height: '100%',
                minHeight: 300,
            }}
            spec={spec}
            renderer={'svg'}
        />
    );
};