# Altair Saver
[](https://github.com/altair-viz/altair_saver/actions?query=workflow%3Abuild)
[](https://github.com/altair-viz/altair_saver/actions?query=workflow%3Alint)
[](https://github.com/psf/black)
[](https://colab.research.google.com/github/altair-viz/altair_saver/blob/master/AltairSaver.ipynb)
This packge provides extensions to [Altair](http://altair-viz.github.io) for saving charts
to a variety of output types. Supported output formats are:
- ``.json``/``.vl.json``: Vega-Lite JSON specification
- ``.vg.json``: Vega JSON specification
- ``.html``: HTML output
- ``.png``: PNG image
- ``.svg``: SVG image
- ``.pdf``: PDF image
## Usage
The ``altair_saver`` library has a single public function, ``altair_saver.save()``.
Given an Altair chart named ``chart``, you can use it as follows:
```python
from altair_saver import save
save(chart, "chart.vl.json") # Vega-Lite JSON specification
save(chart, "chart.vg.json") # Vega JSON specification
save(chart, "chart.html") # HTML document
save(chart, "chart.html", inline=True) # HTML document with all JS code included inline
save(chart, "chart.png") # PNG Image
save(chart, "chart.svg") # SVG Image
save(chart, "chart.pdf") # PDF Image
```
### Renderer
Additionally, altair_saver provides an [Altair Renderer](https://altair-viz.github.io/user_guide/display_frontends.html#altair-s-renderer-framework)
entrypoint that can display the above outputs directly in Jupyter notebooks.
For example, you can specify a vega-lite mimetype (supported by JupyterLab, nteract, and other
platforms) with a PNG fallback for other frontends as follows:
```python
alt.renderers.enable('altair_saver', ['vega-lite', 'png'])
```
## Installation
The ``altair_saver`` package can be installed with:
```
$ pip install altair_saver
```
Saving as ``vl.json`` and as ``html`` requires no additional setup.
To install with conda, use
```
$ conda install -c conda-forge altair_saver
```
The conda package installs the *NodeJS* dependencies described below, so charts can be
saved to ``png``, ``svg``, and ``pdf`` without additional setup.
### Additional Requirements
Output to ``png``, ``svg``, and ``pdf`` requires execution of Javascript code, which
``altair_saver`` can do via one of two backends.
#### Selenium
The *selenium* backend supports the following formats:
- `.vg.json`
- `.png`
- `.svg`.
To be used, it requires the [Selenium](https://selenium.dev/selenium/docs/api/py/) Python package,
and a properly configured installation of either [chromedriver](https://chromedriver.chromium.org/) or
[geckodriver](https://firefox-source-docs.mozilla.org/testing/geckodriver/).
On Linux systems, this can be setup as follows:
```bash
$ pip install selenium
$ apt-get install chromium-chromedriver
```
Using conda, the required packages can be installed as follows (a compatible version of
[Google Chrome](https://www.google.com/chrome/) must be installed separately):
```bash
$ conda install -c python-chromedriver-binary
```
Selenium supports [other browsers](https://selenium-python.readthedocs.io/installation.html) as well,
but altair-saver is currently only tested with Chrome.
#### NodeJS
The *nodejs* backend supports the following formats:
- `.vg.json`
- `.png`
- `.svg`
- `.pdf`
It requires [NodeJS](https://nodejs.org/), along with the [vega-lite](https://www.npmjs.com/package/vega-lite),
[vega-cli](https://www.npmjs.com/package/vega-cli), and [canvas](https://www.npmjs.com/package/canvas) packages.
First install NodeJS either by [direct download](https://nodejs.org/en/download/) or via a
[package manager](https://nodejs.org/en/download/package-manager/), and then use the `npm` tool
to install the required packages:
```bash
$ npm install vega-lite vega-cli canvas
```
Using conda, node and the required packages can be installed as follows:
```bash
$ conda install -c conda-forge vega-cli vega-lite-cli
```
These packages are included automatically when installing ``altair_saver`` via conda-forge.
Raw data
{
"_id": null,
"home_page": "http://github.com/altair-viz/altair_saver/",
"name": "altair-saver",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "Jake VanderPlas",
"author_email": "jakevdp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ad/80/21a2928d4f857bf3d7c0dae46b1fe0b5b0b70057f844ee0d5d090effb5fe/altair_saver-0.5.0.tar.gz",
"platform": "",
"description": "# Altair Saver\n\n[](https://github.com/altair-viz/altair_saver/actions?query=workflow%3Abuild)\n[](https://github.com/altair-viz/altair_saver/actions?query=workflow%3Alint)\n[](https://github.com/psf/black)\n[](https://colab.research.google.com/github/altair-viz/altair_saver/blob/master/AltairSaver.ipynb)\n\n\nThis packge provides extensions to [Altair](http://altair-viz.github.io) for saving charts\nto a variety of output types. Supported output formats are:\n\n- ``.json``/``.vl.json``: Vega-Lite JSON specification\n- ``.vg.json``: Vega JSON specification\n- ``.html``: HTML output\n- ``.png``: PNG image\n- ``.svg``: SVG image\n- ``.pdf``: PDF image\n\n## Usage\nThe ``altair_saver`` library has a single public function, ``altair_saver.save()``.\nGiven an Altair chart named ``chart``, you can use it as follows:\n```python\nfrom altair_saver import save\n\nsave(chart, \"chart.vl.json\") # Vega-Lite JSON specification\nsave(chart, \"chart.vg.json\") # Vega JSON specification\nsave(chart, \"chart.html\") # HTML document\nsave(chart, \"chart.html\", inline=True) # HTML document with all JS code included inline\nsave(chart, \"chart.png\") # PNG Image\nsave(chart, \"chart.svg\") # SVG Image\nsave(chart, \"chart.pdf\") # PDF Image\n```\n\n### Renderer\nAdditionally, altair_saver provides an [Altair Renderer](https://altair-viz.github.io/user_guide/display_frontends.html#altair-s-renderer-framework)\nentrypoint that can display the above outputs directly in Jupyter notebooks.\nFor example, you can specify a vega-lite mimetype (supported by JupyterLab, nteract, and other\nplatforms) with a PNG fallback for other frontends as follows:\n```python\nalt.renderers.enable('altair_saver', ['vega-lite', 'png'])\n```\n\n## Installation\nThe ``altair_saver`` package can be installed with:\n```\n$ pip install altair_saver\n```\nSaving as ``vl.json`` and as ``html`` requires no additional setup.\n\nTo install with conda, use\n```\n$ conda install -c conda-forge altair_saver\n```\nThe conda package installs the *NodeJS* dependencies described below, so charts can be\nsaved to ``png``, ``svg``, and ``pdf`` without additional setup.\n\n### Additional Requirements\n\nOutput to ``png``, ``svg``, and ``pdf`` requires execution of Javascript code, which\n``altair_saver`` can do via one of two backends.\n\n#### Selenium\nThe *selenium* backend supports the following formats:\n\n- `.vg.json`\n- `.png`\n- `.svg`.\n\nTo be used, it requires the [Selenium](https://selenium.dev/selenium/docs/api/py/) Python package,\nand a properly configured installation of either [chromedriver](https://chromedriver.chromium.org/) or\n[geckodriver](https://firefox-source-docs.mozilla.org/testing/geckodriver/).\n\nOn Linux systems, this can be setup as follows:\n```bash\n$ pip install selenium\n$ apt-get install chromium-chromedriver\n```\nUsing conda, the required packages can be installed as follows (a compatible version of\n[Google Chrome](https://www.google.com/chrome/) must be installed separately):\n```bash\n$ conda install -c python-chromedriver-binary\n```\nSelenium supports [other browsers](https://selenium-python.readthedocs.io/installation.html) as well,\nbut altair-saver is currently only tested with Chrome.\n\n#### NodeJS\nThe *nodejs* backend supports the following formats: \n\n- `.vg.json`\n- `.png`\n- `.svg`\n- `.pdf`\n\nIt requires [NodeJS](https://nodejs.org/), along with the [vega-lite](https://www.npmjs.com/package/vega-lite),\n[vega-cli](https://www.npmjs.com/package/vega-cli), and [canvas](https://www.npmjs.com/package/canvas) packages.\n\nFirst install NodeJS either by [direct download](https://nodejs.org/en/download/) or via a\n[package manager](https://nodejs.org/en/download/package-manager/), and then use the `npm` tool\nto install the required packages:\n```bash\n$ npm install vega-lite vega-cli canvas\n```\nUsing conda, node and the required packages can be installed as follows:\n```bash\n$ conda install -c conda-forge vega-cli vega-lite-cli\n```\nThese packages are included automatically when installing ``altair_saver`` via conda-forge.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Altair extension for saving charts to various formats.",
"version": "0.5.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "71d62c2f1b5aa281557674eb85505d75a937a9edd6ef033b463b0d8693ed3839",
"md5": "1b5368e73dd212d16a53f865ad2bc018",
"sha256": "e3b1049e565dd104aa8d5d3ec681a40479f9d070a3094f4918b64b8329308fab"
},
"downloads": -1,
"filename": "altair_saver-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b5368e73dd212d16a53f865ad2bc018",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 89282,
"upload_time": "2020-03-31T12:31:23",
"upload_time_iso_8601": "2020-03-31T12:31:23.617097Z",
"url": "https://files.pythonhosted.org/packages/71/d6/2c2f1b5aa281557674eb85505d75a937a9edd6ef033b463b0d8693ed3839/altair_saver-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ad8021a2928d4f857bf3d7c0dae46b1fe0b5b0b70057f844ee0d5d090effb5fe",
"md5": "acd8816c7b85eeb6d58e33bc587d913e",
"sha256": "c098bcf6868e3ba11db108904dc3b8515b54505b89bca5f69527115487b88795"
},
"downloads": -1,
"filename": "altair_saver-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "acd8816c7b85eeb6d58e33bc587d913e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 84757,
"upload_time": "2020-03-31T12:31:24",
"upload_time_iso_8601": "2020-03-31T12:31:24.916648Z",
"url": "https://files.pythonhosted.org/packages/ad/80/21a2928d4f857bf3d7c0dae46b1fe0b5b0b70057f844ee0d5d090effb5fe/altair_saver-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-03-31 12:31:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "altair-viz",
"github_project": "altair_saver",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "altair",
"specs": []
},
{
"name": "altair_data_server",
"specs": [
[
">=",
"0.4.0"
]
]
},
{
"name": "altair_viewer",
"specs": []
},
{
"name": "selenium",
"specs": []
}
],
"lcname": "altair-saver"
}