View Source Tucan.Export (tucan v0.4.1)

Various export methods for Tucan plots.

This is a simple wrapper around the VegaLite.Export API. It provides helper utilities for exporting a tucan plot as json, html, png, svg or pdf.

External dependencies

All of the export functions depend on the :jason package. Additionally PNG, SVG and PDF exports rely on npm packages, so you will need Node.js, npm, and the following dependencies installed:

npm install -g vega vega-lite canvas

For more details check VegaLite.Export.

Summary

Functions

Saves a Tucan specification in one of the supported formats.

Builds an HTML page that renders the given graphic.

Returns the underlying Vega-Lite specification as JSON.

Renders the given graphic into a PDF and returns its binary content.

Renders the given graphic as a PNG image and returns its binary content.

Renders the given graphic as an SVG image and returns its binary content.

Functions

Link to this function

save!(vl, path, opts \\ [])

View Source
@spec save!(vl :: VegaLite.t(), path :: String.t(), opts :: keyword()) :: :ok

Saves a Tucan specification in one of the supported formats.

Options

  • :format - the format to export the graphic as, must be either of: :json, :html, :png, :svg, :pdf. By default the format is inferred from the file extension.

  • :local_npm_prefix - a relative path pointing to a local npm project directory where the necessary npm packages are installed.

Examples

Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Export.save!("iris.png")

See also VegaLite.Export.save!/3

@spec to_html(vl :: VegaLite.t()) :: String.t()

Builds an HTML page that renders the given graphic.

See also VegaLite.Export.to_html/1

@spec to_json(vl :: VegaLite.t()) :: String.t()

Returns the underlying Vega-Lite specification as JSON.

See also VegaLite.Export.to_json/1

@spec to_pdf(vl :: VegaLite.t(), opts :: keyword()) :: binary()

Renders the given graphic into a PDF and returns its binary content.

Relies on the npm packages mentioned above.

Options

  • :local_npm_prefix - a relative path pointing to a local npm project directory where the necessary npm packages are installed.

See also VegaLite.Export.to_pdf/2

@spec to_png(vl :: VegaLite.t(), opts :: keyword()) :: binary()

Renders the given graphic as a PNG image and returns its binary content.

Relies on the npm packages mentioned above.

Options

  • :local_npm_prefix - a relative path pointing to a local npm project directory where the necessary npm packages are installed.

See also VegaLite.Export.to_png/2

@spec to_svg(vl :: VegaLite.t(), opts :: keyword()) :: binary()

Renders the given graphic as an SVG image and returns its binary content.

Relies on the npm packages mentioned above.

Options

  • :local_npm_prefix - a relative path pointing to a local npm project directory where the necessary npm packages are installed.

See also VegaLite.Export.to_svg/2