Developers · Releases

GDK 1.1 · released

Layouts that don’t overlap, stay stable when data changes, and react to the user.

GDK 1.1 adds functions that place shapes and labels: Separate moves them apart, Pack packs circles, and Declutter picks the labels that fit at each zoom level. Elastic grids stretch around a focus, and one call animates many shapes at once. Every demo on this page runs live, with the code that drives it.

npm install @visquill/visquill-gdk@^1.1.0

On this page: No overlap · Beeswarm · Chart labels · Map labels · Packing · Grids · Animation · Also in 1.1 · Upgrading from 1.0 · What’s new in detail →

Population of 237 countries and territories, 1950–2100, one circle each, placed without overlap. Data: UN World Population Prospects 2024.Full screen ↗

No overlap · Separate

Circles that pass each other without overlapping

When circles move through a crowd, moving them apart only where they overlap pushes the others ahead instead of letting them pass.

The blobs rise and sink and find their way past each other. Drag the edge of the band to make it wider or narrower.

demo.ts · lines 76–85Full source
blobs.forEach((b, i) => {
    const height = b.center + b.swing * Math.sin(2 * Math.PI * (b.turns * t + b.phase))
    const across = placed ? Circles.center(targets[i]).x - center.x : 0
    const sideways = Math.min(half.value, Math.max(-half.value, across))
    Circles.circleAt(Points.moveRight(Segments.pointAt(axis, height), sideways), radii[i], homes[i])
})
Separate.circles(homes, { padding, weights, previous: placed ? targets : undefined }, targets)
// …
Animate.shape.followAll(circles, targets, { alpha })

14 more Separate examples in the Lab →

Beeswarm · Separate

Beeswarm dots that make room and keep their order

In a beeswarm, dots with similar values overlap, and a layout computed anew on every update makes them jump from side to side.

Drag the disc through the dots, then switch between order, sides and fresh.

demo.ts · lines 64–75Full source
Reactive.do([axis, disc, mode], () => {
    sample.forEach((v, i) => {
        Circles.circleAt(Segments.pointAt(axis, v.value / 100), dotRadius, onAxis[i])
    })
    const keep = modes[mode.value]
    Separate.circlesAlongAxis(onAxis, "x", {
        padding:   dotPadding,
        obstacles: [obstacle],
        previous:  keep !== "fresh" && placed ? { circles: dots, keep } : undefined,
    }, dots)
    placed = true
})

14 more Separate examples in the Lab →

Chart labels · Separate

Chart labels that move apart along one axis

In a donut chart, the labels of small neighbouring slices collide, and labels moved apart by hand overlap again as soon as the data changes.

Turn separate off while the years run, and the labels of small slices collide. Turn it back on, and they slide apart in their order.

demo.ts · lines 72–87Full source
const boxes  = side.map(home => home.box)
const placed = separate ? Separate.boxesAlongAxis(boxes, "y", {
    padding,
    min: center.y - outer - 40,
    max: center.y + outer + 40,
}) : boxes
// …
    const y = Boxes.center(placed[k]).y
    // …
    Points.copy({ x: columnX, y }, labels[home.i])

14 more Separate examples in the Lab →

Map labels · Declutter

Map labels that never overlap, at any zoom level

Deciding which labels fit at each zoom level usually means a collision check written by hand and run again on every zoom step.

Zoom in: more labels appear, the larger cities first.

demo.ts · lines 72–104Full source
// Each label as a box in world coordinates, from its dot to the end of
// its text. The viewport's zoom scales the positions while the labels
// keep their size: that is Declutter's scale.
const boxes: Box[] = places.map((_, i) =>
    Boxes.box({ x: at[i].x, y: at[i].y - labelHeight / 2 },
        labelGap + Boxes.width(labels[i].extent).value, labelHeight))
// anchor [0, 0.5]: the middle of the box's left side stays at the dot.
const minScale = Declutter.boxes(boxes, places.map(p => p[3]), { padding, anchor: [0, 0.5] })
// …
        labels[i].visible.value = inView && zoom >= minScale[i]

4 more Declutter examples in the Lab →

Packing · Pack

Packed bubbles, in groups or all together

Packing bubbles in one cluster per category, with room for a name between the clusters, usually means building a hierarchy first.

Switch the groups off and on: the bubbles move to their new places.

demo.ts · lines 57–71Full source
Reactive.do([rvg.frame, grouped], () => {
    Pack.circlesAround(sizes, Points.moveDown(Boxes.center(rvg.frame), 40), {
        padding,
        groups:   grouped.value ? groups : undefined,
        groupPadding,
    }, targets)
    // …
    Animate.shape.followAll(bubbles, targets, { alpha })
    // …
})

7 more Pack examples in the Lab →
Necklace maps: circles along a ring, an arc or a coast →

Grids · Grids

Grids that enlarge the cells around a focus

A fisheye or focus-plus-context view means computing every cell anew and keeping the rest of the chart in step with it.

Drag the handle over the heatmap; the grid glides to each new focus.

demo.ts · lines 76–98Full source
Reactive.do([handle, chart], () => {
    // …
        Grids.focusAt(base, handle, focusFactor, falloff, goal)
        // …
    Animate.real.snap(t, 0)
    Animate.real.follow(t, 1, { alpha: followAlpha })
})
// …
Reactive.do([t], () => {
    Grids.lerp(from, goal, t, shown)
    Grids.cells(shown, cells)
})

More grid examples in the Lab →

Animation · Animate

Many shapes, one animation call

Moving dozens of shapes between layouts usually means one tween per shape and bookkeeping to start, stop and finish them together.

Pick Scatter, Shelf, Grid or Ring. Pick another while the boxes move: they head for the new layout from where they are.

demo.ts · lines 119–132Full source
const show = (layout: number, animate: boolean) => {
    // …
    const { order, targets } = targetsFor(layout)
    const shapes = order.map(i => boxes[i])
    // …
    animation = Animate.shape.morphAll(shapes, targets, duration, {
        stagger,
        easing: EasingFunctions.easeInOutCubic,
    })
}

17 more Animate examples in the Lab →

Also in 1.1

Smaller additions

  • Rectangles without overlapSeparate.boxes

    Separate.boxes moves overlapping rectangles apart, each pair horizontally or vertically, for example squares on a map in a Demers cartogram. The population map at the top does the same with circles.

  • Text extentlabel.extent

    label.extent is the box a label's text takes up as drawn. It updates when the text or the fonts change, so labels can be separated or decluttered by their real size. graphic.ready tells when the fonts are loaded.

  • Animation handlesRvgAnimation

    Every animation returns a handle: cancel it, check whether it is still running, or wait for it with done. Animate.shape.trace draws a line along a route, and the stagger option starts many shapes one after another.

  • Simplify

    Fewer points for long lines: lttb, minMax, douglasPeucker and envelope return the indices of the points to keep, so other data can be picked with the same indices.

  • Profiles beside routesOffsets.besideRoute

    A baseline beside a route and coordinates relative to it, for an elevation profile that runs next to a trail and moves with the map.

  • Polygon masksgroup.mask.polygon

    Masks take polygons as well as circles and boxes, for lenses of any shape or a highlight above a line.

  • Frame clockVisQuill.clock

    Stop real time and step the animations frame by frame, so each frame can be captured for a video at a steady rate.

  • Labels along curveslabelAlongCircle

    Labels along circles, arcs and polygons, upright and inside or outside the shape. All label functions take the same options object.

  • Circles and arcsSvg.get

    Arc and Circle are separate types now, and Svg.get returns an SVGCircleElement for a circle and an SVGPathElement for an arc.

Upgrading from 1.0

What changes for existing code

Most 1.0 code runs unchanged. The changes below need edits; deprecated names still work in 1.x.

npm install @visquill/visquill-gdk@^1.1.0

Breaking changes

What1.01.1
Points.mapToCirclemapToCircle(center, radius, result?)mapToCircle(point, center, radius, result?)
Values.modulusmodulus(-7.5, 2) → -1 (Integer); ÷ 0 → 0modulus(-7.5, 2) → -1.5 (Real); ÷ 0 → NaN
Circles passed to Arcs.*Arcs.pointAt(circle, …)Arcs.pointAt(Cast.toArc(circle), …)
arc.geometricType"Circle""Arc"
UMD file namedist/visquill.umd.jsdist/visquill.umd.cjs

Deprecated (still work in 1.x)

  • Offsets.convexOneSidedContour → Offsets.besideRoute: left now means left of the direction of travel, not left on screen.
  • text.label(text, oriented, angle, offset, autoFlip, style) → text.label(text, style, { … })
  • text.labelAt(text, anchor, oriented, angle, offset, autoFlip, style) → text.labelAt(text, anchor, style, { … })
  • text.labelAlongPolyline(text, polyline, offset, flip, style) → text.labelAlongPolyline(text, polyline, style, { … })
  • Reactive.skip → your own action in Reactive.do: an internal empty action; not needed in user code.

What’s new in detail, with code · Full list: changelog ↗