mascot-vis 3.0.0 → 3.0.1
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/package.json +1 -2
- package/js/depGraphVis.js +0 -66
- package/src-new-ts/action/createElement.ts +0 -91
- package/src-new-ts/action/encode.js +0 -20
- package/src-new-ts/action/repeat.js +0 -128
- package/src-new-ts/action/traverseScene.js +0 -41
- package/src-new-ts/data/Network.js +0 -2
- package/src-new-ts/data/Scope.js +0 -135
- package/src-new-ts/data/Table.js +0 -263
- package/src-new-ts/data/Tree.js +0 -3
- package/src-new-ts/data/field.ts +0 -115
- package/src-new-ts/data/import.ts +0 -96
- package/src-new-ts/data/predicate.ts +0 -82
- package/src-new-ts/depgraph/DepGraph.js +0 -178
- package/src-new-ts/depgraph/Edge.js +0 -9
- package/src-new-ts/depgraph/SceneGraph2DepGraph.js +0 -110
- package/src-new-ts/depgraph/Signal.js +0 -12
- package/src-new-ts/depgraph/operator/BoundsEvaluator.js +0 -30
- package/src-new-ts/depgraph/operator/Dataflow.js +0 -41
- package/src-new-ts/depgraph/operator/DomainBuilder.js +0 -50
- package/src-new-ts/depgraph/updateDepGraph.js +0 -45
- package/src-new-ts/depgraph/variable/BoundsVar.js +0 -81
- package/src-new-ts/depgraph/variable/ChannelVar.js +0 -17
- package/src-new-ts/depgraph/variable/DataScopeVar.js +0 -12
- package/src-new-ts/depgraph/variable/DomainVar.js +0 -15
- package/src-new-ts/depgraph/variable/FieldVar.js +0 -17
- package/src-new-ts/depgraph/variable/LayoutParameter.js +0 -8
- package/src-new-ts/depgraph/variable/ScaleVar.js +0 -13
- package/src-new-ts/depgraph/variable/Variable.js +0 -39
- package/src-new-ts/element/gradient/LinearGradient.js +0 -37
- package/src-new-ts/element/group/Collection.js +0 -109
- package/src-new-ts/element/group/Group.js +0 -307
- package/src-new-ts/element/group/Scene.js +0 -98
- package/src-new-ts/element/mark/CircleMark.ts +0 -85
- package/src-new-ts/element/mark/Mark.ts +0 -233
- package/src-new-ts/element/mark/PathMark.js +0 -483
- package/src-new-ts/element/mark/Segment.js +0 -29
- package/src-new-ts/element/mark/Vertex.js +0 -118
- package/src-new-ts/encode/Scale.ts +0 -115
- package/src-new-ts/index.ts +0 -19
- package/src-new-ts/layout/Layout.ts +0 -3
- package/src-new-ts/render/CanvasRenderer.ts +0 -24
- package/src-new-ts/render/SVGRenderer.js +0 -316
- package/src-new-ts/util.ts +0 -3
- package/src-old/action/Classify.js +0 -53
- package/src-old/action/Densify.js +0 -199
- package/src-old/action/Partition.js +0 -531
- package/src-old/action/Repeat.js +0 -106
- package/src-old/action/Repopulate.js +0 -44
- package/src-old/action/Stratify.js +0 -156
- package/src-old/basic/Gradient.js +0 -37
- package/src-old/basic/Point.js +0 -51
- package/src-old/basic/Rectangle.js +0 -63
- package/src-old/bind/bindToAngle.js +0 -56
- package/src-old/bind/bindToAreaMark.js +0 -360
- package/src-old/bind/bindToColor.js +0 -114
- package/src-old/bind/bindToLink.js +0 -81
- package/src-old/bind/bindToPosition.js +0 -283
- package/src-old/bind/bindToRadialDistance.js +0 -62
- package/src-old/bind/bindToSize.js +0 -235
- package/src-old/bind/bindToText.js +0 -60
- package/src-old/bind/bindToThickness.js +0 -100
- package/src-old/constraint/AffixConstraint.js +0 -129
- package/src-old/constraint/AlignConstraint.js +0 -58
- package/src-old/core/Encoding.js +0 -336
- package/src-old/core/Scale.js +0 -322
- package/src-old/core/SceneLoader.js +0 -290
- package/src-old/core/SceneValidator.js +0 -232
- package/src-old/core/SpecExecutor.js +0 -113
- package/src-old/core/SpecGenerator.js +0 -350
- package/src-old/data/DataImporter.js +0 -64
- package/src-old/data/DataScope.js +0 -124
- package/src-old/data/DataTable.js +0 -338
- package/src-old/data/Network.js +0 -106
- package/src-old/data/Tree.js +0 -251
- package/src-old/data/transform/Bin.js +0 -46
- package/src-old/data/transform/Filter.js +0 -48
- package/src-old/data/transform/Groupby.js +0 -18
- package/src-old/data/transform/KDE.js +0 -58
- package/src-old/data/transform/Sort.js +0 -14
- package/src-old/data/transform/Split.js +0 -5
- package/src-old/data/transform/partition.js +0 -46
- package/src-old/history/UndoRedoStack +0 -0
- package/src-old/index.js +0 -271
- package/src-old/indexSVG.js +0 -259
- package/src-old/interaction/Interaction.js +0 -91
- package/src-old/interaction/MouseEvent.js +0 -8
- package/src-old/interaction/Selection.js +0 -9
- package/src-old/interaction/brush.js +0 -362
- package/src-old/item/Segment.js +0 -29
- package/src-old/item/Vertex.js +0 -118
- package/src-old/item/composite/Collection.js +0 -106
- package/src-old/item/composite/Glyph.js +0 -19
- package/src-old/item/composite/Group.js +0 -310
- package/src-old/item/composite/Scene.js +0 -1251
- package/src-old/item/mark/ArcPath.js +0 -181
- package/src-old/item/mark/AreaPath.js +0 -78
- package/src-old/item/mark/CirclePath.js +0 -102
- package/src-old/item/mark/EllipsePath.js +0 -5
- package/src-old/item/mark/Image.js +0 -101
- package/src-old/item/mark/LinkPath.js +0 -118
- package/src-old/item/mark/Mark.js +0 -163
- package/src-old/item/mark/Path.js +0 -494
- package/src-old/item/mark/PointText.js +0 -201
- package/src-old/item/mark/PolygonPath.js +0 -64
- package/src-old/item/mark/RectPath.js +0 -88
- package/src-old/item/mark/RingPath.js +0 -92
- package/src-old/item/refs/Axis.js +0 -362
- package/src-old/item/refs/EncodingAxis.js +0 -515
- package/src-old/item/refs/Gridlines.js +0 -144
- package/src-old/item/refs/LayoutAxis.js +0 -316
- package/src-old/item/refs/Legend.js +0 -273
- package/src-old/layout/Circular.js +0 -95
- package/src-old/layout/Force.js +0 -52
- package/src-old/layout/Grid.js +0 -423
- package/src-old/layout/Layout.js +0 -13
- package/src-old/layout/Packing.js +0 -56
- package/src-old/layout/Stack.js +0 -264
- package/src-old/layout/Strata.js +0 -88
- package/src-old/layout/Sugiyama.js +0 -59
- package/src-old/layout/TidyTree.js +0 -105
- package/src-old/layout/Treemap.js +0 -87
- package/src-old/renderer/SVGInteractionHandler.js +0 -241
- package/src-old/renderer/SVGRenderer.js +0 -325
- package/src-old/renderer/WebGLRenderer.js +0 -1097
- package/src-old/renderer/WebGLRenderer2.js +0 -249
- package/src-old/renderer/threejs/Line2.js +0 -18
- package/src-old/renderer/threejs/LineGeometry.js +0 -77
- package/src-old/renderer/threejs/LineMaterial.js +0 -605
- package/src-old/renderer/threejs/LineSegments2.js +0 -281
- package/src-old/renderer/threejs/LineSegmentsGeometry.js +0 -226
- package/src-old/renderer/threejs/Wireframe.js +0 -51
- package/src-old/renderer/threejs/WireframeGeometry2.js +0 -16
- package/src-old/scale/areaSize.js +0 -0
- package/src-old/scale/domain.js +0 -38
- package/src-old/util/Constants.js +0 -180
- package/src-old/util/DataUtil.js +0 -35
- package/src-old/util/ItemUtil.js +0 -586
- package/src-old/util/Numerical.js +0 -33
- package/tests/demo-tests/README.md +0 -80
- package/tests/demo-tests/SVG2PNG.js +0 -56
- package/tests/demo-tests/demos2CanvasPNGs.js +0 -69
- package/tests/demo-tests/demos2ScenesSVGs.js +0 -100
- package/tests/demo-tests/pathElementWorker.js +0 -91
- package/tests/demo-tests/pixelTest.js +0 -62
- package/tests/demo-tests/renderDemos.html +0 -132
- package/tests/demo-tests/serializationTest.js +0 -36
- package/tests/demo-tests/serializeDemos.html +0 -134
- package/tests/unit-tests/README.md +0 -4
- package/tests/unit-tests/jasmine-browser.json +0 -21
- package/tests/unit-tests/jasmine.json +0 -14
- package/tests/unit-tests/testSpec.js +0 -274
package/src-old/data/Tree.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { atlas_rowId, nodeId } from "../util/Constants";
|
|
2
|
-
import DataScope from "./DataScope";
|
|
3
|
-
import DataTable from "./DataTable";
|
|
4
|
-
|
|
5
|
-
const depth = "_depth";
|
|
6
|
-
|
|
7
|
-
export default class Tree {
|
|
8
|
-
|
|
9
|
-
constructor(data, name) {
|
|
10
|
-
this._type = "tree";
|
|
11
|
-
let nodeArr = [];
|
|
12
|
-
let linkArr = [];
|
|
13
|
-
|
|
14
|
-
this._nodeHash = {};
|
|
15
|
-
|
|
16
|
-
this._traverse(data, nodeArr, linkArr);
|
|
17
|
-
|
|
18
|
-
this._nodeTable = new DataTable(nodeArr, "nodes");
|
|
19
|
-
this._linkTable = new DataTable(linkArr, "links");
|
|
20
|
-
|
|
21
|
-
this._nodeTable.tree = this;
|
|
22
|
-
this._linkTable.tree = this;
|
|
23
|
-
this._data = data;
|
|
24
|
-
//this.aggregateFromLeaves("value", "average");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get type() {
|
|
28
|
-
return this._type;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
_traverse(data, nodes, links, d = 0) {
|
|
32
|
-
let node = {};
|
|
33
|
-
if (!(nodeId in data))
|
|
34
|
-
data[nodeId] = "n" + nodes.length;
|
|
35
|
-
nodes.push(node);
|
|
36
|
-
data[depth] = d;
|
|
37
|
-
|
|
38
|
-
for (let k in data) {
|
|
39
|
-
if (k == "children" && data[k] && data[k].length > 0) {
|
|
40
|
-
for (let c of data[k]) {
|
|
41
|
-
let id = this._traverse(c, nodes, links, d + 1);
|
|
42
|
-
links.push({
|
|
43
|
-
parent: data[nodeId],
|
|
44
|
-
child: id
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
} else
|
|
48
|
-
node[k] = data[k];
|
|
49
|
-
}
|
|
50
|
-
this._nodeHash[node[nodeId]] = node;
|
|
51
|
-
return node[nodeId];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getParent(node) {
|
|
55
|
-
let id = node[nodeId];
|
|
56
|
-
let parentId;
|
|
57
|
-
let links = this._linkTable["data"]
|
|
58
|
-
let nodes = this._nodeTable["data"];
|
|
59
|
-
|
|
60
|
-
for (let i in links) {
|
|
61
|
-
if (links[i]["child"] == id) {
|
|
62
|
-
parentId = links[i]["parent"];
|
|
63
|
-
let index = nodes.findIndex(x => x[nodeId] == parentId);
|
|
64
|
-
return nodes[index];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
getChildren(node) {
|
|
70
|
-
let id = node[nodeId];
|
|
71
|
-
let children = [];
|
|
72
|
-
let links = this._linkTable["data"]
|
|
73
|
-
let nodes = this._nodeTable["data"];
|
|
74
|
-
for (let i in links) {
|
|
75
|
-
if (links[i]["parent"] == id) {
|
|
76
|
-
let childId = links[i]["child"];
|
|
77
|
-
let index = nodes.findIndex(x => x[nodeId] == childId);
|
|
78
|
-
children.push(nodes[index]);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return children;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
getNodeDataScope(node) {
|
|
85
|
-
let ds = new DataScope(this._nodeTable);
|
|
86
|
-
return ds.cross(atlas_rowId, node[atlas_rowId]);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
getMaxDepth() {
|
|
90
|
-
return this._nodeTable["_fieldSummaries"][depth]["max"];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
getRoot() {
|
|
94
|
-
let nodes = this._nodeTable["data"];
|
|
95
|
-
return nodes[0]; // Due to recursive appending of nodes, last one is root
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get nodeTable() {
|
|
99
|
-
return this._nodeTable;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
get linkTable() {
|
|
103
|
-
return this._linkTable;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
getNode(id) {
|
|
107
|
-
return this._nodeTable["data"].filter(d => d[nodeId] == id)[0];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
sumLeaves(root, attr) {
|
|
111
|
-
if (!root) return 0;
|
|
112
|
-
let id = root[nodeId];
|
|
113
|
-
let children = []
|
|
114
|
-
children = this.getChildren(root);
|
|
115
|
-
|
|
116
|
-
if (children && children.length > 0) {
|
|
117
|
-
let sum = 0;
|
|
118
|
-
for (let child of children) {
|
|
119
|
-
sum += this.sumLeaves(child, attr);
|
|
120
|
-
}
|
|
121
|
-
this.getNode(id)["sum" + attr] = sum;
|
|
122
|
-
|
|
123
|
-
} else this.getNode(id)["sum" + attr] = root[attr];
|
|
124
|
-
return root["sum" + attr];
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
countLeaves(root, attr) {
|
|
129
|
-
if (!root) return 0;
|
|
130
|
-
let id = root[nodeId];
|
|
131
|
-
let children = []
|
|
132
|
-
children = this.getChildren(root);
|
|
133
|
-
let count = 0;
|
|
134
|
-
if (children && children.length > 0) {
|
|
135
|
-
for (let child of children) {
|
|
136
|
-
count += this.countLeaves(child, attr);
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
count = 1
|
|
140
|
-
}
|
|
141
|
-
this.getNode(id)["count" + attr] = count;
|
|
142
|
-
return root["count" + attr];
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
averageLeaves(root, attr) {
|
|
147
|
-
if (!root) return 0;
|
|
148
|
-
let id = root[nodeId];
|
|
149
|
-
let children = []
|
|
150
|
-
children = this.getChildren(root);
|
|
151
|
-
let sum = 0;
|
|
152
|
-
if (children && children.length > 0) {
|
|
153
|
-
for (let child of children) {
|
|
154
|
-
sum += this.averageLeaves(child, attr);
|
|
155
|
-
}
|
|
156
|
-
sum /= children.length;
|
|
157
|
-
// this.getNode(id)["median" + attr]
|
|
158
|
-
this.getNode(id)["average" + attr] = sum;
|
|
159
|
-
} else this.getNode(id)["average" + attr] = root[attr];
|
|
160
|
-
return root["average" + attr];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
medianLeaves(root, attr) {
|
|
164
|
-
if (!root) return 0;
|
|
165
|
-
let id = root[nodeId];
|
|
166
|
-
let children = []
|
|
167
|
-
children = this.getChildren(root);
|
|
168
|
-
let medianArr = [];
|
|
169
|
-
if (children && children.length > 0) {
|
|
170
|
-
for (let child of children) {
|
|
171
|
-
medianArr.push(this.medianLeaves(child, attr));
|
|
172
|
-
}
|
|
173
|
-
medianArr.sort(function (a, b) {
|
|
174
|
-
return a - b;
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
let mid = Math.floor(medianArr.length / 2);
|
|
178
|
-
|
|
179
|
-
if (medianArr.length % 2)
|
|
180
|
-
this.getNode(id)["median" + attr] = medianArr[mid];
|
|
181
|
-
else
|
|
182
|
-
this.getNode(id)["median" + attr] = (medianArr[mid - 1] + medianArr[mid]) / 2.0;
|
|
183
|
-
} else this.getNode(id)["median" + attr] = root[attr];
|
|
184
|
-
return root["median" + attr];
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
maxLeaves(root, attr) {
|
|
189
|
-
if (!root) return 0;
|
|
190
|
-
let id = root[nodeId];
|
|
191
|
-
let children = []
|
|
192
|
-
children = this.getChildren(root);
|
|
193
|
-
let Arr = [];
|
|
194
|
-
if (children && children.length > 0) {
|
|
195
|
-
for (let child of children) {
|
|
196
|
-
Arr.push(this.maxLeaves(child, attr));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
this.getNode(id)["max" + attr] = Math.max(...Arr);
|
|
200
|
-
} else this.getNode(id)["max" + attr] = root[attr];
|
|
201
|
-
|
|
202
|
-
return root["max" + attr];
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
minLeaves(root, attr) {
|
|
206
|
-
if (!root) return 0;
|
|
207
|
-
let id = root[nodeId];
|
|
208
|
-
let children = []
|
|
209
|
-
children = this.getChildren(root);
|
|
210
|
-
let Arr = [];
|
|
211
|
-
if (children && children.length > 0) {
|
|
212
|
-
for (let child of children) {
|
|
213
|
-
Arr.push(this.minLeaves(child, attr));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
this.getNode(id)["min" + attr] = Math.min(...Arr);
|
|
217
|
-
} else this.getNode(id)["min" + attr] = root[attr];
|
|
218
|
-
return root["min" + attr];
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
aggregateFromLeaves(attr, aggregator) {
|
|
223
|
-
let root = this.getRoot()
|
|
224
|
-
switch (aggregator) {
|
|
225
|
-
|
|
226
|
-
case "sum":
|
|
227
|
-
this.sumLeaves(root, attr);
|
|
228
|
-
break;
|
|
229
|
-
|
|
230
|
-
case "count":
|
|
231
|
-
this.countLeaves(root, attr);
|
|
232
|
-
break;
|
|
233
|
-
|
|
234
|
-
case "average":
|
|
235
|
-
this.averageLeaves(root, attr);
|
|
236
|
-
break;
|
|
237
|
-
|
|
238
|
-
case "median":
|
|
239
|
-
this.medianLeaves(root, attr);
|
|
240
|
-
break;
|
|
241
|
-
|
|
242
|
-
case "max":
|
|
243
|
-
this.maxLeaves(root, attr);
|
|
244
|
-
break;
|
|
245
|
-
|
|
246
|
-
case "min":
|
|
247
|
-
this.minLeaves(root, attr);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import * as d3 from "d3";
|
|
2
|
-
import { DataType } from "../../util/Constants";
|
|
3
|
-
import DataTable from "../DataTable";
|
|
4
|
-
|
|
5
|
-
export default function bin(table, fields, args) {
|
|
6
|
-
//right now only handles one field
|
|
7
|
-
let f = fields[0];
|
|
8
|
-
//TODO: check that can perform kde on f
|
|
9
|
-
let gf = table.nonNumericFields;
|
|
10
|
-
|
|
11
|
-
//construct groups
|
|
12
|
-
let g = {};
|
|
13
|
-
for (let row of table.data){
|
|
14
|
-
let k = gf.map(d => String(row[d])).join("_");
|
|
15
|
-
if (!g.hasOwnProperty(k)){
|
|
16
|
-
g[k] = gf.map(d => row[d]);
|
|
17
|
-
g[k].push([]);
|
|
18
|
-
}
|
|
19
|
-
g[k][g[k].length -1].push(row[f]);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let newData = [];
|
|
23
|
-
for (let k in g) {
|
|
24
|
-
let data = g[k].pop(),
|
|
25
|
-
bin = d3.bin()(data);
|
|
26
|
-
for (let b of bin) {
|
|
27
|
-
let o = {};
|
|
28
|
-
g[k].forEach((d, i) => o[gf[i]] = d);
|
|
29
|
-
o["x0"] = b.x0;
|
|
30
|
-
o["x1"] = b.x1;
|
|
31
|
-
o[f+"_count"] = b.length;
|
|
32
|
-
newData.push(o);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let fTypes = {};
|
|
37
|
-
gf.forEach(d => fTypes[d] = table.getFieldType(d));
|
|
38
|
-
fTypes["x0"] = DataType.Number;
|
|
39
|
-
fTypes["x1"] = DataType.Number;
|
|
40
|
-
fTypes[f+"_count"] = DataType.Number;
|
|
41
|
-
|
|
42
|
-
let dt = new DataTable(newData, table.url, fTypes);
|
|
43
|
-
dt.sourceDataTable = table;
|
|
44
|
-
dt.transform = {"type": "bin", "args": fields};
|
|
45
|
-
return dt;
|
|
46
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import DataTable from "../DataTable";
|
|
2
|
-
|
|
3
|
-
export default function filter(table, predicates) {
|
|
4
|
-
let data = [];
|
|
5
|
-
for (let row of table.data){
|
|
6
|
-
let include = true;
|
|
7
|
-
for (let p of predicates){
|
|
8
|
-
if (!satisfy(row, p)){
|
|
9
|
-
include = false;
|
|
10
|
-
break;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
if (include)
|
|
14
|
-
data.push(row);
|
|
15
|
-
}
|
|
16
|
-
let dt = new DataTable(data, table.url);
|
|
17
|
-
dt.sourceDataTable = table;
|
|
18
|
-
dt.transform = {"type": "filter", "args": predicates};
|
|
19
|
-
return dt;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function satisfy(row, p){
|
|
23
|
-
if ("field" in p) {
|
|
24
|
-
let f = p["field"];
|
|
25
|
-
if ("value" in p)
|
|
26
|
-
return row[f] == p["value"];
|
|
27
|
-
else if ("range" in p)
|
|
28
|
-
return row[f] >= p["range"][0] && row[f] <= p["range"][1];
|
|
29
|
-
else if ("values" in p)
|
|
30
|
-
return p["values"].indexOf(row[f]) >= 0;
|
|
31
|
-
} else if ("fields" in p) {
|
|
32
|
-
let f1 = p["fields"][0], f2 = p["fields"][1],
|
|
33
|
-
v1 = row[f1], v2 = row[f2];
|
|
34
|
-
switch (p["operator"]) {
|
|
35
|
-
case "==":
|
|
36
|
-
return v1 == v2;
|
|
37
|
-
case ">":
|
|
38
|
-
return v1 > v2;
|
|
39
|
-
case ">=":
|
|
40
|
-
return v1 >= v2;
|
|
41
|
-
case "<":
|
|
42
|
-
return v1 < v2;
|
|
43
|
-
case "<=":
|
|
44
|
-
return v1 <= v2;
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default function groupby (table, fields) {
|
|
2
|
-
let g = {};
|
|
3
|
-
for (let row of table.data){
|
|
4
|
-
addGroupByVals(fields, row, g);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function addGroupByVals(fields, row, obj){
|
|
9
|
-
// let hash = obj;
|
|
10
|
-
// for (let i = 0; i < fields.length; i++){
|
|
11
|
-
// if (!hash.hasOwnProperty(vals[i]))
|
|
12
|
-
// hash[vals[i]] = i == fields.length - 1 ? [] : {};
|
|
13
|
-
// if (i == fields.length - 1)
|
|
14
|
-
// hash[vals[i]].push(row);
|
|
15
|
-
// else
|
|
16
|
-
// hash = hash[vals[i]];
|
|
17
|
-
// }
|
|
18
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as d3 from "d3";
|
|
2
|
-
import { DataType } from "../../util/Constants";
|
|
3
|
-
import DataTable from "../DataTable";
|
|
4
|
-
|
|
5
|
-
export default function kde(table, fields, args) {
|
|
6
|
-
//right now only handles one field
|
|
7
|
-
let f = fields[0];
|
|
8
|
-
//TODO: check that can perform kde on f
|
|
9
|
-
let gf = table.nonNumericFields;
|
|
10
|
-
|
|
11
|
-
let g = {};
|
|
12
|
-
for (let row of table.data){
|
|
13
|
-
let k = gf.map(d => String(row[d])).join("_");
|
|
14
|
-
if (!(k in g)){
|
|
15
|
-
g[k] = gf.map(d => row[d]);
|
|
16
|
-
g[k].push([]);
|
|
17
|
-
}
|
|
18
|
-
g[k][g[k].length -1].push(row[f]);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let min = ("min" in args) ? args.min : table.getFieldSummary(f).min,
|
|
22
|
-
max = ("max" in args) ? args.max : table.getFieldSummary(f).max;
|
|
23
|
-
let v = min, thresholds = [];
|
|
24
|
-
while(v < max) {
|
|
25
|
-
thresholds.push(v);
|
|
26
|
-
v += args["interval"];
|
|
27
|
-
}
|
|
28
|
-
thresholds.push(v);
|
|
29
|
-
|
|
30
|
-
let newData = [];
|
|
31
|
-
for (let k in g) {
|
|
32
|
-
let data = g[k].pop(),
|
|
33
|
-
density = _kde(_epanechnikov(args.bandwidth), thresholds, data);
|
|
34
|
-
for (let t of density) {
|
|
35
|
-
let o = {};
|
|
36
|
-
g[k].forEach((d, i) => o[gf[i]] = d);
|
|
37
|
-
o[f] = t[0];
|
|
38
|
-
o[f+"_density"] = t[1];
|
|
39
|
-
newData.push(o);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let fTypes = {};
|
|
44
|
-
gf.forEach(d => fTypes[d] = table.getFieldType(d));
|
|
45
|
-
fTypes[f] = DataType.Number;
|
|
46
|
-
fTypes[f+"_density"] = DataType.Number;
|
|
47
|
-
|
|
48
|
-
return new DataTable(newData, table.url, fTypes);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function _kde(kernel, thresholds, data) {
|
|
52
|
-
return thresholds.map(t => [t, d3.mean(data, d => kernel(t - d))]);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function _epanechnikov(bandwidth) {
|
|
56
|
-
return x => Math.abs(x /= bandwidth) <= 1 ? 0.75 * (1 - x * x) / bandwidth : 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default function sort(table, fields, args) {
|
|
2
|
-
table.data.sort((a,b) => compareRow(a,b, fields));
|
|
3
|
-
table.summarize();
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
function compareRow(row1, row2, fields, fieldTypes){
|
|
7
|
-
for (let f of fields){
|
|
8
|
-
if (row1[f] < row2[f])
|
|
9
|
-
return -1;
|
|
10
|
-
else if (row1[f] > row2[f])
|
|
11
|
-
return 1;
|
|
12
|
-
}
|
|
13
|
-
return 0;
|
|
14
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { nodeId } from "../../util/Constants";
|
|
2
|
-
import Network from "../Network";
|
|
3
|
-
|
|
4
|
-
function merge(grouping, subgraphs) {
|
|
5
|
-
let newGrouping = [grouping[0]], newSG = [subgraphs[0]];
|
|
6
|
-
for (let i = 1; i < subgraphs.length; i++) {
|
|
7
|
-
let canMerge = false, sg1 = subgraphs[i];
|
|
8
|
-
for (let j = 0; j < newSG.length; j++) {
|
|
9
|
-
let sg2 = newSG[j];
|
|
10
|
-
let set = new Set(sg1);
|
|
11
|
-
sg2.forEach(d => set.add(d));
|
|
12
|
-
if (set.size < sg1.length + sg2.length) {
|
|
13
|
-
newSG[j] = [...set];
|
|
14
|
-
newGrouping[j] = newGrouping[j].concat(grouping[i])
|
|
15
|
-
canMerge = true;
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (!canMerge) {
|
|
20
|
-
newSG.push(sg1);
|
|
21
|
-
newGrouping.push(grouping[i]);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return {grouping: newGrouping, subgraphs: newSG};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default function partition(graph) {
|
|
28
|
-
let nodes = graph.nodes, links = graph.links;
|
|
29
|
-
let grouping = links.map((d, i) => [i]), subgraphs = links.map((d) => [d.source, d.target]);
|
|
30
|
-
let newGrouping = merge(grouping, subgraphs);
|
|
31
|
-
while (newGrouping.grouping.length != grouping.length) {
|
|
32
|
-
grouping = newGrouping.grouping;
|
|
33
|
-
subgraphs = newGrouping.subgraphs;
|
|
34
|
-
newGrouping = merge(grouping, subgraphs);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let result = [];
|
|
38
|
-
for (let [i, g] of newGrouping.grouping.entries()) {
|
|
39
|
-
let data = {"nodes": [], "links": []};
|
|
40
|
-
data.links = g.map(d => links[d]);
|
|
41
|
-
const nids = newGrouping.subgraphs[i];
|
|
42
|
-
data.nodes = nodes.filter( d => nids.indexOf(d[nodeId]) >= 0 );
|
|
43
|
-
result.push(new Network(data));
|
|
44
|
-
}
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
File without changes
|