From Pasted Code to Live Dashboards: Introducing Code Panels for R and Python CanvasXpress

If you already write charts with the R canvasXpress library or the Python canvasxpress package, you no longer have to choose between "the chart I already wrote" and "the dashboard I need to ship." CanvasXpress Dashboards can now take that exact code — the same canvasXpress(...) call in R or CanvasXpress(...) object in Python you already run in your analysis — and turn it into a live, interactive, native panel inside a dashboard. No manual translation, no rebuilding the chart from scratch in a different config format.

This builds on a path that CanvasXpress Dashboards users already know well: pasting R/ggplot2 code to get a ggplot panel. Code panels extend that same idea to charts authored directly against the CanvasXpress API itself, in either R or Python.

Why this matters

A lot of scientific and analytical work starts as a script: load some data, call canvasXpress() or CanvasXpress(), tweak config options until the chart looks right, done. That script is often the real source of truth for a chart — more so than any dashboard-authoring UI. Until now, getting that chart into a shareable dashboard meant re-expressing it by hand in the dashboard's own panel format, which is busywork at best and a source of subtle mismatches at worst.

Code panels remove that step. The chart your R or Python code produces is the panel — same data, same configuration, same interactivity.

How it works

Open the Builder and use the 📈 Code button. Its dialog includes a Source picker that lists the code sources your server supports — ggplot2, R canvasXpress, and Python canvasxpress — and, for the CanvasXpress sources, a language toggle so you can paste either R or Python.

A typical R snippet looks like the kind of thing you'd already run in an R session:

library(canvasXpress)
g <- canvasXpress(data = iris,
                   graphType = "Scatter2D",
                   colorBy = "Species")

Or the Python equivalent:

from canvasxpress.canvas import CanvasXpress

g = CanvasXpress(data=my_data, config=my_config)

Paste either of these into the Builder, pick the matching source and language, and the dialog returns a live panel rendered with the full CanvasXpress JavaScript engine — pan, zoom, tooltips, legends, and every interactive behavior your chart would have anywhere else in the dashboard. Because the extracted panel is a native CanvasXpress spec rather than a special-cased chart type, it behaves exactly like any other panel you built directly in the Builder: it can be resized, repositioned, and combined with other panels in the same dashboard.

Each code panel keeps a </> Code recipe attached, so anyone looking at the dashboard later can open the panel and see the original R or Python source that produced it — a built-in paper trail from source code to visualization.

Authoring a whole dashboard from a folder of scripts

If you have a folder of R scripts, each producing one chart, you don't have to paste them in one at a time. The cxd-cx command-line tool walks a folder of R snippets and assembles them into a complete dashboard of native panels in one pass — handy for turning an existing analysis pipeline's output charts into a dashboard without touching the Builder UI at all.

It's still just a dashboard

Once a code panel exists, it's a first-class citizen of the dashboard — nothing about it is special-cased for sharing or reloading. You can use the Save as JSON action from the toolbar to serialize the whole dashboard, including code panels, and later restore it by dragging that .json file back onto the dashboard container. If you want to see exactly how a dashboard — code panels included — was assembled step by step, the Reproduce toolbar action replays its construction in order.

A note on trust

Converting arbitrary R or Python code into a chart necessarily means running that code somewhere. Code panels use the same sandboxed execution model that already powers CanvasXpress Dashboards' other code-driven features: it's gated to administrators, runs with no network access, confined storage, and strict resource limits, and it refuses to run at all if your deployment is configured against a standalone rendering engine instead of the embedded one. In other words, this is the same trust boundary you already rely on for ggplot-paste — extended to cover native CanvasXpress code, not a new category of risk.

This isn't meant for accepting arbitrary code from untrusted end users; it's meant for the person building the dashboard to reuse their own analysis code directly, safely, on infrastructure they control.

Try it

If you're evaluating CanvasXpress Dashboards and already have R or Python scripts that call canvasXpress() / CanvasXpress(), the fastest way to see this in action is to open the Builder, click 📈 Code, pick your language, and paste in something you already have. The CanvasXpress Code Gallery example ships with sample panels built this way — from an R bar chart to a Python heatmap — so you can see the range of what a pasted snippet turns into before you try your own.

The underlying principle is simple: your chart code shouldn't need a second life just to live inside a dashboard. Now it doesn't have to.