Function: decodeFigure()
ts
function decodeFigure(json): FigureInput;Decode a figure encoded by encodeFigure (or by Plotly): every { dtype, bdata, shape? } spec, anywhere in the figure, becomes a typed array again (a 2D shape gives an array of row typed arrays, as plotly.js does). ISO date strings stay strings, which Holochart accepts wherever it accepts dates. Accepts the JSON text or the parsed value; the input is never mutated.
Throws if the input is not an object, or a spec is malformed (bad base64, byte length or shape).
Parameters
| Parameter | Type |
|---|---|
json | unknown |
Returns
Example
ts
const figure = decodeFigure('{"data":[{"x":{"dtype":"f8","bdata":"AAAAAAAA8D8AAAAAAAAAQA=="}}]}');
// figure.data[0].x → Float64Array [1, 2]