From 174d6e7aa812c900ec9c9c7ea2cbaf4b7ce8f17e Mon Sep 17 00:00:00 2001 From: Adam Schill Collberg Date: Fri, 16 May 2025 15:26:18 +0200 Subject: [PATCH] Add docs about exporting HTML to file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Florentin Dörre --- docs/source/rendering.rst | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/source/rendering.rst b/docs/source/rendering.rst index c0830089..8d2d0792 100644 --- a/docs/source/rendering.rst +++ b/docs/source/rendering.rst @@ -23,7 +23,7 @@ The ``render`` method Once you have a ``VisualizationGraph`` object, you can render it using the ``render`` method. This will return a HTML object that will be displayed in an environment that supports HTML rendering, such as -Jupyter notebooks or streamlit. +Jupyter notebooks or streamlit application. All parameter of the ``render`` method are optional, and the full list of parameters of them is listed in the API reference: :meth:`neo4j_viz.VisualizationGraph.render`. @@ -50,7 +50,23 @@ But you can disable this by passing ``show_hover_tooltip=False``. Examples --------- +~~~~~~~~ Please refer to the :doc:`Getting started section <./getting-started>` and the :doc:`tutorials <./tutorials/index>` for examples of ``render`` method usage. + + +Exporting to HTML +~~~~~~~~~~~~~~~~~ + +The object returned by the ``render`` method is a ``IPython.display.HTML`` object. +In addition to being displayed in a Jupyter notebook or streamlit application, it can also be saved as an HTML file. +This could be useful if you want to share the visualization with others or embed it in a web page. + +To save the HTML data to a file, you can use the ``data`` attribute of the HTML object: + +.. code-block:: python + + html = VG.render(...) + with open("my_graph.html", "w") as f: + f.write(html.data)