mascot-vis 3.0.0 → 3.0.2
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/mascot-esm.js +186 -0
- package/package.json +3 -6
- package/dist/mascot-es.js +0 -27745
- package/dist/mascot-min.js +0 -186
- package/dist/mascot-umd.js +0 -27781
- 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
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
import {Errors, DataType, ItemType, Orientation, Direction} from "../util/Constants";
|
|
2
|
-
import DataScope from "../data/DataScope";
|
|
3
|
-
import {getPeers} from "../util/ItemUtil";
|
|
4
|
-
import StackLayout from "../layout/Stack";
|
|
5
|
-
import { normalizeAngle } from "../util/DataUtil";
|
|
6
|
-
|
|
7
|
-
export function dividable(compnt) {
|
|
8
|
-
if ([ItemType.Line, ItemType.Circle, ItemType.Rect, ItemType.Area, ItemType.Ring, ItemType.Pie, ItemType.Path].indexOf(compnt.type) < 0) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (compnt.type === ItemType.Path && (compnt.closed || !compnt.firstVertex.dataScope))
|
|
13
|
-
return false;
|
|
14
|
-
|
|
15
|
-
if (!compnt.dataScope) {
|
|
16
|
-
return true;
|
|
17
|
-
} else {
|
|
18
|
-
let peers = getPeers(compnt, compnt.getScene());
|
|
19
|
-
for (let p of peers) {
|
|
20
|
-
if (p.dataScope.numTuples > 1)
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function divideItem(scene, compnt, orientation, field, datatable, callback) {
|
|
28
|
-
let f = callback ? datatable.transformField(field, callback) : field;
|
|
29
|
-
let type = datatable.getFieldType(f);
|
|
30
|
-
|
|
31
|
-
if (type != DataType.String && type != DataType.Date) {
|
|
32
|
-
throw new Error(Errors.PARTITION_BY_NONCAT + ": " + f + " is " + type);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!dividable(compnt)) {
|
|
36
|
-
throw new Error(Errors.COMPNT_NON_PARTITIONABLE);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
switch (compnt.type) {
|
|
40
|
-
case ItemType.Line:
|
|
41
|
-
return _doLineDivide(scene, compnt, f, datatable);
|
|
42
|
-
case ItemType.Path:
|
|
43
|
-
return _doPathDivide(scene, compnt, f, datatable);
|
|
44
|
-
case ItemType.Circle:
|
|
45
|
-
return _doCircleDivide(scene, compnt, orientation, f, datatable);
|
|
46
|
-
case ItemType.Rect:
|
|
47
|
-
return _doRectDivide(scene, compnt, orientation, f, datatable);
|
|
48
|
-
case ItemType.Area:
|
|
49
|
-
return _doAreaDivide(scene, compnt, orientation, f, datatable);
|
|
50
|
-
case ItemType.Ring:
|
|
51
|
-
return _doRingDivide(scene, compnt, orientation, f, datatable);
|
|
52
|
-
case ItemType.Pie:
|
|
53
|
-
case ItemType.Arc:
|
|
54
|
-
return _doArcDivide(scene, compnt, orientation, f, datatable);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function _doLineDivide(scene, compnt, field, datatable) {
|
|
60
|
-
let peers = getPeers(compnt, scene);
|
|
61
|
-
let colls = [], toReturn;
|
|
62
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => new DataScope(datatable).cross(field, d));
|
|
63
|
-
|
|
64
|
-
let line2Scopes = {}, max = 0;
|
|
65
|
-
for (let p of peers) {
|
|
66
|
-
let scopes = ds;
|
|
67
|
-
if (p.dataScope) {
|
|
68
|
-
scopes = ds.map(d => d.merge(p.dataScope));
|
|
69
|
-
scopes = scopes.filter(d => !d.isEmpty());
|
|
70
|
-
}
|
|
71
|
-
if (scopes.length > max)
|
|
72
|
-
max = scopes.length;
|
|
73
|
-
line2Scopes[p.id] = scopes;
|
|
74
|
-
}
|
|
75
|
-
let collClassId;
|
|
76
|
-
for (let p of peers) {
|
|
77
|
-
let coll = scene.collection();
|
|
78
|
-
if (collClassId == undefined)
|
|
79
|
-
collClassId = coll.id;
|
|
80
|
-
coll.classId = collClassId;
|
|
81
|
-
coll.dataScope = p.dataScope;
|
|
82
|
-
|
|
83
|
-
let parent = p.parent;
|
|
84
|
-
//let index = parent.children.indexOf(p) - 1;
|
|
85
|
-
parent.addChild(coll);
|
|
86
|
-
|
|
87
|
-
let scopes = line2Scopes[p.id];
|
|
88
|
-
let x1 = p.vertices[0].x, y1 = p.vertices[0].y, x2 = p.vertices[1].x, y2 = p.vertices[1].y;
|
|
89
|
-
|
|
90
|
-
// p.classId = compnt.id;
|
|
91
|
-
// p.vertices[0].x = x1;
|
|
92
|
-
// p.vertices[0].y = y1;
|
|
93
|
-
// p.vertices[1].x = x1 + (x2 - x1)/max;
|
|
94
|
-
// p.vertices[1].y = y1 + (y2 - y1)/max;
|
|
95
|
-
// p.dataScope = scopes[0];
|
|
96
|
-
// coll.addChild(p);
|
|
97
|
-
|
|
98
|
-
for (let i = 0; i < scopes.length; i++) {
|
|
99
|
-
let c = p.duplicate();
|
|
100
|
-
c.classId = compnt.id;
|
|
101
|
-
c.vertices[0].x = x1 + (x2 - x1) * i /max
|
|
102
|
-
c.vertices[0].y = y1 + (y2 - y1) * i /max;
|
|
103
|
-
c.vertices[1].x = x1 + (x2 - x1) * (i + 1)/max;
|
|
104
|
-
c.vertices[1].y = y1 + (y2 - y1) * (i + 1)/max;
|
|
105
|
-
c.dataScope = scopes[i];
|
|
106
|
-
coll.addChild(c);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
parent.removeChild(p);
|
|
110
|
-
colls.push(coll);
|
|
111
|
-
|
|
112
|
-
if (p == compnt)
|
|
113
|
-
toReturn = coll;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return toReturn;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function _doPathDivide(scene, compnt, field, datatable) {
|
|
120
|
-
let peers = getPeers(compnt, scene);
|
|
121
|
-
let colls = [], toReturn;
|
|
122
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => new DataScope(datatable).cross(field, d));
|
|
123
|
-
|
|
124
|
-
let line2Scopes = {}, max = 0;
|
|
125
|
-
for (let p of peers) {
|
|
126
|
-
let scopes = ds;
|
|
127
|
-
if (p.dataScope) {
|
|
128
|
-
scopes = ds.map(d => d.merge(p.dataScope));
|
|
129
|
-
scopes = scopes.filter(d => !d.isEmpty());
|
|
130
|
-
}
|
|
131
|
-
if (scopes.length > max)
|
|
132
|
-
max = scopes.length;
|
|
133
|
-
line2Scopes[p.id] = scopes;
|
|
134
|
-
}
|
|
135
|
-
let collClassId;
|
|
136
|
-
for (let p of peers) {
|
|
137
|
-
let coll = scene.collection();
|
|
138
|
-
if (collClassId == undefined)
|
|
139
|
-
collClassId = coll.id;
|
|
140
|
-
coll.classId = collClassId;
|
|
141
|
-
coll.dataScope = p.dataScope;
|
|
142
|
-
|
|
143
|
-
let parent = p.parent;
|
|
144
|
-
//let index = parent.children.indexOf(p) - 1;
|
|
145
|
-
parent.addChild(coll);
|
|
146
|
-
|
|
147
|
-
let scopes = line2Scopes[p.id];
|
|
148
|
-
let x1 = p.bounds.left, y1 = p.bounds.top, x2 = p.bounds.right, y2 = p.bounds.bottom;
|
|
149
|
-
|
|
150
|
-
for (let i = 0; i < scopes.length; i++) {
|
|
151
|
-
let c = scene.mark("line", {x1: x1 + (x2 - x1) * i /max, x2: x1 + (x2 - x1) * (i + 1)/max, y1: y1 + (y2 - y1) * i /max, y2: y1 + (y2 - y1) * (i + 1)/max});
|
|
152
|
-
c.classId = compnt.id;
|
|
153
|
-
c.dataScope = scopes[i];
|
|
154
|
-
coll.addChild(c);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
parent.removeChild(p);
|
|
158
|
-
colls.push(coll);
|
|
159
|
-
|
|
160
|
-
if (p == compnt)
|
|
161
|
-
toReturn = coll;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
let f = compnt.firstVertex.dataScope.fields[0];
|
|
165
|
-
scene.densify(toReturn.firstChild, datatable, {field: f});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return toReturn;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
function _doRectDivide(scene, compnt, o, field, datatable) {
|
|
174
|
-
let peers = getPeers(compnt, scene);
|
|
175
|
-
let colls = [], toReturn, orientation = o ? o : Orientation.Horizontal;
|
|
176
|
-
if (orientation != Orientation.Horizontal && orientation != Orientation.Vertical)
|
|
177
|
-
throw Errors.UNKNOWN_Orientation + ": " + orientation;
|
|
178
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => new DataScope(datatable).cross(field, d));
|
|
179
|
-
|
|
180
|
-
//datascopes
|
|
181
|
-
let rect2Scopes = {}, max = 0;
|
|
182
|
-
for (let p of peers) {
|
|
183
|
-
let scopes = ds;
|
|
184
|
-
if (p.dataScope) {
|
|
185
|
-
scopes = ds.map(d => d.merge(p.dataScope));
|
|
186
|
-
scopes = scopes.filter(d => !d.isEmpty());
|
|
187
|
-
}
|
|
188
|
-
if (scopes.length > max)
|
|
189
|
-
max = scopes.length;
|
|
190
|
-
rect2Scopes[p.id] = scopes;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
let collClassId;
|
|
194
|
-
for (let p of peers) {
|
|
195
|
-
let coll = scene.collection();
|
|
196
|
-
if (collClassId == undefined)
|
|
197
|
-
collClassId = coll.id;
|
|
198
|
-
coll.classId = collClassId;
|
|
199
|
-
coll.dataScope = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
200
|
-
|
|
201
|
-
let parent = p.parent;
|
|
202
|
-
//let index = parent.children.indexOf(p) - 1;
|
|
203
|
-
parent.addChild(coll);
|
|
204
|
-
|
|
205
|
-
let scopes = rect2Scopes[p.id];
|
|
206
|
-
let bounds = p.bounds, left = bounds.left, top = bounds.top;
|
|
207
|
-
|
|
208
|
-
// let wd = orientation == Orientation.Horizontal ? bounds.width/max : bounds.width,
|
|
209
|
-
// ht = orientation == Orientation.Horizontal ? bounds.height : bounds.height/max;
|
|
210
|
-
let wd = orientation == Orientation.Horizontal ? bounds.width/scopes.length : bounds.width,
|
|
211
|
-
ht = orientation == Orientation.Horizontal ? bounds.height : bounds.height/scopes.length;
|
|
212
|
-
|
|
213
|
-
for (let i = 0; i < scopes.length; i++) {
|
|
214
|
-
let c = p.duplicate();
|
|
215
|
-
c.classId = compnt.id;
|
|
216
|
-
c.resize(wd, ht);
|
|
217
|
-
c.dataScope = scopes[i];
|
|
218
|
-
coll.addChild(c);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
coll.layout = new StackLayout({orientation: orientation, left: left, top: top});
|
|
222
|
-
|
|
223
|
-
colls.push(coll);
|
|
224
|
-
|
|
225
|
-
parent.removeChild(p);
|
|
226
|
-
|
|
227
|
-
if (p == compnt)
|
|
228
|
-
toReturn = coll;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
scene._reapplySizeBindings(toReturn);
|
|
232
|
-
|
|
233
|
-
return toReturn;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function _doAreaDivide(scene, compnt, orientation, field, datatable) {
|
|
237
|
-
let peers = getPeers(compnt, scene);
|
|
238
|
-
// make sure the orientation is correct; in case that the boundary partitioning has already been performed if we initial an area mark other than a rect
|
|
239
|
-
let p1 = peers[0];
|
|
240
|
-
if ((p1.vertices.length == 4) && (orientation == Orientation.Horizontal) && (p1.vertices[0].x !== p1.vertices[1].x)) {
|
|
241
|
-
for (let p of peers) {
|
|
242
|
-
let temp = p.vertices[1];
|
|
243
|
-
p.vertices[1] = p.vertices[3];
|
|
244
|
-
p.vertices[3] = temp;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
let colls = [], toReturn;
|
|
248
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => new DataScope(datatable).cross(field, d));
|
|
249
|
-
let collClassId;
|
|
250
|
-
for (let p of peers) {
|
|
251
|
-
let coll = scene.collection();
|
|
252
|
-
if (collClassId == undefined)
|
|
253
|
-
collClassId = coll.id;
|
|
254
|
-
coll.classId = collClassId;
|
|
255
|
-
coll.dataScope = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
256
|
-
|
|
257
|
-
let parent = p.parent;
|
|
258
|
-
parent.addChild(coll);
|
|
259
|
-
|
|
260
|
-
let left = p.left, top = p.top;
|
|
261
|
-
|
|
262
|
-
let wd = orientation == Orientation.Horizontal ? p.width/ds.length : p.width,
|
|
263
|
-
ht = orientation == Orientation.Horizontal ? p.height : p.height/ds.length;
|
|
264
|
-
// p.classId = compnt.id;
|
|
265
|
-
// p.resizeArea(wd, ht);
|
|
266
|
-
// coll.addChild(p);
|
|
267
|
-
|
|
268
|
-
for (let i = 0; i < ds.length; i++) {
|
|
269
|
-
let c = p.duplicate();
|
|
270
|
-
c.classId = compnt.id;
|
|
271
|
-
c.resizeArea(wd, ht);
|
|
272
|
-
coll.addChild(c);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
parent.removeChild(p);
|
|
276
|
-
|
|
277
|
-
for (let i = 0; i < coll.children.length; i++) {
|
|
278
|
-
let child = coll.children[i];
|
|
279
|
-
if (child.dataScope) {
|
|
280
|
-
child.dataScope = child.dataScope.merge(ds[i]);
|
|
281
|
-
} else {
|
|
282
|
-
child.dataScope = ds[i];
|
|
283
|
-
}
|
|
284
|
-
// assigning datascope for boundary vertices
|
|
285
|
-
for (let v of child.vertices){
|
|
286
|
-
if (v.dataScope) {
|
|
287
|
-
v.dataScope = child.dataScope.merge(v.dataScope);
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
v.dataScope = child.dataScope;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// coll.layout = new StackLayout({orientation: orientation, left: left, top: top});
|
|
296
|
-
|
|
297
|
-
colls.push(coll);
|
|
298
|
-
|
|
299
|
-
if (p == compnt)
|
|
300
|
-
toReturn = coll;
|
|
301
|
-
}
|
|
302
|
-
scene._reapplySizeBindings(toReturn);
|
|
303
|
-
return toReturn;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function _doArcDivide(scene, compnt, o, field, datatable) {
|
|
307
|
-
let toReturn, orientation = o ? o : Orientation.Radial;
|
|
308
|
-
let peers = getPeers(compnt, scene);
|
|
309
|
-
let collClassId;
|
|
310
|
-
if (orientation == Orientation.Radial) {
|
|
311
|
-
peers.forEach(p => {
|
|
312
|
-
let pieDS = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
313
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => pieDS.cross(field, d));
|
|
314
|
-
ds = ds.filter(d => !d.isEmpty());
|
|
315
|
-
let numArcs = ds.length;
|
|
316
|
-
|
|
317
|
-
// Define new collection and save parent
|
|
318
|
-
let coll = scene.collection();
|
|
319
|
-
coll.dataScope = pieDS;
|
|
320
|
-
if (collClassId == undefined)
|
|
321
|
-
collClassId = coll.id;
|
|
322
|
-
coll.classId = collClassId;
|
|
323
|
-
let parent = p.parent;
|
|
324
|
-
// Create each arc
|
|
325
|
-
for (let i = 0; i < numArcs; i++){
|
|
326
|
-
let arc = scene.mark("arc", {
|
|
327
|
-
innerRadius: i * p.outerRadius/numArcs,
|
|
328
|
-
outerRadius: (i+1) * p.outerRadius/numArcs,
|
|
329
|
-
x: p.x,
|
|
330
|
-
y: p.y,
|
|
331
|
-
startAngle: p.startAngle,
|
|
332
|
-
endAngle: p.endAngle,
|
|
333
|
-
strokeColor: p.strokeColor,
|
|
334
|
-
fillColor: p.fillColor,
|
|
335
|
-
strokeWidth: p.strokeWidth,
|
|
336
|
-
opacity: p.opacity
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// Add the datascope
|
|
340
|
-
arc.dataScope = ds[i];
|
|
341
|
-
arc.classId = compnt.id;
|
|
342
|
-
|
|
343
|
-
// Add to collection
|
|
344
|
-
coll.addChild(arc);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
coll.layout = new StackLayout({orientation: Orientation.Radial});
|
|
348
|
-
|
|
349
|
-
// Replace original circle w/ coll of pies
|
|
350
|
-
parent.removeChild(p);
|
|
351
|
-
parent.addChild(coll);
|
|
352
|
-
|
|
353
|
-
// Return collection
|
|
354
|
-
if (p == compnt)
|
|
355
|
-
toReturn = coll;
|
|
356
|
-
});
|
|
357
|
-
return toReturn;
|
|
358
|
-
} else {
|
|
359
|
-
throw Errors.UNKNOWN_Orientation + ": " + orientation;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
function _doRingDivide(scene, compnt, o, field, datatable) {
|
|
364
|
-
let toReturn, orientation = o ? o : Orientation.Angular;
|
|
365
|
-
let peers = getPeers(compnt, scene);
|
|
366
|
-
let collClassId;
|
|
367
|
-
if (orientation == Orientation.Angular) {
|
|
368
|
-
peers.forEach(p => {
|
|
369
|
-
let ringDS = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
370
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => ringDS.cross(field, d));
|
|
371
|
-
ds = ds.filter(d => !d.isEmpty());
|
|
372
|
-
let numArcs = ds.length;
|
|
373
|
-
|
|
374
|
-
// Define new collection and save parent
|
|
375
|
-
let coll = scene.collection();
|
|
376
|
-
coll.dataScope = ringDS;
|
|
377
|
-
if (collClassId == undefined)
|
|
378
|
-
collClassId = coll.id;
|
|
379
|
-
coll.classId = collClassId;
|
|
380
|
-
let parent = p.parent;
|
|
381
|
-
|
|
382
|
-
let arcAng = 360 / numArcs;
|
|
383
|
-
|
|
384
|
-
// Create each pie
|
|
385
|
-
let start = 90;
|
|
386
|
-
let clockwise = true;
|
|
387
|
-
for (let i = 0; i < numArcs; i++){
|
|
388
|
-
let arc = scene.mark("arc", {
|
|
389
|
-
innerRadius: p.innerRadius,
|
|
390
|
-
outerRadius: p.outerRadius,
|
|
391
|
-
x: p.x,
|
|
392
|
-
y: p.y,
|
|
393
|
-
startAngle: clockwise ? normalizeAngle(start - arcAng * (i + 1)) : normalizeAngle(start + arcAng * i),
|
|
394
|
-
endAngle: clockwise ? normalizeAngle(start - arcAng * i) : normalizeAngle(start + arcAng * (i + 1)),
|
|
395
|
-
strokeColor: p.strokeColor,
|
|
396
|
-
fillColor: p.fillColor,
|
|
397
|
-
strokeWidth: p.strokeWidth,
|
|
398
|
-
opacity: p.opacity
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// Add the datascope
|
|
402
|
-
arc.dataScope = ds[i];
|
|
403
|
-
arc.classId = compnt.id;
|
|
404
|
-
|
|
405
|
-
// Add to collection
|
|
406
|
-
coll.addChild(arc);
|
|
407
|
-
}
|
|
408
|
-
coll.layout = new StackLayout({direction: Direction.Clockwise, orientation: Orientation.Angular});
|
|
409
|
-
// Replace original circle w/ coll of pies
|
|
410
|
-
parent.removeChild(p);
|
|
411
|
-
parent.addChild(coll);
|
|
412
|
-
|
|
413
|
-
// Return collection
|
|
414
|
-
if (p == compnt)
|
|
415
|
-
toReturn = coll;
|
|
416
|
-
});
|
|
417
|
-
return toReturn;
|
|
418
|
-
} else {
|
|
419
|
-
throw Errors.UNKNOWN_Orientation + ": " + orientation;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
function _doCircleDivide(scene, compnt, o, field, datatable) {
|
|
425
|
-
let toReturn, orientation = o ? o : Orientation.Angular;
|
|
426
|
-
|
|
427
|
-
// Perform on all repitions of cmpnt on canvas
|
|
428
|
-
let peers = getPeers(compnt, scene);
|
|
429
|
-
let collClassId;
|
|
430
|
-
if (orientation == Orientation.Angular) {
|
|
431
|
-
peers.forEach(p => {
|
|
432
|
-
let circDS = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
433
|
-
//console.info("Peer DS: ", circDS);
|
|
434
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => circDS.cross(field, d));
|
|
435
|
-
ds = ds.filter(d => !d.isEmpty());
|
|
436
|
-
let numPies = ds.length;
|
|
437
|
-
|
|
438
|
-
// Define new collection and save parent
|
|
439
|
-
let coll = scene.collection();
|
|
440
|
-
coll.dataScope = circDS;
|
|
441
|
-
if (collClassId == undefined)
|
|
442
|
-
collClassId = coll.id;
|
|
443
|
-
coll.classId = collClassId;
|
|
444
|
-
let parent = p.parent;
|
|
445
|
-
|
|
446
|
-
// Calculate angle of each pie
|
|
447
|
-
let pieAng = 360 / numPies;
|
|
448
|
-
|
|
449
|
-
// Create each pie
|
|
450
|
-
let start = 90;
|
|
451
|
-
let clockwise = true;
|
|
452
|
-
for (let i = 0; i < numPies; i++){
|
|
453
|
-
let pie = scene.mark("pie", {
|
|
454
|
-
innerRadius: 0,
|
|
455
|
-
outerRadius: p.radius,
|
|
456
|
-
x: p.x,
|
|
457
|
-
y: p.y,
|
|
458
|
-
startAngle: clockwise ? normalizeAngle(start - pieAng * (i + 1)) : normalizeAngle(start + pieAng * i),
|
|
459
|
-
endAngle: clockwise ? normalizeAngle(start - pieAng * i) : normalizeAngle(start + pieAng * (i + 1)),
|
|
460
|
-
strokeColor: p.strokeColor,
|
|
461
|
-
fillColor: p.styles.fillColor
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
// Add the datascope
|
|
465
|
-
pie.dataScope = ds[i];
|
|
466
|
-
pie.classId = compnt.id;
|
|
467
|
-
|
|
468
|
-
// Add to collection
|
|
469
|
-
coll.addChild(pie);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
coll.layout = new StackLayout({orientation: Orientation.Angular, direction: Direction.Clockwise});
|
|
473
|
-
// Replace original circle w/ coll of pies
|
|
474
|
-
parent.removeChild(p);
|
|
475
|
-
parent.addChild(coll);
|
|
476
|
-
|
|
477
|
-
// Return collection
|
|
478
|
-
if (p == compnt)
|
|
479
|
-
toReturn = coll;
|
|
480
|
-
});
|
|
481
|
-
} else if (orientation == Orientation.Radial) {//radial
|
|
482
|
-
peers.forEach(p => {
|
|
483
|
-
let circDS = p.dataScope ? p.dataScope : new DataScope(datatable);
|
|
484
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => circDS.cross(field, d));
|
|
485
|
-
ds = ds.filter(d => !d.isEmpty());
|
|
486
|
-
let numRings = ds.length;
|
|
487
|
-
|
|
488
|
-
// Define new collection and save parent
|
|
489
|
-
let coll = scene.collection();
|
|
490
|
-
coll.dataScope = circDS;
|
|
491
|
-
if (collClassId == undefined)
|
|
492
|
-
collClassId = coll.id;
|
|
493
|
-
coll.classId = collClassId;
|
|
494
|
-
let parent = p.parent;
|
|
495
|
-
|
|
496
|
-
// Calculate angle of each pie
|
|
497
|
-
let thickness = p.radius / numRings;
|
|
498
|
-
|
|
499
|
-
// Create each pie
|
|
500
|
-
for (let i = 0; i < numRings; i++){
|
|
501
|
-
let r = scene.mark("ring", {
|
|
502
|
-
x: p.x,
|
|
503
|
-
y: p.y,
|
|
504
|
-
innerRadius: i * thickness,
|
|
505
|
-
outerRadius: (i + 1) * thickness,
|
|
506
|
-
strokeColor: p.strokeColor,
|
|
507
|
-
fillColor: p.styles.fillColor
|
|
508
|
-
})
|
|
509
|
-
|
|
510
|
-
// Add the datascope
|
|
511
|
-
r.dataScope = ds[i];
|
|
512
|
-
r.classId = compnt.id;
|
|
513
|
-
|
|
514
|
-
// Add to collection
|
|
515
|
-
coll.addChild(r);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// Replace original circle w/ coll of pies
|
|
519
|
-
parent.removeChild(p);
|
|
520
|
-
parent.addChild(coll);
|
|
521
|
-
|
|
522
|
-
// Return collection
|
|
523
|
-
if (p == compnt)
|
|
524
|
-
toReturn = coll;
|
|
525
|
-
});
|
|
526
|
-
} else {
|
|
527
|
-
throw Errors.UNKNOWN_Orientation + ": " + orientation;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
return toReturn;
|
|
531
|
-
}
|
package/src-old/action/Repeat.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import {Errors, DataType, nodeId, atlas_rowId} from "../util/Constants";
|
|
2
|
-
import DataScope from "../data/DataScope";
|
|
3
|
-
import { isMark, itemIsRepeatable } from "../util/ItemUtil";
|
|
4
|
-
|
|
5
|
-
export function repeatable(compnt) {
|
|
6
|
-
if (Array.isArray(compnt)) {
|
|
7
|
-
if (compnt.length === 1) {
|
|
8
|
-
return itemIsRepeatable(compnt[0]);
|
|
9
|
-
} else {
|
|
10
|
-
for (let c of compnt) {
|
|
11
|
-
if (!isMark(c) || c.dataScope)
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
} else {
|
|
17
|
-
return itemIsRepeatable(compnt);
|
|
18
|
-
}
|
|
19
|
-
// else if ((isMark(compnt) || compnt.type == ItemType.Glyph) && !compnt.dataScope) {
|
|
20
|
-
// return true;
|
|
21
|
-
// } else if (compnt.type == ItemType.Collection) {
|
|
22
|
-
// return itemIsRepeatable(compnt);
|
|
23
|
-
// }
|
|
24
|
-
//return false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function repeatItem(scene, compnt, field, datatable, callback) {
|
|
28
|
-
let f = callback ? datatable.transformField(field, callback) : field;
|
|
29
|
-
let type = datatable.getFieldType(f);
|
|
30
|
-
|
|
31
|
-
if (type != DataType.String && type != DataType.Date && type != DataType.Integer) {
|
|
32
|
-
throw new Error(Errors.REPEAT_BY_NONCAT + ": " + f + " is " + type);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!repeatable(compnt)) {
|
|
36
|
-
throw new Error(Errors.COMPNT_NON_REPEATABLE);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return _doRepeat(scene, compnt, f, datatable);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _doRepeat(scene, compnt, field, datatable) {
|
|
43
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => compnt.dataScope ? compnt.dataScope.cross(field, d) : new DataScope(datatable).cross(field, d));
|
|
44
|
-
ds = ds.filter(d => !d.isEmpty());
|
|
45
|
-
let coll = scene.collection();
|
|
46
|
-
coll.dataScope = compnt.dataScope ? compnt.dataScope.clone() : new DataScope(datatable);
|
|
47
|
-
|
|
48
|
-
//scene.addChild(coll);
|
|
49
|
-
|
|
50
|
-
//do not initialize classId here, initialize in scene.mark/glyph/new Collection()
|
|
51
|
-
// compnt.classId = compnt.id;
|
|
52
|
-
coll.addChild(compnt);
|
|
53
|
-
|
|
54
|
-
for (let i = 1; i < ds.length; i++) {
|
|
55
|
-
let c = compnt.duplicate();
|
|
56
|
-
coll.addChild(c);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
coll.children.forEach((d, i) => d.dataScope = ds[i]);
|
|
60
|
-
//TODO: turn the folllwing into getter and setter
|
|
61
|
-
// if (!scene.cellAlign.hasOwnProperty(compnt.classId)) {
|
|
62
|
-
// scene.cellAlign[compnt.classId] = {x: Alignment.Left, y: Alignment.Bottom};
|
|
63
|
-
// }
|
|
64
|
-
scene._reapplySizeBindings(compnt);
|
|
65
|
-
return coll;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function repeatNodeLink(scene, node, link, data) {
|
|
69
|
-
let nodeDS = data.nodeTable.getFieldSummary(nodeId).unique.map(d => node.dataScope ? node.dataScope.cross(nodeId, d) : new DataScope(data.nodeTable).cross(nodeId, d));
|
|
70
|
-
let linkColl = scene.collection(), nodeColl = scene.collection(), id2node = {};
|
|
71
|
-
nodeColl.dataScope = node.dataScope ? node.dataScope.clone() : new DataScope(data.nodeTable);
|
|
72
|
-
|
|
73
|
-
//do not initialize classId here, initialize in scene.mark/glyph/new Collection()
|
|
74
|
-
// compnt.classId = compnt.id;
|
|
75
|
-
nodeColl.addChild(node);
|
|
76
|
-
for (let i = 1; i < nodeDS.length; i++) {
|
|
77
|
-
let c = node.duplicate();
|
|
78
|
-
nodeColl.addChild(c);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
nodeColl.children.forEach((d, i) => {
|
|
82
|
-
d.dataScope = nodeDS[i];
|
|
83
|
-
id2node[d.dataScope.getFieldValue(nodeId)] = d;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
let linkDS = data.linkTable.getFieldSummary(atlas_rowId).unique.map(d => link.dataScope ? link.dataScope.cross(atlas_rowId, d) : new DataScope(data.linkTable).cross(atlas_rowId, d));
|
|
87
|
-
linkColl.dataScope = link.dataScope ? link.dataScope.clone() : new DataScope(data.linkTable);
|
|
88
|
-
|
|
89
|
-
linkColl.addChild(link);
|
|
90
|
-
for (let i = 1; i < linkDS.length; i++) {
|
|
91
|
-
let c = link.duplicate();
|
|
92
|
-
linkColl.addChild(c);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
linkColl.children.forEach((d, i) => d.dataScope = linkDS[i]);
|
|
96
|
-
let s = data.type === "tree" ? "parent" : "source", t = data.type === "tree" ? "child" : "target";
|
|
97
|
-
for (let l of linkColl.children) {
|
|
98
|
-
let sid = l.dataScope.getFieldValue(s),
|
|
99
|
-
tid = l.dataScope.getFieldValue(t);
|
|
100
|
-
l.source = id2node[sid];
|
|
101
|
-
l.target = id2node[tid];
|
|
102
|
-
l._updateBounds();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return [nodeColl, linkColl];
|
|
106
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import DataScope from "../data/DataScope";
|
|
2
|
-
import { DataType, Errors } from "../util/Constants";
|
|
3
|
-
import { getPeers } from "../util/ItemUtil";
|
|
4
|
-
|
|
5
|
-
export function repopulateItem(scene, compnt, field, datatable) {
|
|
6
|
-
let type = datatable.getFieldType(field);
|
|
7
|
-
|
|
8
|
-
if (type != DataType.String && type != DataType.Date && type != DataType.Integer) {
|
|
9
|
-
throw new Error(Errors.REPOPULATE_BY_NONCAT + ": " + field + " is " + type);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (compnt.parent && compnt.parent.dataScope && !compnt.parent.dataScope.isFullTable() && compnt.parent.dataScope.dataTable != datatable) {
|
|
13
|
-
throw new Error(Errors.REPOPULATE_DT_MISMATCH);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return _doRopulate(scene, compnt, field, datatable);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function _doRopulate(scene, item, field, datatable) {
|
|
20
|
-
|
|
21
|
-
//assuming parent is a collection
|
|
22
|
-
let peers = getPeers(item.parent, scene);
|
|
23
|
-
if (peers.length === 1) {
|
|
24
|
-
item.parent.dataScope = undefined;
|
|
25
|
-
}
|
|
26
|
-
for (let coll of peers) {
|
|
27
|
-
let ds = datatable.getFieldSummary(field).unique.map(d => coll.dataScope ? coll.dataScope.cross(field, d) : new DataScope(datatable).cross(field, d));
|
|
28
|
-
ds = ds.filter(d => !d.isEmpty());
|
|
29
|
-
const toAdd = ds.length - coll.children.length, toRemove = coll.children.length - ds.length;
|
|
30
|
-
for (let i = 0; i < toRemove; i++) {
|
|
31
|
-
coll.removeChildAt(coll.children.length - 1);
|
|
32
|
-
}
|
|
33
|
-
const numPeers = coll.children.length;
|
|
34
|
-
for (let i = 0; i < toAdd; i++) {
|
|
35
|
-
let c = coll.children[Math.floor(Math.random()*numPeers)].duplicate();
|
|
36
|
-
coll.addChild(c);
|
|
37
|
-
}
|
|
38
|
-
coll.children.forEach((d, i) => d.dataScope = ds[i]);
|
|
39
|
-
}
|
|
40
|
-
scene._relayoutAncestors(item);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
//TODO: remove encodings;
|
|
44
|
-
}
|