.. currentmodule:: gosling .. _export: Exporting Visualizations ======================== A gosling visualization can be exported to either a **standalone HTML file** or a **JSON object** by calling the `save` function. The format of the exported visualization is determined by a file extension you specify (i.e., `*.html` or `*.json`). HTML ---- You can save an HTML file that embeds your Gosling visualization. .. code-block:: python vis = gos.Track( gos.bigwig("https://s3.amazonaws.com/gosling-lang.org/data/HFFc6_H3K4me3.bigWig") ).encode( x='position:G', y='value:Q' ).view() vis.save('gosling.html') The saved HTML file includes all resources that are needed to display Gosling visualization on the webpage. .. code-block:: html
If you open the HTML file on your browser, you will be able to see your visualization displayed on the page. JSON ---- You can save the JSON object of your Gosling visualization. .. code-block:: python vis = gos.Track( gos.bigwig("https://s3.amazonaws.com/gosling-lang.org/data/HFFc6_H3K4me3.bigWig") ).encode( x='position:G', y='value:Q' ).view() vis.save('gosling.json') This object is a full specification of your Gosling visualization. You can copy the object and paste it on the `Gosling Editor`_ to display your visualization. .. code-block:: json { "tracks": [ { "data": { "type": "bigwig", "url": "https://s3.amazonaws.com/gosling-lang.org/data/HFFc6_H3K4me3.bigWig" }, "height": 180, "mark": "bar", "width": 800, "x": { "field": "position", "type": "genomic" }, "y": { "field": "value", "type": "quantitative" } } ] } .. _Gosling Editor: https://gosling.js.org/