Skip to content

RESET

String constant used to reset an individual config property.

A sentinel string that any config value can be set to. config() treats it as “restore the default”, which matters because a chart keeps every setting it was ever given; passing undefined would leave the old value in place. It works at any depth, so shapeConfig: {fill: RESET} resets just the fill.

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

const viz = new Treemap().config({title: "Quarterly revenue", legend: false});

// Later: put both keys back to their defaults instead of guessing what they were.
viz.config({title: RESET, legend: RESET});

The same Legend instance is told to draw circles, then given RESET for that one key. Tick the box to watch the swatches return to the default rectangles while the data, colors, and size stay as configured.

import {Legend, RESET} from "@d3plus/core";

const data = [
  {id: "North", color: "#1c7ed6"},
  {id: "South", color: "#e67700"},
  {id: "East", color: "#2f9e44"},
];

const legend = new Legend()
  .select("#legend")
  .data(data)
  .shape("Circle")
  .render();

// The swatches go back to the default rectangles; nothing else changes.
legend.shape(RESET).render();

Parameters

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