concat
Reduce and concat all the elements included in arrayOfArrays if they are arrays. If it is a JSON object try to concat the array under given key data. If the key doesn’t exists in object item, a warning message is lauched to the console. You need to implement DataFormat callback to concat the arrays manually.
Basic example
Section titled “Basic example”Flattens an array of arrays into one array of rows, in order. This is what a chart does when its data config lists several sources.
import {concat} from "@d3plus/data";
concat([[{id: 1}], [{id: 2}, {id: 3}]]);
Custom key
Section titled “Custom key”The second argument names the property to read when a response nests its rows under something other than data.
import {concat} from "@d3plus/data";
concat([{rows: [{id: 1}]}, {rows: [{id: 2}]}], "rows");
Objects with data key
Section titled “Objects with data key”An element can also be an object whose data property holds the rows, the shape many APIs respond with, and the two forms can be mixed in one call.
import {concat} from "@d3plus/data";
concat([{data: [{id: 1}]}, [{id: 2}], {data: [{id: 3}]}]);
Parameters
import {concat} from "@d3plus/data";
arrayOfArraysrequiredArray.<Array.<DataPoint>|Record>Array of elements
datastringDefaultdataThe key in each element that contains the sub-array to concatenate.