Skip to content

Commit

Permalink
ci: Moved vl-convert-python to save dependency group (vega#3609)
Browse files Browse the repository at this point in the history
* Moved `vl-convert-python` to `save` dependency group

* Added `altair[save]` to installation.rst

* Update saving_charts.rst

* Update installation.rst

* Update saving_charts.rst

---------

Co-authored-by: Mattijn van Hoek <[email protected]>
  • Loading branch information
apoorvkh and mattijn authored Oct 26, 2024
1 parent f57df00 commit f7dfcc3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
6 changes: 6 additions & 0 deletions doc/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ and non-notebook IDEs, see :ref:`displaying-charts`.
If you wish to install Altair with only the required dependencies,
you can omit the ``[all]``/``-all`` suffix.

Altair can also be installed with just the dependencies necessary for saving charts to offline HTML files or PNG/SVG/PDF formats, using:

.. code-block:: bash
pip install "altair[save]"
Development Installation
========================

Expand Down
40 changes: 21 additions & 19 deletions doc/user_guide/saving_charts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ As an alternative, the ``inline=True`` keyword argument may be provided to ``cha
.. note::

Calling ``chart.save`` with ``inline=True`` requires the :ref:`install-vl-convert` package.
Calling ``chart.save`` with ``inline=True`` requires :ref:`additional-dependencies`.


.. _saving-png:
Expand All @@ -172,25 +172,11 @@ To save an Altair chart object as a PNG, SVG, or PDF image, you can use
chart.save('chart.svg')
chart.save('chart.pdf')
Saving these images requires an additional extension vl-convert_ to run the
javascript code necessary to interpret the Vega-Lite specification and output
it in the form of an image.

.. _install-vl-convert:

vl-convert
^^^^^^^^^^
The vl-convert_ package can be installed with::

conda install -c conda-forge vl-convert-python

or::
.. note::

pip install vl-convert-python
:ref:`additional-dependencies` are required to save charts as images by running the javascript
code necessary to interpret the Vega-Lite specification and output it in the form of an image.

vl-convert_ does not require any external dependencies.
See the vl-convert documentation for information and for known
`limitations <https://github.com/vega/vl-convert#limitations>`_.

altair_saver
^^^^^^^^^^^^
Expand All @@ -216,6 +202,22 @@ size at the default resolution of 72 ppi::

chart.save('chart.png', scale_factor=2)

.. _additional-dependencies:

Additional Dependencies
~~~~~~~~~~~~~~~~~~~~~~~
Saving charts to images or offline HTML files requires the vl-convert_ package::

conda install -c conda-forge vl-convert-python

or::

pip install vl-convert-python

vl-convert_ does not require any external dependencies.
See the vl-convert documentation for information and for known
`limitations <https://github.com/vega/vl-convert#limitations>`_.

Sharable URL
~~~~~~~~~~~~
The :meth:`Chart.to_url` method can be used to build a sharable URL that opens the chart
Expand All @@ -237,4 +239,4 @@ specification in the online Vega editor_.

.. _vl-convert: https://github.com/vega/vl-convert
.. _vegaEmbed: https://github.com/vega/vega-embed
.. _editor: https://vega.github.io/editor/
.. _editor: https://vega.github.io/editor/
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ Documentation = "https://altair-viz.github.io"
Source = "https://github.com/vega/altair"

[project.optional-dependencies]
save = [
"vl-convert-python>=1.7.0",
]
all = [
"altair[save]",
"vega_datasets>=0.9.0",
"vl-convert-python>=1.7.0",
"pandas>=1.1.3",
"numpy",
"pyarrow>=11",
Expand Down

0 comments on commit f7dfcc3

Please sign in to comment.