ddplot 1.0.0
Breaking changes:
- All arguments now use snake_case, throughout the package. Each
capital letter becomes an underscore followed by the lower-case letter
(
titleFontSize is now title_font_size,
strokeWidth is stroke_width,
axisCol is axis_col,
colorCategory is color_category,
valueFormat is value_format, topN
is top_n), and lower-case names made of several words are
split too: bgcol is now bg_col,
xtitle/ytitle are
x_title/y_title,
xticks/yticks are
x_ticks/y_ticks, xtitleFontSize
is x_title_font_size,
hlines/vlines are
h_lines/v_lines, rollmean is
roll_mean (line_chart()),
meanline is mean_line
(violin_plot()), and
panelcol/xgridlinecol are
panel_col/x_grid_line_col
(bar_chart_race()). Code written for ddplot 0.2.0 must be
updated to the new names.
New charts:
- New
box_plot(): boxes and whiskers per group, with the
outliers or every point (points), notches, the mean,
horizontal boxes and sorting by median or mean. The quartiles are
computed in R (quantile() type 7, as in
boxplot()). Hovering a box shows its summary while the
others fade.
- New
density_plot(): kernel density curves computed with
stats::density() (bandwidth,
adjust), overlapping, stacked or as shares
(position), with mean or median lines, a rug, a guide that
reads every curve at the pointer, and a legend that hides groups.
- New
heatmap_chart(): a grid of coloured cells for two
categorical columns, with aggregation (aggregate), a
sequential or diverging (midpoint) colour ramp, clustering
of rows and columns (cluster), values in the cells, a
colour legend that marks the hovered cell and row and column
highlighting.
- New
sankey_diagram(): flows between nodes laid out in
columns (align), with flows coloured by source, target or a
gradient, node values, draggable nodes, flows that run in from left to
right, and tooltips with the share of the source and the target. Cycles
are detected and refused.
- New
network_graph(): a force-directed network from a
table of links and an optional table of nodes (node_group,
node_size, node_label), with directed arrows,
weighted links, neighbour highlighting, draggable nodes, zoom and pan,
and a legend that highlights groups.
- New
likert_chart(): diverging stacked bars for survey
answers on an ordered scale (levels), with a neutral answer
split across the centre, negative and positive totals, sorting by
agreement and highlighting of an answer across questions.
- New
funnel_chart(): the stages of a process as centred
bars, joined by a funnel or not (shape), with the
conversion between stages, the share of the first stage, and the number
lost on the way in the tooltip.
- New
gantt_chart(): tasks along a time axis with groups,
progress, dependencies drawn as arrows (depends_on),
milestones, a today line, zoom and pan in time, and
highlighting of the chain of tasks linked to the hovered one.
- New
candlestick_chart(): open / high / low / close
candles with volumes, moving averages (moving_average), a
crosshair with a price readout, and zoom and pan that refit the price
axis to the visible candles.
- New
circle_packing(): a hierarchy of one or more
grouping levels as nested circles, with zoom into groups on click,
labels that fit their circles and tooltips with the share of the
parent.
- All ten share a small script of helpers (tooltips, legends, Shiny),
work with D3 v5 and v6, animate when drawn (
animate = FALSE
to turn it off, and they stay still for visitors who prefer reduced
motion) and report clicks to Shiny in
input$<id>_clicked.
Improvements:
bar_chart() and horz_bar_chart() have been
rewritten and now share one interactive D3 script. New arguments:
group with position = "grouped",
"stacked" or "percent" (switchable from
buttons on the chart), agg ("sum",
"mean", "median", "min",
"max", "count") so raw rows can be passed
directly (leave y/value empty to count rows),
labels (values on the bars), highlight,
ref_lines, negative_fill,
corner_radius, legend, controls,
tooltip, animate,
value_format/value_prefix/value_suffix,
subtitle and grid_col. Bars grow in when
drawn; the tooltip shows the value, share of total and rank (or every
group and the total); buttons re-sort the bars with an animation; the
legend hides (click) or isolates (double-click) groups. Negative values
are supported. Long category labels are rotated or truncated
automatically. In Shiny, input$<id>_clicked returns
the clicked category and group, and the layout, sort order and hidden
groups are kept across renderD3() updates. Existing calls
keep working; the default look changed (white background, palette colour
instead of crimson unless fill is set, value labels,
rounded bar ends, value-axis title defaults to the column name, smaller
fonts), and x_ticks in bar_chart() is no
longer used.
lollipop_chart() and horz_lollipop() have
been rewritten on the same interactive script as the bar charts. New
arguments: group (one lollipop per group, side by side,
with a click/double-click legend), agg (raw rows are
aggregated; leave y/value empty to count
rows), labels, highlight,
ref_lines, negative_fill, legend,
controls, tooltip, animate,
value_format/value_prefix/value_suffix,
subtitle, grid_col and opacity.
Lollipops grow in when drawn, show their values, can be re-sorted from
buttons on the chart, and show their value, rank and (for sums and
counts) share of the total on hover. Negative values are drawn downwards
(or to the left). In Shiny, input$<id>_clicked
returns the clicked category and group, and the sort order and hidden
groups are kept across renderD3() updates. Breaking
changes: several rows with the same category are now combined (summed by
default, see agg) instead of being drawn on top of each
other (use beeswarm_plot() to show every row);
y/value are now optional; the default look
changed (palette colour instead of maroon and lime,
line_stroke_width = 2, circle_radius = 6, a
ring in the background colour around the dots, value-axis title defaults
to the column name, smaller fonts); x_ticks and
label_ticks are no longer used.
- In
bar_chart() and horz_bar_chart(), the
tooltip no longer shows a share of the total or a total when the values
are means, medians, minima or maxima (agg), and, in the
side-by-side layout, categories are then sorted by the average of their
groups rather than their total.
area_chart(), stacked_area_chart() and
area_band() have been rewritten on the interactive script
of line_chart(): they get its crosshair tooltip, range
buttons, navigator, drag-to-zoom (double-click to reset),
click/double-click legend, end labels, events,
bands, h_lines, value and date formats,
subtitle, and ts/mts input (for
area_chart() and stacked_area_chart()).
area_chart() gains several series (y = c(...)
or group), baseline and
negative_fill (area above and below a value in two colours)
and curve. stacked_area_chart() gains Stacked
/ 100% buttons (position, controls), a tooltip
with every layer, its share and the total, layers that re-stack when one
is hidden, long data (y + group),
y to choose the columns and colors; missing
values count as zero when stacking and negative values are stacked below
zero. area_band() gains an optional central line
(y, line_width), one band per
group, and a tooltip with the range. In Shiny, the zoom,
the hidden series and the stacked layout are kept across
renderD3() updates. Existing calls keep working, but the
defaults changed: white background, palette colours instead of crimson
(and of the D3 Category10 scheme in stacked_area_chart();
color_category still picks a scheme), smaller fonts, a
gradient fill in area_chart() unless opacity
is given, stroke_width = 1 and opacity = 0.85
in stacked_area_chart(), a semi-transparent band in
area_band(). stacked_area_chart() now stacks
the numeric columns only, and
legend_box_size/legend_text_size are no longer
used.
histogram() has been rewritten as an interactive chart.
New arguments: data (give a data frame and column names),
group with position = "stacked" or
"overlay", stat = "count",
"percent" or "density", bin_width
and breaks, density (kernel density or normal
curve), stats (mean and median lines),
ref_lines, rug, summary,
x_format/x_prefix/x_suffix,
legend, controls, tooltip,
animate, corner_radius, subtitle
and grid_col. The number of bins, counts / percentages and
the group layout can be changed from buttons on the chart; hovering a
bin shows its range, count, share and cumulative share; a summary (n,
mean, median, standard deviation) is shown above the bars; dragging
across the bars selects a range, which can be zoomed into and re-binned
(double-click resets); the legend hides (click) or isolates
(double-click) groups. Integer data get bins centred on the integers. In
Shiny, input$<id>_clicked and
input$<id>_selected return the clicked bin and the
selected range, and the bins, layout, hidden groups and zoom are kept
across renderD3() updates. Existing calls keep working; the
default look changed (white background, palette colour instead of
crimson unless fill is set, bins with round widths so
bins is approximate, x-axis title defaults to the variable
name, smaller fonts).
pie_chart() has been rewritten as an interactive chart.
value is now optional (rows are counted) and rows with the
same label are added up. New arguments: fill,
sort, max_slices/other_label
(combine the smallest slices), labels and
label_position (labels inside the slices, or outside with
leader lines), legend, center_label (donut
centre), highlight,
start_angle/end_angle (e.g. half donuts),
stroke/stroke_width, tooltip,
animate,
value_format/value_prefix/value_suffix,
subtitle and axis_col. Slices sweep in, pull
out on hover with a tooltip (value, share, rank; the “Other” slice lists
what it contains), and can be hidden (click) or isolated (double-click)
from the legend, the shares being recomputed; donut charts show the
total, or the hovered slice, in their centre. inner_radius
below 1 is now a fraction of the radius. In Shiny,
input$<id>_clicked returns the clicked label and the
hidden slices are kept across renderD3() updates. Existing
calls keep working; the default look changed (palette colours instead of
the “Paired” scheme unless color_category is set, lines
between the slices, percentages on the slices, a legend with the shares
on the right or below, the title at the top left,
label_height defaults to 12, pad_radius now
defaults to the D3 default so pad_angle works on its
own).
parliament_chart() has been rewritten as an interactive
hemicycle and coalition builder. The seats are laid out on as many rows
as give the largest seats, and the parties form wedges from left to
right; a dashed line marks the majority and the centre shows the total.
Hovering a seat or a legend entry shows the party’s seats, share, rank
and distance from a majority; clicking parties builds a coalition whose
seats glide to the left, with a gauge counting them against the
majority. New arguments: subtitle, fill,
color_category, previous (gains and losses
since the previous election), majority (a number or share
of seats, or FALSE), coalition,
coalition_builder, regroup, sort,
arc (from a hemicycle to a full ring),
inner_radius, seat_shape,
center_label, legend, tooltip,
animate and axis_col. The seats fill in from
left to right when the chart comes into view. In Shiny,
input$<id>_clicked returns the clicked party and
input$<id>_coalition the coalition, which is kept
across renderD3() updates while the seats glide to their
new places. Bug fixes: the chart now works with any column names (it
only drew seats for columns named political_party and
number_of_seats), width and
height are applied, seats that did not fit are no longer
dropped, and the tooltip no longer leaks into the page. Existing calls
keep working; the default look changed (white background, palette
colours, seats sized to fill the chart unless seat_size is
given, title at the top left, title_font_size = 20).
scatter_plot() has been upgraded. New arguments:
group (categorical colours with a click/double-click
legend, or a colour gradient for a numeric column),
size_by/size_range (bubble chart),
label/show_labels (tooltip titles and
collision-free point labels), tooltip (extra columns),
trend = "lm"/"loess" with a 95% confidence
band (ci) and fit statistics on hover,
x_scale/y_scale = "log",
h_lines/v_lines,
x_format/y_format, subtitle and
grid_col. Hovering a point shows its values with guides to
both axes; dragging a box selects points, which can be zoomed into
(double-click resets). In Shiny, input$<id>_selected
and input$<id>_clicked return the selected and
clicked row numbers, and hidden groups and the zoom are kept across
renderD3() updates. Existing calls keep working; the
default look changed (white background, grid lines, palette colour
instead of crimson unless col is set,
size = 4, opacity = 0.8, axis titles default
to the column names, smaller title font sizes).
Race charts:
- A new family of animated race charts shares one player: a play /
pause button, a timeline that can be dragged to any moment, a speed
button (0.5x to 4x), a loop button and keyboard controls (space, arrow
keys, Home, End). The races animate continuously between periods, which
can be numbers, dates or text; items can enter late, leave early or have
gaps; tooltips keep updating while the race plays; the race starts when
the chart scrolls into view (
autoplay,
start_frame, loop, controls,
frame_dur, ease, time_format). In
Shiny, input$<id>_frame reports the period on show
and the period, speed and pinned or hidden items are kept across
renderD3() updates. A new “Race charts” guide shows them
all.
bar_chart_race() has been rewritten on this player:
bars overtake each other exactly when their values cross, new items rise
from below the cut and leaving ones sink, value labels count smoothly, a
big period label (with an optional total counter) sits in
the corner, hovering shows the value, rank and change since the previous
period, and clicking a bar follows it, even below the cut. New
arguments: top_n (with Top N buttons), group
(colours and a clickable legend), fill,
highlight, labels, name_position,
total, rank_flash, agg,
corner_radius, subtitle, value formats,
tooltip, axis_col and the player arguments.
Existing calls keep working; the default look changed (white background,
palette colours, no stroke or panel), and frame_dur /
transition_dur now default to 0 / 1000 (each period lasts
frame_dur + transition_dur). sort = "none" now
works.
- New
line_race(): a racing line chart where lines grow
over time with live labels at their heads, smoothly rescaling axes, a
value / rank (bump chart) switch, top_n leaders over grey
context lines, a sliding window or growing time axis,
pop-up events, crosshair tooltips, pinning and a category
legend.
- New
bubble_race(): an animated Gapminder style bubble
chart with fixed linear or log axes (switchable from the chart), a
period watermark, live tooltips with axis guides, click to follow
bubbles with their trails (hover or click a trail dot to jump in time),
a group legend, a size legend and Shiny inputs (_clicked,
_followed).
- New
radial_bar_race(): a circular bar chart race with
spokes and rings layouts that morph into each other, smoothly moving
ranks, a live centre counter, rank-change arrows, live tooltips,
click-to-pin and a group legend.
- New
treemap_race(): an animated treemap whose tiles
glide as the values change (stable re-squarified layout), with optional
groups (headers, zoom on click, legend to hide or isolate), live
tooltips, pinned items, value / share / growth labels and a growth heat
map colour mode.
- New
donut_race(): an animated share race, a donut or
pie whose slices glide past each other when the ranking changes, with a
live league table (share bars, values, rank change arrows), an “Other”
slice that items flow into and out of (max_slices), hover
and pin, hide and show all, and a ranked or fixed slice order.
Playful indicators:
- New
muscle_growth(): a sailor flexing both arms whose
biceps grow with a level, from flat, skinny arms (0) to giant biceps
(1), with stages from “Noodle arms” to “Mighty”. The sailor strains at
low levels (squeezed eyes, gritted teeth, a red face, sweat and
trembling arms) and grins at high ones; the shoulders widen, the anchor
and heart tattoos stretch with the biceps (tattoos), veins
show and the biggest biceps sparkle (sparkles). The eyes
follow the mouse, and clicking makes the sailor flex harder, the cap
jump and a speech bubble pop up. It has target (a dashed
outline of the biceps to reach), draggable (drag up to
grow, down to shrink), colours for the skin, hair, stripes and card, and
the Shiny inputs of the other indicators.
- New
nose_growth(): a person in profile whose nose grows
with a level, from a small nose (0) to one that reaches across the chart
(1), with stages from “Honest” to “Pants on fire”. A twig with leaves
sprouts from a long nose and a bird lands on the longest
(leaves, bird); the person gets more nervous
(wavy mouth, raised brow, blush, a drop of sweat) as the nose grows. The
eye follows the mouse, the ponytail swings, and clicking makes the nose
wobble, the bird hop and the person protest in a speech bubble. It has
target, draggable (the tip follows the mouse),
colours for the skin, hair, stripes and card, and the Shiny inputs of
the other indicators.
- New
hair_growth(): a portrait whose hair grows with a
level, from a bald, shiny head (0) through stubble, a buzz cut, short
curls and curly hair to a big afro with an afro pick (1). The face
smiles more as the hair grows, the eyes follow the mouse, the person
blinks and breathes, and clicking makes the afro bounce and the person
wink. It has target (a dashed outline of the hair to
reach), draggable (drag up to grow, down to cut), colours
for the hair, skin, turtleneck and card, and the Shiny inputs of the
other indicators (input$<id>_clicked with the stage,
input$<id>_value).
heart_fill(), glass_fill(),
plant_growth(), flame() and
flower() have been rewritten as animated, interactive
indicators sharing one script of helpers. They animate when they scroll
into view (the heart and the glass fill up, the plant grows, the flame
ignites, the flower blooms) while the value counts up, only animate
while on screen, stay still for visitors who prefer reduced motion, and
fit the size of the widget (width, height and
bg_col are now available everywhere). In Shiny, a new value
moves smoothly from the old one, input$<id>_clicked
reports clicks and, with the new draggable = TRUE (heart,
glass, plant and flame), viewers can set the level by dragging or with
the arrow keys, reported in input$<id>_value.
Existing calls keep working; the size arguments
(heart_size, glass_width,
glass_height, pot_width,
pot_height, plant_max_height,
petal_length, petal_width,
center_radius) now default to fitting the chart, font sizes
can be numbers or CSS sizes, and the default colours changed.
heart_fill(): a classic heart shape with a wavy liquid,
a gloss, a heartbeat (beat, bpm), the
percentage inside the heart (white over the liquid) and a
target line; hover to speed up the beat, click to release
small hearts.
glass_fill(): a tapered glass with reflections, a
moving surface (waves), rising bubbles, an
optional measuring scale (ticks) and target;
moving the mouse rocks the water, clicking drops some more in.
plant_growth(): the plant grows from a seed to a
sprout, leaves, a bud and an opening flower, sways in the breeze
(sway), shows its stage and an optional
target; hover for a gust of wind, click to water it. New
label_color, label_font_size and
soil_color; flower_color is now used.
flame(): a three-layer flickering flame with a glow and
sparks (flicker, sparks), on its own, a candle
or logs (base), its height scaled to
max_intensity, an optional value and caption
(show_value, value_suffix,
title_text); it leans away from the mouse and flares up
when clicked. flame_outline now defaults to no outline, and
width and height are now applied.
flower(): gradient petals in two rings
(layers), stamens on a golden-angle spiral
(stamens), a bloom when it comes into view
(bloom), and petals to pluck (“loves me, loves me not”,
pluck). With petal_values and
petal_labels, it becomes a small flower chart with tooltips
and highlighting. It stops turning while hovered, and
rotation_speed now defaults to 0.5.
ddplot 0.2.0
Improvements:
line_chart() has been rewritten for time series work.
It now supports several series (wide y = c(...), long
group =, or ts/mts objects passed
directly), a crosshair tooltip showing every series at the hovered date,
a click/double-click legend, direct end labels, range buttons (1M …
All), a navigator brush, drag-to-zoom with an auto-rescaling y axis,
transform = "index"/"percent" rebasing,
rollmean, lower/upper forecast
ribbons, bands, events, hlines,
yScale = "log", area and points.
In Shiny, the zoom range and hidden series are kept across
renderD3() updates. Existing calls keep working; the
default look changed (white background, strokeWidth = 2,
titleFontSize = 20,
xtitleFontSize/ytitleFontSize = 13,
left-aligned title, y-axis title above the axis, palette color instead
of crimson for a single series unless stroke is set, y axis
fitted to the data unless yZero = TRUE or
area = TRUE).
Documentation:
- The website has been redesigned (Bootstrap 5, light and dark
themes). It has a new home page, a filterable gallery of every chart,
and one guide per family of charts (time series, comparisons,
distributions, relationships, part-to-whole, KPIs, playful indicators),
ordered from the most commonly needed charts to the more specialised
ones. The reference index is grouped the same way. The “Get started”
vignette is now a short introduction; the chart-by-chart examples moved
to the website guides.
Bug fixes:
- Charts now redraw correctly in
Shiny with
r2d3::d3Output() / r2d3::renderD3().
Previously r2d3 re-ran the chart script on the same SVG, so updates were
drawn on top of the previous chart (or not visibly at all) and animation
timers kept running. A shared preamble (ddplotreset.js) now
clears the previous render and stops its timers before each redraw; this
also fixes stacked timers after a widget resize.
Adding new functions:
slope_chart: Tufte / New York Times style slopegraph
comparing two values per category, with direction colouring,
highlight, label collision avoidance and
hover-to-focus.
bump_chart: ranking-over-time chart (Financial Times,
The Economist, FiveThirtyEight) with ranks computed per period (or
supplied via ranked = TRUE), rank circles, end labels and
highlight.
ridgeline_plot: “joy plot” of stacked kernel densities
per group, with Gaussian/Epanechnikov kernels, overlap,
sort, mean/median markers and hover tooltips.
treemap_chart: Shneiderman / NYT budget style treemap
with optional group hierarchy, several tiling algorithms,
auto-fitting labels, group headers and an in-SVG tooltip.
waffle_chart: Pew / FiveThirtyEight style square-grid
part-to-whole chart using largest-remainder allocation, row or column
fill, animated entry and hover highlighting.
sunburst_chart: zoomable sunburst for hierarchical data
(inspired by Apache ECharts), with click-to-zoom, branch highlighting on
hover and smooth arc transitions.
radar_chart: radar / spider chart (inspired by
Chart.js) with polygon or circular grid, shared or per-axis scaling,
center-out animation, point tooltips and a click-to-toggle legend.
calendar_heatmap: GitHub-style calendar heatmap
(inspired by Frappe Charts) with one panel per year, Sunday/Monday week
start, a hoverable “Less … More” legend and a staggered fade-in.
chord_diagram: chord diagram (inspired by Nivo) from an
edge list or square matrix, with hover-to-fade, flow tooltips, gradient
ribbons and click-to-pin.
streamgraph: streamgraph (inspired by Highcharts) with
wiggle/silhouette/expand baselines, inline layer labels, crosshair
tooltip and a click-to-toggle legend.
violin_plot: violin plot (inspired by Plotly.js) with
per-group Gaussian KDE, inner box plot, mean line, jittered points and a
summary-statistics tooltip.
mosaic_chart: mosaic / Marimekko chart (inspired by
Vega-Lite) with variable-width columns, 100%-stacked segments, in-cell
labels and share tooltips.
radial_bar_chart: concentric circular progress rings
(inspired by ApexCharts’ radialBar) with rounded arcs, sweep-in
animation and a center readout that updates on hover.
rose_chart: Nightingale rose / polar area chart
(inspired by AntV G2) with area-true square-root radii, optional
stacking, pop-out hover and a clickable legend.
hexbin_plot: hexagonal binning plot (inspired by
Observable Plot’s hexbin) coloured by count on a linear, sqrt or log
scale, with optional size-by-count and a continuous legend.
ddplot 0.1.0
Breaking changes:
- Now all function are
snake_case named
Adding new functions:
pulse_grid
gauge_chart
bullet_chart
beeswarm_plot
dumbbell_chart
waterfall_chart
liquid_chart
ddplot 0.0.2
Adding new functions:
flame
glass_fill
heart_fill
flower
plant_growth
parliament_chart
ddplot 0.0.1