Tucan.Export (tucan v0.5.0)
View SourceVarious export methods for Tucan
plots.
This is a simple wrapper around the VegaLite.Convert
API. It provides helper
utilities for exporting a tucan plot as json
, html
, png
, svg
, jpeg
or pdf
.
External dependencies
All of the export functions depend on the vega_lite_convert
package.
In order to use these functions you need to add the package in your
dependencies:
def deps do
[
{:vega_lite_convert, "~> 1.0.0"}
]
end
Summary
Functions
Saves a Tucan
specification in one of the supported formats.
Builds an HTML page that renders the given graphic.
Renders the given graphic as a JPEG image and returns its binary content.
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
@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
,:jpeg
. By default the format is inferred from the file extension.
Examples
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Export.save!("iris.png")
See also VegaLite.Convert.save!/3
@spec to_html(vl :: VegaLite.t(), opts :: keyword()) :: String.t()
Builds an HTML page that renders the given graphic.
Options
:bundle
- configures whether the VegaLite client side JS library is embedded in the document or if it is pulled down from the CDN. Defaults totrue
.:renderer
- determines how the VegaLite chart is rendered in the HTML document. Possible values are::svg
,:canvas
, or:hybrid
. Defaults to:svg
.
See also VegaLite.Convert.to_html/2
@spec to_jpeg(vl :: VegaLite.t(), opts :: keyword()) :: binary()
Renders the given graphic as a JPEG image and returns its binary content.
Options
:scale
- the image scale factor. Defaults to1.0
.:quality
- the quality of the generated JPEG between 0 (worst) and 100 (best). Defaults to90
.
See also VegaLite.Convert.to_png/2
@spec to_json(vl :: VegaLite.t()) :: String.t()
Returns the underlying Vega-Lite specification as JSON.
See also VegaLite.Convert.to_json/1
@spec to_pdf(vl :: VegaLite.t()) :: binary()
Renders the given graphic into a PDF and returns its binary content.
See also VegaLite.Convert.to_pdf/1
@spec to_png(vl :: VegaLite.t(), opts :: keyword()) :: binary()
Renders the given graphic as a PNG image and returns its binary content.
Options
:scale
- the image scale factor. Defaults to1.0
.:ppi
- the number of pixels per inch. Defaults to72
See also VegaLite.Convert.to_png/2
@spec to_svg(vl :: VegaLite.t()) :: 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.Convert.to_svg/1