configPrep
Preps a config object for d3plus data, and optionally bubbles up a specific nested type. When using this function, you must bind a d3plus class’ this context.
Basic example
Section titled “Basic example”Prepares a shapeConfig for the shapes a chart draws: it copies in the chart’s duration, keeps only the events that are global (mouseenter) or namespaced to the requested type (click.shape, not click.legend), and wraps every accessor so that when a shape hands it a wrapped datum, the function receives the original data row underneath. Charts call it with this bound; a plain object with a schema works the same way here.
import {configPrep} from "@d3plus/core";
const config = { fill: d => d.color, on: {"click.shape": onShapeClick, mouseenter: onEnter, "click.legend": onLegendClick},};
// Bound to a chart (`this`), for the "shape" event namespace:const prepped = configPrep.call(viz, config, "shape");Object.keys(prepped); // ["duration","on","fill"]prepped.duration; // 600Object.keys(prepped.on); // ["click.shape","mouseenter"]prepped.fill({__d3plus__: true, data: {color: "#c92a2a"}, i: 0}); // "#c92a2a"Parameters
import {configPrep} from "@d3plus/core";
thisrequiredConfigPrepHostconfigConfigObjectDefault...The configuration object to parse.
typestringDefaultshapeThe event classifier to user for "on" events. For example, the default event type of "shape" will apply all events in the "on" config object with that key, like "click.shape" and "mouseleave.shape", in addition to any gloval events like "click" and "mouseleave".
neststring|falseDefaultfalseAn optional nested key to bubble up to the parent config level.