Skip to content

Home > d3-blueprint > D3Blueprint

D3Blueprint class

Base class for composable D3 charts. Subclass and override lifecycle hooks (initialize, transform, preDraw, postDraw, postTransition).

Signature:

typescript
export declare class D3Blueprint<TData = unknown>

Constructors

Constructor

Modifiers

Description

(constructor)(selection)

Constructs a new instance of the D3Blueprint class

Properties

Property

Modifiers

Type

Description

attached

readonly

Record<string, D3Blueprint<TData>>

Proxy that provides getter access to attached sub-charts by name.

base

protected

readonly

D3Selection

The root D3 selection this chart is attached to.

Methods

Method

Modifiers

Description

attach(name, chart)

Attaches a sub-chart instance that will be drawn alongside this chart (legacy).

attach(name, ChartClass, selection)

Creates and attaches a sub-chart from a class and selection.

config(name)

Gets a config value by name.

config(name, value)

Sets a config value by name.

config(values)

Sets multiple config values.

configDefine(name, options)

Defines a new config property.

destroy()

Tears down the chart, clearing layers and attachments.

draw(data)

Executes the full draw lifecycle.

initialize()

protected

Called once during construction. Override to set up layers and configs.

layer(name)

Retrieves an existing layer by name.

layer(name, selection, options)

Creates and registers a new layer.

off(event)

Removes an event listener. Pass null to remove.

on(event, listener)

Registers an event listener. Delegates to d3-dispatch.

postDraw(data)

protected

Called after all layers have drawn (but before transitions complete).

postTransition(data)

protected

Called after all transitions have completed.

preDraw(data)

protected

Called before layers are drawn.

transform(data)

protected

Called at the start of draw(). Return transformed data or undefined to keep original.

use(plugin, name)

Wires a plugin into this chart.

  1. Calls plugin.install(this) immediately 2. Hooks preDraw / postDraw / postTransition via namespaced events 3. Wraps destroy() to call plugin.destroy(this) before the original teardown