Skip to content

stylize

Applies each key/value in an object as a style.

Applies every key of an object as an inline style on a d3 selection, one .style() call per entry, which is how a chart’s shapeConfig styles reach the drawn elements. Keys are CSS property names (stroke-width, not strokeWidth).

import {select} from "d3-selection";
import {stylize} from "@d3plus/dom";

stylize(select("rect"), {
  fill: "#1c7ed6",
  stroke: "#1864ab",
  "stroke-width": 3,
  opacity: 0.85,
});

Parameters

import {stylize} from "@d3plus/dom";
erequiredStylable

The d3 selection to apply styles to.

sRecordDefault {}

An object of key/value style pairs.