Sample 06 — Interactive Data and Learning Widgets
Explore synthetic datasets with interactive plots, charts, quizzes, and tabs, with copyable JSON and accessible static fallbacks.
Source: https://lapotron.com/article/sample-interactive-data/
A useful interactive invites the reader to test a relationship, not merely watch an animation. In this sample, readers can change a function's parameters, inspect a chart, explore a hierarchy, and check a short answer.
Every dataset here is invented for demonstration. The numbers do not describe site visitors, actual experiments, or a person's routine. Source blocks show the complete author-facing configuration; the live component appears immediately below each block.
Describe a widget with data
An interactive fence contains one validated JSON object. The type chooses a widget; chart widgets also have a style. Titles and captions explain what the reader should notice. Use JSON data rather than JavaScript expressions or callback functions.
The simplest experiment is a sine curve with amplitude and frequency controls.
Change one parameter at a time
Try it: move a slider with the keyboard, inspect its value, and use Reset. A caption should give the reader a concrete comparison to make.
Follow a trend with a line chart
A category chart has labels and equally sized value arrays. A null is a missing observation, not a measured zero. A second series and a reference line give the reader useful comparisons.
Two imagined sequences
View data table
| Label | Sequence A | Sequence B |
|---|---|---|
| Pass 1 | 4 | 3 |
| Pass 2 | 6 | 5 |
| Pass 3 | — | 7 |
| Pass 4 | 9 | 8 |
| Pass 5 | 11 | 10 |
Try it: inspect the shared tooltip, hide a series with its legend, and reset. Focus the plot and use Left/Right to move between points and Up/Down to change series. Enter pins a tooltip; Escape dismisses it. Zoom controls change the visible range, while the data table retains the source values.
Use a time axis and dated XY points when the spacing represents real elapsed time. Category labels alone do not make an evenly spaced timeline into a continuous time scale.
Compare parts with stacked bars
Stacking is appropriate when the values are meaningful parts of a total. These invented minutes form one small scheduling example.
An imagined study session
View data table
| Label | Reading | Making |
|---|---|---|
| Plan | 10 | 5 |
| Draft | 5 | 20 |
| Review | 8 | 7 |
Try it: compare the total heights, then hide one category to inspect its contribution. Be explicit about whether the chart shows raw totals or percentages; changing the visual form changes the question a reader can answer.
Use numeric coordinates for a scatter plot
XY data uses points, with numeric x and y. Optional low and high fields display an interval. Here those bounds are illustrative marks, not estimated confidence intervals.
A synthetic input-response relationship
View data table
| Series | Label | X | Y | Radius | Low | High |
|---|---|---|---|---|---|---|
| Example points | 1 | 2 | — | 1.5 | 2.5 | |
| Example points | 2 | 4.5 | — | 4 | 5 | |
| Example points | 3 | 6 | — | 5.5 | 6.5 | |
| Example points | 4 | 8.5 | — | 8 | 9 |
A visually smooth pattern is not evidence of a causal relationship. Supply the data source, units, sampling method, and interpretation when replacing this synthetic example with real results.
Find a pattern across two categories
A heatmap has column labels, row labels, and cells of the form [columnIndex, rowIndex, value]. Indices begin at zero.
An imagined weekly practice grid
View data table
| X | Y | Value |
|---|---|---|
| Mon | Read | 5 |
| Tue | Read | 8 |
| Wed | Read | 4 |
| Thu | Read | 6 |
| Mon | Make | 3 |
| Tue | Make | 5 |
| Wed | Make | 9 |
| Thu | Make | 7 |
| Mon | Review | 2 |
| Tue | Review | 4 |
| Wed | Review | 3 |
| Thu | Review | 5 |
Try it: inspect a cell and check its row in the data table. Then narrow the value range to highlight only part of the grid. A legend or exact-value table should carry meaning that color alone cannot communicate.
Explore a hierarchy with a treemap
A hierarchy uses named branches and numeric leaf values. A treemap emphasizes relative area; it should not be used when precise comparison of similar values is the main task.
An illustrative allocation of attention
View data table
| Path | Value |
|---|---|
| Study | — |
| Study / Reading | 12 |
| Study / Notes | 8 |
| Practice | — |
| Practice / Experiments | 18 |
| Practice / Review | 10 |
The exported data records the hierarchy's paths and values. Keep branch names meaningful when you substitute a real collection.
Check an idea with a quiz
A quiz has a prompt, two to eight choices, a zero-based answer index, and an explanation. The explanation should show the reasoning, not just announce a result.
Read the numbers before the chart
Reveal explanation
5
The values sum to 20. Dividing by four values gives 5.
In a tutorial like this one, the visible source intentionally reveals the answer. For an exercise article, present only the rendered quiz and keep the source in Studio.
Switch between short plain-text summaries
Use the plain-text tab widget when panels need only text. Choose rich Markdown tabs instead when a panel contains lists, equations, images, or links.
Three ways to approach a visual
Inspect, export, and keep a static fallback
Charts are compiled to light/dark SVG with exact-value tables before publication. Their interactive engine loads on intent, such as hover, focus, or touch. The static drawing remains useful while the enhancement loads or if it is unavailable.
Try it: activate a chart, open its data table, and compare a tooltip with the corresponding source value. Download CSV for the full dataset, or SVG/PNG for the current chart view. Hidden series and a narrowed zoom range do not remove source rows from CSV.
Without JavaScript, the chart drawings and data tables remain readable, quiz explanations remain available, and tab content has a static representation. Print and PDF use the static presentation. Write titles, captions, and explanations that make sense in those modes too.
When adapting this sample, start with one question and one small dataset. Add interaction only when the reader can use it to answer that question more clearly.