Plotting Data with Plotly Offline Mode in an Air-Gapped Environment

Foong Min Wong
2 min readOct 16, 2024

--

When conducting demos in secure locations or areas with limited or no internet connection, displaying interactive visualizations of experimental data can be challenging. Whether you are showcasing data trends, simulation results, or complex analyses, being unable to rely on cloud-based plotting services can make things difficult. This is where Plotly’s offline mode comes into play to create and view rich, interactive plots without an internet connection.

Normally, Plotly’s online mode relies on external resources from a Content Delivery Network (CDN) like Plotly’s JavaScript library hosted on their servers. It requires an internet connection to download the libraries when rendering the plot. However, when privacy or security is a concern, or when you are working in air-gapped environments, the online mode may not be a suitable option.

Plotly’s offline mode overcomes this by allowing you to plot without the internet, ensure data is secured or not uploaded to external servers, and embed self-contained HTML files in their private browsers or dashboards with colleagues for collaborative analysis without compromising security protocols.

Plotly’s include_plotlyjs: https://plotly.com/python-api-reference/generated/plotly.io.html?highlight=include_plotlyjs

Self-contained HTML files include the entire Plotly JavaScript library and the data needed to display a plot are embedded directly within the HTML file when using offline mode. This means you don’t need to connect to external servers or CDNs to load resources. Since all required scripts and data are included in the exported HTML file, the plot can be viewed and interacted with entirely locally, which is essential in environments where internet connections are prohibited or heavily controlled. The offline plot can be packaged as an HTML file, which can be moved across secure systems (e.g., via USB drives or secure file transfer methods), allowing others in the air-gapped environment to view the plot without needing any additional tools.

Comparison of displaying exported Plotly HTML files with different configurations when the internet is disconnected

When exporting a Ploly plot for embedding in a secure dashboard, you want all the required JavaScript libraries and data to be included directly in the exported HTML. This will make the plot fully self-contained and able to be rendered without relying on any external sources like CDNs. Using include_plotlyjs=’include’ in either plotly.offline.plot() or plotly.io.to_html() ensures that the Plotly JavaScript library is embedded directly into the HTML file.

--

--

No responses yet