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.
Files changed (152) hide show
  1. package/package.json +1 -2
  2. package/js/depGraphVis.js +0 -66
  3. package/src-new-ts/action/createElement.ts +0 -91
  4. package/src-new-ts/action/encode.js +0 -20
  5. package/src-new-ts/action/repeat.js +0 -128
  6. package/src-new-ts/action/traverseScene.js +0 -41
  7. package/src-new-ts/data/Network.js +0 -2
  8. package/src-new-ts/data/Scope.js +0 -135
  9. package/src-new-ts/data/Table.js +0 -263
  10. package/src-new-ts/data/Tree.js +0 -3
  11. package/src-new-ts/data/field.ts +0 -115
  12. package/src-new-ts/data/import.ts +0 -96
  13. package/src-new-ts/data/predicate.ts +0 -82
  14. package/src-new-ts/depgraph/DepGraph.js +0 -178
  15. package/src-new-ts/depgraph/Edge.js +0 -9
  16. package/src-new-ts/depgraph/SceneGraph2DepGraph.js +0 -110
  17. package/src-new-ts/depgraph/Signal.js +0 -12
  18. package/src-new-ts/depgraph/operator/BoundsEvaluator.js +0 -30
  19. package/src-new-ts/depgraph/operator/Dataflow.js +0 -41
  20. package/src-new-ts/depgraph/operator/DomainBuilder.js +0 -50
  21. package/src-new-ts/depgraph/updateDepGraph.js +0 -45
  22. package/src-new-ts/depgraph/variable/BoundsVar.js +0 -81
  23. package/src-new-ts/depgraph/variable/ChannelVar.js +0 -17
  24. package/src-new-ts/depgraph/variable/DataScopeVar.js +0 -12
  25. package/src-new-ts/depgraph/variable/DomainVar.js +0 -15
  26. package/src-new-ts/depgraph/variable/FieldVar.js +0 -17
  27. package/src-new-ts/depgraph/variable/LayoutParameter.js +0 -8
  28. package/src-new-ts/depgraph/variable/ScaleVar.js +0 -13
  29. package/src-new-ts/depgraph/variable/Variable.js +0 -39
  30. package/src-new-ts/element/gradient/LinearGradient.js +0 -37
  31. package/src-new-ts/element/group/Collection.js +0 -109
  32. package/src-new-ts/element/group/Group.js +0 -307
  33. package/src-new-ts/element/group/Scene.js +0 -98
  34. package/src-new-ts/element/mark/CircleMark.ts +0 -85
  35. package/src-new-ts/element/mark/Mark.ts +0 -233
  36. package/src-new-ts/element/mark/PathMark.js +0 -483
  37. package/src-new-ts/element/mark/Segment.js +0 -29
  38. package/src-new-ts/element/mark/Vertex.js +0 -118
  39. package/src-new-ts/encode/Scale.ts +0 -115
  40. package/src-new-ts/index.ts +0 -19
  41. package/src-new-ts/layout/Layout.ts +0 -3
  42. package/src-new-ts/render/CanvasRenderer.ts +0 -24
  43. package/src-new-ts/render/SVGRenderer.js +0 -316
  44. package/src-new-ts/util.ts +0 -3
  45. package/src-old/action/Classify.js +0 -53
  46. package/src-old/action/Densify.js +0 -199
  47. package/src-old/action/Partition.js +0 -531
  48. package/src-old/action/Repeat.js +0 -106
  49. package/src-old/action/Repopulate.js +0 -44
  50. package/src-old/action/Stratify.js +0 -156
  51. package/src-old/basic/Gradient.js +0 -37
  52. package/src-old/basic/Point.js +0 -51
  53. package/src-old/basic/Rectangle.js +0 -63
  54. package/src-old/bind/bindToAngle.js +0 -56
  55. package/src-old/bind/bindToAreaMark.js +0 -360
  56. package/src-old/bind/bindToColor.js +0 -114
  57. package/src-old/bind/bindToLink.js +0 -81
  58. package/src-old/bind/bindToPosition.js +0 -283
  59. package/src-old/bind/bindToRadialDistance.js +0 -62
  60. package/src-old/bind/bindToSize.js +0 -235
  61. package/src-old/bind/bindToText.js +0 -60
  62. package/src-old/bind/bindToThickness.js +0 -100
  63. package/src-old/constraint/AffixConstraint.js +0 -129
  64. package/src-old/constraint/AlignConstraint.js +0 -58
  65. package/src-old/core/Encoding.js +0 -336
  66. package/src-old/core/Scale.js +0 -322
  67. package/src-old/core/SceneLoader.js +0 -290
  68. package/src-old/core/SceneValidator.js +0 -232
  69. package/src-old/core/SpecExecutor.js +0 -113
  70. package/src-old/core/SpecGenerator.js +0 -350
  71. package/src-old/data/DataImporter.js +0 -64
  72. package/src-old/data/DataScope.js +0 -124
  73. package/src-old/data/DataTable.js +0 -338
  74. package/src-old/data/Network.js +0 -106
  75. package/src-old/data/Tree.js +0 -251
  76. package/src-old/data/transform/Bin.js +0 -46
  77. package/src-old/data/transform/Filter.js +0 -48
  78. package/src-old/data/transform/Groupby.js +0 -18
  79. package/src-old/data/transform/KDE.js +0 -58
  80. package/src-old/data/transform/Sort.js +0 -14
  81. package/src-old/data/transform/Split.js +0 -5
  82. package/src-old/data/transform/partition.js +0 -46
  83. package/src-old/history/UndoRedoStack +0 -0
  84. package/src-old/index.js +0 -271
  85. package/src-old/indexSVG.js +0 -259
  86. package/src-old/interaction/Interaction.js +0 -91
  87. package/src-old/interaction/MouseEvent.js +0 -8
  88. package/src-old/interaction/Selection.js +0 -9
  89. package/src-old/interaction/brush.js +0 -362
  90. package/src-old/item/Segment.js +0 -29
  91. package/src-old/item/Vertex.js +0 -118
  92. package/src-old/item/composite/Collection.js +0 -106
  93. package/src-old/item/composite/Glyph.js +0 -19
  94. package/src-old/item/composite/Group.js +0 -310
  95. package/src-old/item/composite/Scene.js +0 -1251
  96. package/src-old/item/mark/ArcPath.js +0 -181
  97. package/src-old/item/mark/AreaPath.js +0 -78
  98. package/src-old/item/mark/CirclePath.js +0 -102
  99. package/src-old/item/mark/EllipsePath.js +0 -5
  100. package/src-old/item/mark/Image.js +0 -101
  101. package/src-old/item/mark/LinkPath.js +0 -118
  102. package/src-old/item/mark/Mark.js +0 -163
  103. package/src-old/item/mark/Path.js +0 -494
  104. package/src-old/item/mark/PointText.js +0 -201
  105. package/src-old/item/mark/PolygonPath.js +0 -64
  106. package/src-old/item/mark/RectPath.js +0 -88
  107. package/src-old/item/mark/RingPath.js +0 -92
  108. package/src-old/item/refs/Axis.js +0 -362
  109. package/src-old/item/refs/EncodingAxis.js +0 -515
  110. package/src-old/item/refs/Gridlines.js +0 -144
  111. package/src-old/item/refs/LayoutAxis.js +0 -316
  112. package/src-old/item/refs/Legend.js +0 -273
  113. package/src-old/layout/Circular.js +0 -95
  114. package/src-old/layout/Force.js +0 -52
  115. package/src-old/layout/Grid.js +0 -423
  116. package/src-old/layout/Layout.js +0 -13
  117. package/src-old/layout/Packing.js +0 -56
  118. package/src-old/layout/Stack.js +0 -264
  119. package/src-old/layout/Strata.js +0 -88
  120. package/src-old/layout/Sugiyama.js +0 -59
  121. package/src-old/layout/TidyTree.js +0 -105
  122. package/src-old/layout/Treemap.js +0 -87
  123. package/src-old/renderer/SVGInteractionHandler.js +0 -241
  124. package/src-old/renderer/SVGRenderer.js +0 -325
  125. package/src-old/renderer/WebGLRenderer.js +0 -1097
  126. package/src-old/renderer/WebGLRenderer2.js +0 -249
  127. package/src-old/renderer/threejs/Line2.js +0 -18
  128. package/src-old/renderer/threejs/LineGeometry.js +0 -77
  129. package/src-old/renderer/threejs/LineMaterial.js +0 -605
  130. package/src-old/renderer/threejs/LineSegments2.js +0 -281
  131. package/src-old/renderer/threejs/LineSegmentsGeometry.js +0 -226
  132. package/src-old/renderer/threejs/Wireframe.js +0 -51
  133. package/src-old/renderer/threejs/WireframeGeometry2.js +0 -16
  134. package/src-old/scale/areaSize.js +0 -0
  135. package/src-old/scale/domain.js +0 -38
  136. package/src-old/util/Constants.js +0 -180
  137. package/src-old/util/DataUtil.js +0 -35
  138. package/src-old/util/ItemUtil.js +0 -586
  139. package/src-old/util/Numerical.js +0 -33
  140. package/tests/demo-tests/README.md +0 -80
  141. package/tests/demo-tests/SVG2PNG.js +0 -56
  142. package/tests/demo-tests/demos2CanvasPNGs.js +0 -69
  143. package/tests/demo-tests/demos2ScenesSVGs.js +0 -100
  144. package/tests/demo-tests/pathElementWorker.js +0 -91
  145. package/tests/demo-tests/pixelTest.js +0 -62
  146. package/tests/demo-tests/renderDemos.html +0 -132
  147. package/tests/demo-tests/serializationTest.js +0 -36
  148. package/tests/demo-tests/serializeDemos.html +0 -134
  149. package/tests/unit-tests/README.md +0 -4
  150. package/tests/unit-tests/jasmine-browser.json +0 -21
  151. package/tests/unit-tests/jasmine.json +0 -14
  152. package/tests/unit-tests/testSpec.js +0 -274
@@ -1,178 +0,0 @@
1
- import Dataflow, { OpType } from "./operator/Dataflow.js";
2
- import BoundsVar from "./variable/BoundsVar.js";
3
- import DataScopeVar from "./variable/DataScopeVar.js";
4
- import Variable, { VarType } from "../depgraph/variable/Variable.js";
5
- import Edge from "./Edge.js";
6
- import ChannelVar from "./variable/ChannelVar.js";
7
- import FieldVar from "./variable/FieldVar.js";
8
- import DomainVar from "./variable/DomainVar.js";
9
- import DomainBuilder from "./operator/DomainBuilder.js";
10
- import BoundsEvaluator from "./operator/BoundsEvaluator.js";
11
-
12
- export default class DependencyGraph {
13
-
14
- constructor() {
15
- this._variables = {};
16
- this._operators = {};
17
- this._edges = [];
18
- }
19
-
20
- getVariable(type, ...params) {
21
- if (Object.values(VarType).indexOf(type) < 0)
22
- throw new Error('Variable Type Not Known');
23
- let v = this.findVariable(type, params);
24
- if (v) return v;
25
- switch (type) {
26
- case VarType.CHANNEL:
27
- v = new ChannelVar(type, params[0], params[1]);
28
- break;
29
- case VarType.FIELD:
30
- v = new FieldVar(type, params[0], params[1]);
31
- break;
32
- case VarType.DOMAIN:
33
- v = new DomainVar(type, params[0]);
34
- break;
35
- case VarType.DATASCOPE:
36
- v = new DataScopeVar(type, params[0]);
37
- break;
38
- case VarType.BOUNDS:
39
- v = new BoundsVar(type, params[0]);
40
- break;
41
- default:
42
- break;
43
- }
44
- if (!(type in this._variables))
45
- this._variables[type] = {}
46
- this._variables[type][v.id] = v;
47
- return v;
48
- }
49
-
50
- // createDataflowOperator(type, input, output) {
51
- // if (Object.values(OpType).indexOf(type) < 0)
52
- // throw new Error('Operator Type Not Known');
53
- // let op = new Dataflow(type, input, output);
54
- // if (!(type in this._operators))
55
- // this._operators[type] = {}
56
- // this._operators[type][op.id] = op;
57
- // return op;
58
- // }
59
-
60
- createDataflowOperator(type, ...params) {
61
- if (Object.values(OpType).indexOf(type) < 0)
62
- throw new Error('Operator Type Not Known');
63
- let op;
64
- switch (type) {
65
- case OpType.EVAL_BBOX:
66
- op = new BoundsEvaluator(type);
67
- break;
68
- case OpType.BUILD_DOMAIN:
69
- op = new DomainBuilder(type, params[0]);
70
- break;
71
- }
72
- if (!(type in this._operators))
73
- this._operators[type] = {}
74
- this._operators[type][op.id] = op;
75
- return op;
76
- }
77
-
78
- connect(fromNode, toNode, isDirected = true){
79
- if (fromNode instanceof Variable && toNode instanceof Dataflow) {
80
- const edge = new Edge(fromNode, toNode, isDirected);
81
- this._edges.push(edge);
82
- fromNode.outgoingEdges.push(edge);
83
- toNode.inputVars.push(fromNode);
84
- } else if (fromNode instanceof Dataflow && toNode instanceof Variable) {
85
- const edge = new Edge(fromNode, toNode, isDirected);
86
- this._edges.push(edge);
87
- fromNode.outputVar = toNode;
88
- toNode.incomingEdges.push(edge);
89
- } else {
90
- throw new Error("An edge must connect a variable and an operator.");
91
- }
92
- }
93
-
94
- // createOperator(type, ...params) {
95
- // if (Object.values(OpType).indexOf(type) < 0)
96
- // throw new Error('Operator Type Not Known');
97
- // let op;
98
- // switch(type) {
99
- // case OpType.ENCODER:
100
- // if ((params[0] == "x" || params[0] == "y") && isMark(params[1]))
101
- // op = new MarkPosEncoder(params[0], params[1]);
102
- // break;
103
- // case OpType.LAYOUT:
104
- // break;
105
- // case OpType.CONSTRAINT:
106
- // break;
107
- // default:
108
- // break;
109
- // }
110
- // if (!(type in this._operators))
111
- // this._operators[type] = {}
112
- // this._operators[type][op.id] = op;
113
- // return op;
114
- // }
115
-
116
- /**
117
- *
118
- * @param {object} def:
119
- */
120
- addInteraction(def) {
121
-
122
- }
123
-
124
- processChange(varType, ...params) {
125
- // if (Object.values(VarType).indexOf(varType) < 0)
126
- // throw new Error('Unknown Variable Type: ' + varType);
127
- let v = this.findVariable(varType, params);
128
- if (!v)
129
- throw new Error('Unable to find variables matching the described change');
130
- for (let e of v.outgoingEdges) {
131
- if (e.isDirected) {
132
- let dfOp = e.toNode;
133
- dfOp.run();
134
- }
135
- }
136
- }
137
-
138
-
139
- findVariable(varType, params) {
140
- if (!(varType in this._variables))
141
- return null;
142
- let vars = Object.values(this._variables[varType]);
143
- switch (varType) {
144
- case VarType.CHANNEL:
145
- return vars.find(d => d.channel == params[0] && d.element.classId == params[1].classId);
146
- case VarType.FIELD:
147
- return vars.find(d => d.field == params[0] && d.dataset == params[1]);
148
- case VarType.SCALE:
149
- return vars.find(d => d.scale == params[0]);
150
- case VarType.DATASCOPE:
151
- default:
152
- return vars.find(d => d.element.classId == params[0].classId);
153
- }
154
- }
155
-
156
- // addEdges(...stp) {
157
- // for (let p of stp) {
158
- // this.addEdge(p[0], p[1]);
159
- // }
160
- // }
161
-
162
- // addEdge(source, target) {
163
- // // let e = new Edge(source, target);
164
- // // this._edges.push(e);
165
- // // if (!(source.id in this._outgoing))
166
- // // this._outgoing[source.id] = [];
167
- // // this._outgoing[source.id].push(target.id);
168
-
169
- // // if (!(target.id in this._incoming))
170
- // // this._incoming[target.id] = [];
171
- // // this._incoming[target.id].push(source.id);
172
- // if (source instanceof Variable && target instanceof Dataflow) {
173
- // source.targetDf = target;
174
- // } else if (source instanceof Dataflow && target instanceof Variable) {
175
-
176
- // }
177
- // }
178
- }
@@ -1,9 +0,0 @@
1
- export default class Edge {
2
-
3
- constructor(fromNode, toNode, isDirected = true) {
4
- this.fromNode = fromNode;
5
- this.toNode = toNode;
6
- this.isDirected = isDirected;
7
- }
8
-
9
- }
@@ -1,110 +0,0 @@
1
- import { OpType } from "./operator/Dataflow.js";
2
- import { VarType } from "./variable/Variable.js";
3
- import DependencyGraph from "./DepGraph.js";
4
-
5
- export default function constructDepGraph(scn) {
6
-
7
- let g = new DependencyGraph();
8
-
9
- for (let enc of scn.encodings) {
10
- parseEncoding(enc, g);
11
- }
12
-
13
- //more to handle later: layouts and constraints
14
-
15
- console.log("variables", g._variables);
16
- console.log("operators", g._operators);
17
-
18
- return g;
19
- }
20
-
21
- /**
22
- * this method takes an encoding definition enc as input (take a look at src/core/Encoding.js),
23
- * and adds the necessary nodes and edges to the graph.
24
- */
25
- function parseEncoding(enc, g) {
26
-
27
- switch (enc.channel) {
28
- case "width":
29
- case "height":
30
- case "radius":
31
- case "outerRadius":
32
- case "innerRadius":
33
- case "area":
34
- case "fontSize":
35
- case "strokeWidth":
36
- case "x": {
37
- const item = enc.anyItem;
38
- const datascope = g._createVariable(VarType.DATASCOPE, item);
39
- //new Variable(VarType.DATASCOPE, this, item.type === ItemType.Vertex && !item.dataScope? item.parent.dataScope : item.dataScope);
40
-
41
- const scale = g._createVariable(VarType.SCALE, enc.scale);
42
- const channel = g._createVariable(VarType.CHANNEL, enc.channel, item);
43
- const op = g._createOperator(OpType.ENCODER, enc.channel, item);
44
-
45
- //TODO: depending the item type, create channel node that will be used as input to the operator
46
- //e.g., if the item is a mark and its parent is a collection whose position is not bound to data,
47
- //then the collection's left coordinate should be the input
48
- g.addEdge(datascope, op);
49
- g.addEdge(scale, op);
50
- g.addEdge(op, channel);
51
-
52
- let axes = enc.axes;
53
- for (let axis of axes) {
54
- const axisX = g._createVariable(VarType.CHANNEL, 'x', axis);
55
- g.addEdge(op, axisX);
56
- const axisY = g._createVariable(VarType.CHANNEL, 'y', axis);
57
- }
58
- break;
59
- }
60
- default:
61
- break;
62
- // case "y": {
63
- // const scale = new ScaleNode(NodeType.VARIABLE, "n"+generateUniqueID(), enc.scale);
64
- // const collectionTop = new ChannelNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'collections.top', enc.scene._bounds.top);
65
- // const op = new Operator('y-encoder', "n"+generateUniqueID(),);
66
- // const out1 = new ChannelNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'y-axis.y', null);
67
- // const out2 = new ChannelNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'mark.y', null);
68
- // // confused for slope graph - how to determine? Hardcode?
69
- // const out3 = new ChannelNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'y-axis.x', null);
70
- // const _datascope = new DataScopeNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'collections.datascope', null);
71
- // }
72
- // case "fillColor": {
73
- // const op = new Operator('fill-encoder', "n"+generateUniqueID(),);
74
- // const scale = new ScaleNode(NodeType.VARIABLE, "n"+generateUniqueID(), enc.scale);
75
- // const out1 = new ChannelNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'mark.fill', null);
76
- // const _datascope = new DataScopeNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'collections.datascope', null);
77
-
78
- // this._variables[_datascope.id] = _datascope;
79
- // this._variables[scale.id] = scale;
80
- // this._variables[out1.id] = out1;
81
- // this._operators[op.id] = op;
82
-
83
- // this._edges.push(...[new Edge(scale.id, op.id),
84
- // new Edge(_datascope.id, op.id),
85
- // new Edge(op.id, out1.id)]);
86
- // break;
87
- // }
88
- // case "strokeColor": {
89
- // const op = new Operator('stroke-encoder', "n"+generateUniqueID(),);
90
- // const scale = new ScaleNode(NodeType.VARIABLE, "n"+generateUniqueID(), enc.scale);
91
- // const out1 = new ChannelNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'path.stroke', null);
92
- // const _datascope = new DataScopeNode(NodeType.VARIABLE, "n"+generateUniqueID(), 'collections.datascope', null);
93
-
94
- // this._variables[_datascope.id] = _datascope;
95
- // this._variables[scale.id] = scale;
96
- // this._variables[out1.id] = out1;
97
- // this._operators[op.id] = op;
98
-
99
- // this._edges.push(...[new Edge(scale.id, op.id),
100
- // new Edge(_datascope.id, op.id),
101
- // new Edge(op.id, out1.id)]);
102
- // break;
103
- // }
104
- // case "fillGradient":
105
- // case "angle":
106
- // case "text":
107
- // case "radialDistance":
108
- // case "thickness":
109
- }
110
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Signal should capture the following info:
3
- * variable type
4
- * value
5
- */
6
- export default class Signal {
7
-
8
- constructor(varType, val, object) {
9
-
10
- }
11
-
12
- }
@@ -1,30 +0,0 @@
1
- import { ElementType } from "../../action/createElement";
2
- import { getPeers } from "../../action/traverseScene";
3
- import { Rectangle } from "../variable/BoundsVar";
4
- import Dataflow from "./Dataflow";
5
-
6
- export default class BoundsEvaluator extends Dataflow {
7
-
8
- constructor(opType) {
9
- super(opType);
10
- }
11
-
12
- run() {
13
- let elem = this._outputVar.element,
14
- peers = getPeers(elem);
15
- //elem._bounds = computeBounds(elem);
16
- for (let p of peers)
17
- p._bounds = this.computeBounds(p);
18
- }
19
-
20
- computeBounds(elem) {
21
- switch (elem.type) {
22
- case ElementType.Circle:
23
- return this.computeCircleBounds(elem);
24
- }
25
- }
26
-
27
- computeCircleBounds(elem) {
28
- return new Rectangle(elem.x - elem.radius, elem.y - elem.radius, elem.radius * 2, elem.radius * 2);
29
- }
30
- }
@@ -1,41 +0,0 @@
1
- import { generateUniqueID } from "../../util.js";
2
-
3
- export default class Dataflow {
4
- //constructor(opType, input, output) {
5
- constructor(opType) {
6
- this._id = opType + "_" + generateUniqueID();
7
- this._type = opType;
8
- this._inputVars = [];
9
- this._outputVar = undefined;
10
- }
11
-
12
- run() {}
13
-
14
- get id() {
15
- return this._id;
16
- }
17
-
18
- get type() {
19
- return this._type;
20
- }
21
-
22
- get inputVars() {
23
- return this._inputVars;
24
- }
25
-
26
- get outputVar() {
27
- return this._outputVar;
28
- }
29
-
30
- set outputVar(v) {
31
- this._outputVar = v;
32
- }
33
- }
34
-
35
- export const OpType = Object.freeze({
36
- ENCODE: 'encoder',
37
- LAYOUT: 'layout',
38
- CONSTRAIN: 'constraint',
39
- EVAL_BBOX: 'evalBBox',
40
- BUILD_DOMAIN: 'buildDomain'
41
- });
@@ -1,50 +0,0 @@
1
- import { getPeers } from "../../action/traverseScene";
2
- import { FieldType } from "../../data/field";
3
- import DataScopeVar from "../variable/DataScopeVar";
4
- import FieldVar from "../variable/FieldVar";
5
- import Dataflow from "./Dataflow";
6
-
7
- export default class DomainBuilder extends Dataflow {
8
-
9
- constructor(opType, aggregator) {
10
- super(opType);
11
- this._aggregator = aggregator;
12
- }
13
-
14
- run() {
15
- let scale = this._outputVar.scale,
16
- inputFieldVar = this.inputVars.find(d => d instanceof FieldVar),
17
- inputDSVar = this.inputVars.find(d => d instanceof DataScopeVar);
18
-
19
- let field = inputFieldVar.field,
20
- table = inputFieldVar.dataset,
21
- elem = inputDSVar.element;
22
- // console.log(field, table, elem);
23
- //scale.domain = computeDomain(field, tbl, getPeers(elem));
24
- let dataScopes = getPeers(elem).map(d => d.dataScope),
25
- domain;
26
- switch (table.getFieldType(field)) {
27
- case FieldType.Boolean:
28
- break;
29
-
30
- case FieldType.Date:
31
- domain = dataScopes.map(d => d.getFieldValue(field));
32
- break;
33
-
34
- case FieldType.String:
35
- try {
36
- domain = dataScopes.map(d => d.getFieldValue(field));
37
- } catch (error) {
38
- throw new Error("Cannot bind " + this.channel + " to " + field + " : " + error);
39
- }
40
- break;
41
-
42
- default: //integer or number
43
- domain = dataScopes.map(d => d.aggregateNumericalField(field, this._aggregator));
44
- break;
45
- }
46
- scale.domain = domain;
47
- console.log(scale.domain);
48
- }
49
-
50
- }
@@ -1,45 +0,0 @@
1
- import { ElementType } from "../action/createElement.js";
2
- import { OpType } from "./operator/Dataflow.js";
3
- import { VarType } from "./variable/Variable.js";
4
-
5
- //to move to createElement.js
6
- export function newMarkCreated(m, rt) {
7
- switch (m.type) {
8
- case ElementType.Circle: {
9
- let b = rt.getVariable(VarType.BOUNDS, m),
10
- x = rt.getVariable(VarType.CHANNEL, "x", m),
11
- y = rt.getVariable(VarType.CHANNEL, "y", m),
12
- r = rt.getVariable(VarType.CHANNEL, "radius", m),
13
- bbox = rt.createDataflowOperator(OpType.EVAL_BBOX);
14
- // bbox = rt.createDataflowOperator(OpType.EVALBBOX, [x, y, r], b);
15
- rt.connect(x, bbox);
16
- rt.connect(y, bbox);
17
- rt.connect(r, bbox);
18
- rt.connect(bbox, b);
19
- bbox.run();
20
- }
21
- break;
22
- }
23
-
24
- // console.log("variables", rt._variables);
25
- // console.log("operators", rt._operators);
26
- }
27
-
28
-
29
- export function encodingSpecified(field, channel, elem, scale, aggregator, rt) {
30
- //first find/create all the variables in the dep graph (rt)
31
- let fv = rt.getVariable(VarType.FIELD, field, elem.dataScope.dataTable),
32
- cv = rt.getVariable(VarType.CHANNEL, channel, elem),
33
- dv = rt.getVariable(VarType.DOMAIN, scale),
34
- dsv = rt.getVariable(VarType.DATASCOPE, elem),
35
- db = rt.createDataflowOperator(OpType.BUILD_DOMAIN, aggregator);
36
- rt.connect(fv, db);
37
- rt.connect(dsv, db);
38
- rt.connect(db, dv);
39
- db.run();
40
- //console.log(fv, cv, dv);
41
- //then create a new dataflow operator that takes the field and elem data scope as input
42
- //and outputs a scale
43
- //then create a new dataflow operator that takes the scale and elem collection bounds as input
44
- //and channel variables as output
45
- }
@@ -1,81 +0,0 @@
1
- import { ElementType } from "../../action/createElement.js";
2
- import Variable from "./Variable.js";
3
-
4
- export default class BoundsVar extends Variable {
5
-
6
- constructor(type, elem) {
7
- super(type);
8
- this._elem = elem;
9
- }
10
-
11
- get element() {
12
- return this._elem;
13
- }
14
-
15
- }
16
-
17
- export class Rectangle {
18
-
19
- constructor(x, y, width, height) {
20
- this._x = x;
21
- this._y = y;
22
- this._width = width;
23
- this._height = height;
24
- }
25
-
26
- toJSON() {
27
- let json = {};
28
- json.x = this._x;
29
- json.y = this._y;
30
- json.width = this._width;
31
- json.height = this._height;
32
- return json;
33
- }
34
-
35
- union(rect) {
36
- let left = Math.min(this.left, rect.left),
37
- top = Math.min(this.top, rect.top),
38
- right = Math.max(this.right, rect.right),
39
- btm = Math.max(this.bottom, rect.bottom),
40
- wd = right - left,
41
- ht = btm - top;
42
- return new Rectangle(left + wd/2, top + ht/2, wd, ht);
43
- }
44
-
45
- clone() {
46
- return new Rectangle(this.x, this.y, this.width, this.height);
47
- }
48
-
49
- get left() {
50
- return this._x - this._width/2;
51
- }
52
-
53
- get right() {
54
- return this._x + this._width/2;
55
- }
56
-
57
- get top() {
58
- return this._y - this._height/2;
59
- }
60
-
61
- get bottom() {
62
- return this._y + this._height/2;
63
- }
64
-
65
- get x() {
66
- return this._x;
67
- }
68
-
69
- get y() {
70
- return this._y;
71
- }
72
-
73
- contains(x, y) {
74
- return this.left <= x && this.right >= x && this.top <= y && this.bottom >= y;
75
- }
76
-
77
- overlap(r) {
78
- return !(this.right < r.left || this.bottom < r.top || this.left > r.right || this.top > r.bottom);
79
- }
80
-
81
- }
@@ -1,17 +0,0 @@
1
- import Variable from "./Variable.js";
2
-
3
- export default class ChannelVar extends Variable {
4
- constructor(type, channel, elem) {
5
- super(type);
6
- this._channel = channel;
7
- this._elem = elem;
8
- }
9
-
10
- get channel() {
11
- return this._channel;
12
- }
13
-
14
- get element() {
15
- return this._elem;
16
- }
17
- }
@@ -1,12 +0,0 @@
1
- import Variable from "./Variable.js";
2
-
3
- export default class DataScopeVar extends Variable {
4
- constructor(type, item) {
5
- super(type);
6
- this._item = item;
7
- }
8
-
9
- get element() {
10
- return this._item;
11
- }
12
- }
@@ -1,15 +0,0 @@
1
- import Variable from "./Variable.js";
2
-
3
- /**
4
- * domain of a scale
5
- */
6
- export default class DomainVar extends Variable {
7
- constructor(type, scale) {
8
- super(type);
9
- this._scale = scale;
10
- }
11
-
12
- get scale() {
13
- return this._scale;
14
- }
15
- }
@@ -1,17 +0,0 @@
1
- import Variable from "./Variable.js";
2
-
3
- export default class FieldVar extends Variable {
4
- constructor(type, field, dataset) {
5
- super(type);
6
- this._field = field;
7
- this._dataset = dataset;
8
- }
9
-
10
- get field() {
11
- return this._field;
12
- }
13
-
14
- get dataset() {
15
- return this._dataset;
16
- }
17
- }
@@ -1,8 +0,0 @@
1
- import Variable from "./Variable.js";
2
-
3
- export default class LayoutParameter extends Variable {
4
-
5
- constructor(type) {
6
- super(type);
7
- }
8
- }
@@ -1,13 +0,0 @@
1
- import Variable from "./Variable.js";
2
- // ToDo:: To be deleted
3
- export default class ScaleVar extends Variable {
4
-
5
- constructor(type,scale) {
6
- super(type);
7
- this._scale = scale;
8
- }
9
-
10
- get scale() {
11
- return this._scale;
12
- }
13
- }