@uwdata/mosaic-plot 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mosaic-plot.js +10556 -19300
- package/dist/mosaic-plot.min.js +19 -28
- package/package.json +7 -7
- package/src/interactors/Highlight.js +1 -1
- package/src/interactors/Interval1D.js +2 -2
- package/src/interactors/Interval2D.js +2 -2
- package/src/interactors/Nearest.js +11 -7
- package/src/interactors/PanZoom.js +2 -2
- package/src/interactors/Toggle.js +2 -2
- package/src/legend.js +7 -2
- package/src/marks/ConnectedMark.js +1 -1
- package/src/marks/Density1DMark.js +1 -1
- package/src/marks/ErrorBarMark.js +1 -1
- package/src/marks/Grid2DMark.js +1 -1
- package/src/marks/HexbinMark.js +39 -49
- package/src/marks/Mark.js +1 -2
- package/src/marks/RegressionMark.js +2 -2
- package/src/marks/util/stats.js +1 -1
- package/src/plot-attributes.js +1 -0
- package/src/plot.js +15 -3
- package/src/transforms/bin-step.js +43 -0
- package/src/transforms/bin.js +37 -47
- package/src/transforms/time-interval.js +53 -0
- package/src/marks/util/to-data-columns.js +0 -71
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { convertArrowColumn, isArrowTable } from '@uwdata/mosaic-core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {Array | Int8Array | Uint8Array | Uint8ClampedArray
|
|
5
|
-
* | Int16Array | Uint16Array | Int32Array | Uint32Array
|
|
6
|
-
* | Float32Array | Float64Array
|
|
7
|
-
* } Arrayish - an Array or TypedArray
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {
|
|
12
|
-
* | { numRows: number, columns: Record<string,Arrayish> }
|
|
13
|
-
* | { numRows: number, values: Arrayish; }
|
|
14
|
-
* } DataColumns
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Convert input data to a set of column arrays.
|
|
19
|
-
* @param {any} data The input data.
|
|
20
|
-
* @returns {DataColumns} An object with named column arrays.
|
|
21
|
-
*/
|
|
22
|
-
export function toDataColumns(data) {
|
|
23
|
-
return isArrowTable(data)
|
|
24
|
-
? arrowToColumns(data)
|
|
25
|
-
: arrayToColumns(data);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Convert an Arrow table to a set of column arrays.
|
|
30
|
-
* @param {import('apache-arrow').Table} data An Apache Arrow Table.
|
|
31
|
-
* @returns {DataColumns} An object with named column arrays.
|
|
32
|
-
*/
|
|
33
|
-
function arrowToColumns(data) {
|
|
34
|
-
const { numRows, numCols, schema: { fields } } = data;
|
|
35
|
-
const columns = {};
|
|
36
|
-
|
|
37
|
-
for (let col = 0; col < numCols; ++col) {
|
|
38
|
-
const name = fields[col].name;
|
|
39
|
-
if (columns[name]) {
|
|
40
|
-
console.warn(`Redundant column name "${name}". Skipping...`);
|
|
41
|
-
} else {
|
|
42
|
-
columns[name] = convertArrowColumn(data.getChildAt(col));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return { numRows, columns };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Convert an array of values to a set of column arrays.
|
|
51
|
-
* If the array values are objects, build out named columns.
|
|
52
|
-
* We use the keys of the first object as the column names.
|
|
53
|
-
* Otherwise, use a special "values" array.
|
|
54
|
-
* @param {object[]} data An array of data objects.
|
|
55
|
-
* @returns {DataColumns} An object with named column arrays.
|
|
56
|
-
*/
|
|
57
|
-
function arrayToColumns(data) {
|
|
58
|
-
const numRows = data.length;
|
|
59
|
-
if (typeof data[0] === 'object') {
|
|
60
|
-
const names = numRows ? Object.keys(data[0]) : [];
|
|
61
|
-
const columns = {};
|
|
62
|
-
if (names.length > 0) {
|
|
63
|
-
names.forEach(name => {
|
|
64
|
-
columns[name] = data.map(d => d[name]);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return { numRows, columns };
|
|
68
|
-
} else {
|
|
69
|
-
return { numRows, values: data };
|
|
70
|
-
}
|
|
71
|
-
}
|