Icicle
Draws a hierarchy as nested rectangles, one band per groupBy level from
the root edge out, where each node’s breadth is proportional to its summed
value. Click a rectangle to zoom into it; click the root band (or Back) to
zoom out.
Basic example
Section titled “Basic example”Each groupBy level is a band of rectangles, from the root edge out. A rectangle’s breadth is proportional to its sum, so a parent spans exactly its children, and children inherit their top-level group’s color.
Defines the mapping between data and shape. The value can be a String matching a key in each data point (default is "id"), or an accessor Function that returns a unique value for each data point. Additionally, an Array of these values may be provided if the visualization supports nested hierarchies.
["parent", "id"]Accessor function or string key for the value each rectangle's breadth is proportional to. Parent rectangles sum their children.
Multi level
Section titled “Multi level”A three-level groupBy draws three bands. Each branch keeps its top-level color, a step lighter per level. Labels appear only where their whole words fit, upright or turned to run up a tall, narrow rectangle. Hover a rectangle to highlight it with its ancestors.
Defines the mapping between data and shape. The value can be a String matching a key in each data point (default is "id"), or an accessor Function that returns a unique value for each data point. Additionally, an Array of these values may be provided if the visualization supports nested hierarchies.
["area", "module", "file"]Vertical
Section titled “Vertical”orient: "vertical" puts the root on top, with each level below it. Narrow columns turn their labels to read upward.
Which way the levels run: "horizontal" (default) puts the root on the left with each level to its right; "vertical" puts the root on top with each level below it.
Drill down
Section titled “Drill down”Click a rectangle to zoom into it: it moves into the root band and its descendants fill the full breadth. Click the root band, or the Back button, to zoom out. With depth limiting the visible levels, zooming slides that window outward, so deeper levels come into view.
const codebase = [
{area: "Frontend", module: "Components", file: "Button", size: 120},
{area: "Frontend", module: "Components", file: "Modal", size: 240},
{area: "Frontend", module: "Components", file: "Table", size: 410},
{area: "Frontend", module: "Components", file: "Tooltip", size: 90},
{area: "Frontend", module: "Pages", file: "Dashboard", size: 520},
{area: "Frontend", module: "Pages", file: "Settings", size: 180},
{area: "Frontend", module: "Pages", file: "Profile", size: 140},
{area: "Frontend", module: "Styles", file: "Theme", size: 60},
{area: "Frontend", module: "Styles", file: "Layout", size: 45},
{area: "Backend", module: "API", file: "Users", size: 330},
{area: "Backend", module: "API", file: "Orders", size: 460},
{area: "Backend", module: "API", file: "Search", size: 210},
{area: "Backend", module: "Database", file: "Migrations", size: 380},
{area: "Backend", module: "Database", file: "Models", size: 290},
{area: "Backend", module: "Jobs", file: "Email", size: 70},
{area: "Backend", module: "Jobs", file: "Reports", size: 150},
{area: "Infrastructure", module: "CI", file: "Pipelines", size: 95},
{area: "Infrastructure", module: "CI", file: "Caching", size: 30},
{area: "Infrastructure", module: "Deploy", file: "Containers", size: 160},
{area: "Infrastructure", module: "Deploy", file: "Terraform", size: 210},
{area: "Docs", module: "Guides", file: "Getting Started", size: 85},
{area: "Docs", module: "Guides", file: "Theming", size: 40},
{area: "Docs", module: "Reference", file: "API Reference", size: 260},
];
const config = {
data: codebase,
groupBy: ["area", "module", "file"],
sum: "size",
depth: 1,
};
Small data threshold
Section titled “Small data threshold”threshold: 0.03 merges the files below 3% of the total within each module into one bucket labeled by thresholdName, keeping slivers from cluttering the last level. A module with only one such file keeps it as itself, and hovering a bucket lists the files it holds.
The threshold value for bucketing small data points together, as a share of the total. On a stacked Plot, the series whose summed value across every position is under that share of the whole chart's total merge into one series, stacked on top. A bucket needs at least two items, and its tooltips list them. Off (0) by default on Plot charts.
Shading
Section titled “Shading”shadeConfig sets how much each level lightens (step), up to max; shade: false draws every rectangle in its branch’s flat color. Shading applies only to the default colors, so a custom color or colorScale is drawn as given.
const codebase = [
{area: "Frontend", module: "Components", file: "Button", size: 120},
{area: "Frontend", module: "Components", file: "Modal", size: 240},
{area: "Frontend", module: "Components", file: "Table", size: 410},
{area: "Frontend", module: "Components", file: "Tooltip", size: 90},
{area: "Frontend", module: "Pages", file: "Dashboard", size: 520},
{area: "Frontend", module: "Pages", file: "Settings", size: 180},
{area: "Frontend", module: "Pages", file: "Profile", size: 140},
{area: "Frontend", module: "Styles", file: "Theme", size: 60},
{area: "Frontend", module: "Styles", file: "Layout", size: 45},
{area: "Backend", module: "API", file: "Users", size: 330},
{area: "Backend", module: "API", file: "Orders", size: 460},
{area: "Backend", module: "API", file: "Search", size: 210},
{area: "Backend", module: "Database", file: "Migrations", size: 380},
{area: "Backend", module: "Database", file: "Models", size: 290},
{area: "Backend", module: "Jobs", file: "Email", size: 70},
{area: "Backend", module: "Jobs", file: "Reports", size: 150},
{area: "Infrastructure", module: "CI", file: "Pipelines", size: 95},
{area: "Infrastructure", module: "CI", file: "Caching", size: 30},
{area: "Infrastructure", module: "Deploy", file: "Containers", size: 160},
{area: "Infrastructure", module: "Deploy", file: "Terraform", size: 210},
{area: "Docs", module: "Guides", file: "Getting Started", size: 85},
{area: "Docs", module: "Guides", file: "Theming", size: 40},
{area: "Docs", module: "Reference", file: "API Reference", size: 260},
];
const config = {
data: codebase,
groupBy: ["area", "module", "file"],
sum: "size",
shadeConfig: {step: 0.3, max: 0.5},
};
Small multiples
Section titled “Small multiples”facet: "area" draws one Icicle per area as small multiples, each laid out the way the whole chart is.
Splits the chart into small multiples: a grid of equally sized panels, one per distinct value of this data key or accessor, each drawing the chart for that value's rows. The panels share one legend, color scale, title, and timeline, color each series the same way, and hover, tooltips, and legend clicks apply across all of them. Pass false to draw a single chart. See facetConfig for the grid's layout and shared scales.
Configuration
import {Icicle} from "@d3plus/core";
Extends Viz.
activefalse|functionThe active callback function for highlighting shapes.
classNamestring|array.<string>|undefinedCSS classes added to the outermost element this chart or component draws into, next to its fixed d3plus classes, so page CSS can target it: a chart's root
<svg class="d3plus-viz">(its<canvas>with the Canvas renderer) and a standalone component's<svg>. Takes a space-separated string or an array. A new value replaces the classes the previous one added; unset adds none. Tooltips take their owntooltipConfig.className.colorDefaultscolordefaultsconfigOverrides the default colors used when assigning fills from data and choosing legible text colors:
darkandlight(the text colors picked for contrast against a background),missing(null/undefined values),on/off(true/falsevalues),sequential(the anchor hue for magnitude ramps), andscale(the categorical palette, given as a d3 ordinal scale or an array of colors). Keys are merged into the current defaults, and a Viz passes its overrides down to the shapes and components it draws.configd3plusconfigMethods that correspond to the key/value pairs and returns this class.
datastring|array.<datapoint>|objectThe primary data array used to draw the visualization. The value passed should be an Array of objects or a String representing a filepath or URL to be loaded. The following filetypes are supported:
csv,tsv,txt, andjson.If your data URL needs specific headers to be set, an Object with a "url" and "headers" (or any other
fetchrequest option) may also be passed. An Object with any other key is a data row, not a request.Additionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final array of obejcts to be used as the primary data array. For example, some JSON APIs return the headers split from the data values to save bandwidth. These would need be joined using a custom formatter.
If you would like to specify certain configuration options based on the yet-to-be-loaded data, you can also return a full
configobject from the data formatter (including the newdataarray as a key in the object).To re-fetch a URL on an interval and redraw when its data changes, set
dataPollingInterval; each poll runs the same formatter.Defaults to an empty array (
[]).facetstring|false|functionSplits the chart into small multiples: a grid of equally sized panels, one per distinct value of this data key or accessor, each drawing the chart for that value's rows. The panels share one legend, color scale, title, and timeline, color each series the same way, and hover, tooltips, and legend clicks apply across all of them. Pass
falseto draw a single chart. SeefacetConfigfor the grid's layout and shared scales.facetConfigfacetconfigConfiguration for small multiples (see
facet), merged into the current config: -columns/rows: the grid's shape. Chosen by default to make the panels as large as the chart's shape allows. -padding: the space between panels, in pixels (default20). -sort: panel order —"ascending"(default),"descending","data"(first appearance), a comparator over facet values, or an Array of values. -scales:"shared"(default) gives every panel of a chart with axes the same x/y domains;"independent"fits each panel to its own rows. Funnel defaults to"independent"(each panel sized to its own widest stage);"shared"sizes every panel against the widest stage across all panels. PolarArea and RadialBar default to"independent"(each panel's rings and ticks fit its own values);"shared"gives every panel the same value domain. -axes: with shared scales,"outer"(default) labels the axes only along the grid's left and bottom edges;"all"labels every panel. An object sets each axis on its own, as in{x: "all", y: "outer"}: every panel labels its x axis, only the left column labels its y axis, and the panels' plot areas line up. BumpChart defaults to"all", and Marimekko labels its categories on every panel and its 0–100% share axis only along the outer edge, even with independent scales. -title: a(value, data) => stringfunction for each panel's title, orfalseto hide panel titles. -titleConfig: TextBox config for the panel titles (fontSize,fontWeight,fontColor,textAnchor,padding, …).fontFamilystring|array.<string>The font family used throughout the visualization.
groupBystring|function|array.<string|function>Defines the mapping between data and shape. The value can be a String matching a key in each data point (default is "id"), or an accessor Function that returns a unique value for each data point. Additionally, an Array of these values may be provided if the visualization supports nested hierarchies.
highlightfalse|functionPersistently emphasizes the data points matching the given predicate: the matching marks keep their color while every other mark is de-emphasized to a neutral gray (the "emphasis" form — highlight one series, gray the rest). Unlike
hover/active(transient, opacity-based),highlightis a standing state that survives pointer movement. Passfalseto clear it.hoverfalse|functionThe hover callback function for highlighting shapes on mouseover.
legendboolean|functionDefaultrowLegendWhether to display the legend. By default, the legend shows when it has more than one entry and each entry stands for a single group (or two groups at most), or when the entries are colored by a category that isn't a
groupBylevel (seecolor), in which case each entry is labelled by its category. Passfalseto hide it,trueto always show it, or a(config, data) => booleanfunction to decide.legendSortfunctionDefaultpartitionLegendSortCustom sort comparator for legend items.
legendTooltiptooltipconfigDefault{tbody: []}Configuration object for the legend tooltip.
localestring|objectThe locale used for all text and number formatting. Supports the locales defined in d3plus-format. The locale can be a complex Object, a locale code (like "en-US"), or a 2-digit language code (like "en"). If a 2-digit code is provided, the "findLocale" function is used to identify the most approximate locale.
onstringEvent listener for the specified event typenames. Mirrors the core d3-selection behavior.
orient"horizontal"|"vertical"Default"horizontal"Which way the levels run:
"horizontal"(default) puts the root on the left with each level to its right;"vertical"puts the root on top with each level below it.parentunknownParent config used by the wrapper.
renderfunctionDraws the visualization given the specified configuration.
rendererboolean|"svg"|"canvas"Selects which @d3plus/render backend paints the visible output.
"svg"= SvgRenderer (default),"canvas"= CanvasRenderer. Boolean arguments both normalize to"svg".selectstring|htmlelementThe SVG container element as a d3 selector or DOM element. Defaults to
undefined.shadeunknownDefaulttrueLightens each level below the top one a step more than the level above it (see
shadeConfig), so the levels read apart while each branch keeps its top-level color. Applies only to the default colors: a customcolor,shapeConfig.fill, orcolorScaleis drawn as given. Labels keep their automatic contrast color.shadeConfig{step?: number, max?: number}Shading strengths, as
colorLighteramounts (0–1):steppergroupBylevel below the top level, up tomax, which keeps the deepest levels in their branch's hue.shapeConfigd3plusconfigConfiguration object with key/value pairs applied as method calls on each shape.
sortfunctionDefaultpartitionDefaultSortComparator for sibling rectangles, given two d3-hierarchy nodes. Defaults to descending by summed value, with any threshold bucket last.
sumstring|functionDefault"value"Accessor function or string key for the value each rectangle's breadth is proportional to. Parent rectangles sum their children.
thresholdnumber|functionThe threshold value for bucketing small data points together, as a share of the total. On a stacked Plot, the series whose summed value across every position is under that share of the whole chart's total merge into one series, stacked on top. A bucket needs at least two items, and its tooltips list them. Off (
0) by default on Plot charts.thresholdKeystring|functionAccessor for the value used in the threshold algorithm. A stacked Plot defaults to its stacked value.
timestring|false|functionAccessor function or string key for the time dimension of each data point.
timelineDefaultstring|date|array.<string|date>The starting time or range for the timeline. Can be a single Date/String, or an Array of 2 values representing the min and max.
tooltipConfigtooltipconfigDefault{tbody: [shareRow(viz, "sum")]}Configuration for the tooltip component.
totalstring|boolean|functionAccessor function or string key for the total value displayed in the visualization.
translatefunctionDefines how informational text strings should be displayed. By default, this function will try to find the string in question (which is the first argument provided to this function) inside of an internally managed translation Object. If you'd like to override to use custom text, simply pass this method your own custom formatting function.