If you use npm, install with
npm install @saehrimnir/druidjs, and use it with
DruidJS uses internally the Matrix class for storing data. You can use it by creating a
druid.Matrix object for instance with the function
from, in example:
;let data = ... ... ...;let matrix = druidMatrix;
You can create a
druid.Matrix object programmatically by:
let row == col ? 1 : 0;let matrix = rows columns fn;
rows == columns, then
matrix would be a identity matrix.
A shortcut for a identity matrix is:
let matrix = rows columns "I";// orlet matrix = rows columnbs "identity";
There are more shortcuts for creating matrices:
let matrix = 3 3 "zeros"; // matrix would be a 3x3 matrix with zeroeslet matrix = 3 3 "center"; // matrix would be a 3x3 center matrix;let number = 12;let matrix = 3 3 number; // matrix would b a 3x3 matrix filled with 'number'
If you want to use a
druid.Matrix object, for instance, with d3, you can use either the
to2dArray property, the
iterate_rows generator function, or just use the
druid.Matrix object as an iterable (works with d3 since version 6).
let data = await d3;let matrix = druidMatrix;d3datamatrixto2dArray//...d3datamatrix//...d3datamatrix//...