Plotly.PlotlyJS (plotly_ex v0.3.0)

Copy Markdown View Source

Single source of truth for the Plotly.js version and the ordered list of source URLs used to load it.

Loading & fallback

By default plotly.js is loaded from a CDN, falling back automatically when a source is unreachable:

1. cdn.plot.ly   (pinned, default)
2. jsdelivr      (mirror)
3. local bundle  (`/plotly_ex/plotly.min.js?v=4.1.2`, served by `Plotly.Phoenix.Plug`
   or as a Kino asset) — an offline copy vendored with this library.

Phoenix bundle URLs include the vendored version to invalidate immutable browser caches on upgrade. bundled_path/0 remains the configured route.

Each fallback emits a console.warn (browser) / Logger.warning (server) explaining what happened. When source: :bundled is configured, only the local bundle is used and no fallback warning is emitted.

Configuration (compile time)

config :plotly_ex, :plotly_js,
  version: "4.1.2",                       # default — must match the vendored bundle
  source: :cdn,                           # :cdn (default) or :bundled
  bundled_path: "/plotly_ex/plotly.min.js" # public URL the Phoenix Plug serves

Summary

Functions

Public URL the bundled copy is served at (Phoenix).

Filesystem path to the vendored bundle.

cdn.plot.ly URL for the given version.

The plotly.js version this library is built and tested against.

jsdelivr mirror URL for the given version.

Ordered list of plotly.js URLs for Kino widgets.

The configured load source: :cdn (default) or :bundled.

Ordered list of URLs to try, based on source/0.

The configured plotly.js version (defaults to compatible_version/0).

Canonical warning shown when a fallback source is used.

Functions

bundled_path()

Public URL the bundled copy is served at (Phoenix).

bundled_priv_path()

Filesystem path to the vendored bundle.

cdn_url(version \\ "4.1.2")

cdn.plot.ly URL for the given version.

compatible_version()

The plotly.js version this library is built and tested against.

jsdelivr_url(version \\ "4.1.2")

jsdelivr mirror URL for the given version.

kino_source_urls()

Ordered list of plotly.js URLs for Kino widgets.

Identical ordering to source_urls/0, but the offline fallback is the co-located Kino asset URL "./plotly.min.js" (served by Livebook from the widget's asset archive) rather than the Phoenix public path.

source()

The configured load source: :cdn (default) or :bundled.

source_urls()

Ordered list of URLs to try, based on source/0.

version()

The configured plotly.js version (defaults to compatible_version/0).

warning_message(engaged_url)

Canonical warning shown when a fallback source is used.