@d3plus/data v3.0.0-alpha.3
@d3plus/data
JavaScript data loading, manipulation, and analysis functions.
Installing
If using npm, npm install @d3plus/data
. Otherwise, you can download the latest release from GitHub or load from a CDN.
import modules from "@d3plus/data";
In vanilla JavaScript, a d3plus
global is exported from the pre-bundled version:
<script src="https://cdn.jsdelivr.net/npm/@d3plus/data@3.0.0-alpha.3"></script>
<script>
console.log(d3plus);
</script>
Examples
Live examples can be found on d3plus.org, which includes a collection of example visualizations using @d3plus/react.
API Reference
- isData - 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.
- dataConcat - 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.
- dataFold - Given a JSON object where the data values and headers have been split into separate key lookups, this function will combine the data values with the headers and returns one large array of objects.
- isData - Returns true/false whether the argument provided to the function should be loaded using an internal XHR request. Valid data can either be a string URL or an Object with "url" and "headers" keys.
- dataLoad - Loads data from a filepath or URL, converts it to a valid JSON object, and returns it to a callback function.
- merge - Combines an Array of Objects together and returns a new Object.
- unique - ES5 implementation to reduce an Array of values to unique instances.
d3plus.isData(data, data, data) <>
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.
This is a global function
d3plus.dataConcat(arrayOfArray, data) <>
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.
This is a global function
d3plus.dataFold(json, data, headers) <>
Given a JSON object where the data values and headers have been split into separate key lookups, this function will combine the data values with the headers and returns one large array of objects.
This is a global function
d3plus.isData(dataItem) <>
Returns true/false whether the argument provided to the function should be loaded using an internal XHR request. Valid data can either be a string URL or an Object with "url" and "headers" keys.
This is a global function
d3plus.dataLoad(path, formatter, key, callback) <>
Loads data from a filepath or URL, converts it to a valid JSON object, and returns it to a callback function.
This is a global function
d3plus.merge(objects, aggs) <>
Combines an Array of Objects together and returns a new Object.
This is a global function this
merge([
{id: "foo", group: "A", value: 10, links: [1, 2]},
{id: "bar", group: "A", value: 20, links: [1, 3]}
]);
returns this
{id: ["bar", "foo"], group: "A", value: 30, links: [1, 2, 3]}
d3plus.unique(arr, accessor) <>
ES5 implementation to reduce an Array of values to unique instances.
This is a global function this
unique(["apple", "banana", "apple"]);
returns this
["apple", "banana"]
4 months ago
7 months ago
7 months ago
7 months ago