Skip to content

addToQueue

Adds the provided value to the internal queue to be loaded, if necessary. This is used internally in new d3plus visualizations that fold in additional data sources, like the nodes and links of Network or the topojson of Geomap.

Charts call this for every data-like config (data, nodes, links, topojson): a value that must be fetched is queued as a [load, paths, formatter, key] entry to run before the next draw, while an inline array is stored under key right away. Queuing the same key twice replaces the earlier entry.

import {addToQueue} from "@d3plus/data";

const ctx = {_queue: [], schema: {}};

addToQueue.call(ctx, "/data/fruits.csv", undefined, "nodes");
ctx._queue.length;
ctx.schema.nodes;

addToQueue.call(ctx, [{id: "a"}, {id: "b"}], undefined, "nodes");
ctx.schema.nodes;

Parameters

import {addToQueue} from "@d3plus/data";
thisrequiredVizContext
_requiredstring | Array.<DataPoint> | Record
frequiredDataFormatter | undefined

Optional formatter function applied to the loaded data.

keyrequiredstring

The property name on the instance to store the loaded data.