Skip to content

applyConfig

Merges the supplied config objects over a fresh {select: node} target and applies the result via instance.config(). Shared by every d3plus framework wrapper.

What every framework wrapper does with the props it receives: merge the config objects left to right (later ones win, undefined entries are skipped) over {select: container}, then hand the result to the instance’s config().

import {applyConfig} from "@d3plus/dom";
applyConfig(viz, container, {width: 300, title: "Default title"}, undefined, {width: 400, legend: false});
// viz.config({select: container, width: 400, title: "Default title", legend: false})

dataFormat, linksFormat, nodesFormat, and topojsonFormat are config keys like any other, so they go through config() with the rest.

import {applyConfig} from "@d3plus/dom";
applyConfig(viz, container, {data: "/data/fruits.csv", dataFormat: rows => rows.slice(0, 3), groupBy: "name"});
// viz.config({select: container, data: "/data/fruits.csv", dataFormat: rows => rows.slice(0, 3), groupBy: "name"})

Parameters

import {applyConfig} from "@d3plus/dom";
instancerequiredD3plusInstance

A d3plus class instance.

noderequiredElement

The DOM element the visualization renders into (its select).

configsrequiredArray.<Record | undefined>

One or more config objects, merged left-to-right (later objects win); undefined/null entries are ignored.