Skip to content

Frameworks

The d3plus engine (@d3plus/core) is imperative: you create an instance, configure it, and render it. Official wrapper packages fit that lifecycle into the major front-end frameworks, so you pass a declarative config and the wrapper handles instantiation, updates, and teardown for you.

Framework Package Render with
React @d3plus/react <Treemap config={…} />
Vue 3 @d3plus/vue <Treemap :config="…" />
Svelte @d3plus/svelte <div use:d3plus={{constructor, config}} />
Web Components @d3plus/element <d3plus-treemap> (.config = …)
Angular @d3plus/angular <d3plus-viz [viz]="Treemap" [config]="…" />

Every wrapper is a thin layer over the same shared core (in @d3plus/dom), so their runtime behavior is identical.

Pick a framework below. Every example on this site has the same panel, so you can copy any chart in the framework you use; your choice is remembered across pages.

import {Treemap} from "@d3plus/core";

// Renders into <div id="chart" style="height: 300px"></div>
const config = {
  data: [
    {parent: "Group 1", id: "alpha", value: 29},
    {parent: "Group 1", id: "beta", value: 10},
    {parent: "Group 2", id: "gamma", value: 18},
  ],
  groupBy: ["parent", "id"],
  sum: "value",
};

new Treemap()
  .select("#chart")
  .config(config)
  .render();
Terminal window
npm install @d3plus/core

Each wrapper has a way to supply defaults merged ahead of every chart’s own config:

Merge your defaults into each config yourself, for example with assign from @d3plus/dom:

import {assign} from "@d3plus/dom";
const defaults = {locale: "es-ES"};
new Treemap().config(assign({}, defaults, config)).render();

Because all wrappers delegate to the same core, they behave identically:

  • Tweening across updates. The underlying instance is reused when the config changes, so the chart animates between states instead of restarting.
  • Structural diffing. Assigning a config that is structurally identical to the current one (including function-valued accessors, compared by source) is a no-op: no re-render. Set forceUpdate to render on every update regardless.
  • Callbacks. A callback runs at the end of each render cycle.
  • Teardown. The instance is destroyed automatically when the component unmounts (or the element disconnects).
Wrapper Config Global defaults Force re-render
React config prop D3plusContext.Provider forceUpdate prop
Vue config prop provide(D3plusConfigKey, …) forceUpdate prop
Svelte action param globalConfig param forceUpdate param
Web Components .config property setGlobalConfig() .forceUpdate property
Angular config input globalConfig input forceUpdate input