/** * [[include:src/codecs/plotly/README.md]] * * @module codecs/plotly */ import schema from '@stencila/schema'; import * as vfile from '../../util/vfile'; import { Codec } from '../types'; export declare const plotlyMediaType = "application/vnd.plotly.v1+json"; export declare class PlotlyCodec extends Codec implements Codec { readonly mediaTypes: string[]; /** * Decode Plotly JSON to an `ImageObject`. * * Most often used to convert the output of a Jupyter cell to an * image for compatibility to non-browser, non-Plotly supporting * formats such as Word or Markdown. * * Uses Puppeteer and Plotly to generate a static PNG for `contentUrl`. * An alternative would be to use `jsdom` in Node.js but it is reported * that a lot of Plotly's functionality does not work this way (e.g. missing text). * See https://gist.github.com/etpinard/58a9e054b9ca7c0ca4c39976fc8bbf8a. * * In addition to the static image, stores the Plotly JSON in `content` ( * with `mediaType` and `data` properties, so that the node can be reversed * back to Jupyter if needed, or rendered as an interactive figure in HTML. * * It is possible to set the `height` and `width` of the generated image * in options to `Plotly.toImage`. However, it seems best to avoid that * and instead let the values be taken from the `layout` object in the * Plotly JSON (this seems to be the default behavior). */ readonly decode: (file: vfile.VFile) => Promise; /** * Encode a Stencila `ImageObject` with to Plotly JSON * * Most often used when encoding a Jupyter Notebook from some other format, when * the source document was itself created from a Jupyter Notebook (ie. reverse * converting back to a Jupyter Notebook from Word) */ readonly encode: (node: schema.Node) => Promise; }