mascot-vis 2.0.0 → 3.0.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.
Files changed (157) hide show
  1. package/README.md +4 -3
  2. package/dist/mascot-es.js +27745 -0
  3. package/dist/mascot-min.js +186 -199
  4. package/dist/mascot-umd.js +27781 -0
  5. package/js/depGraphVis.js +66 -0
  6. package/package.json +23 -15
  7. package/src-new-ts/action/createElement.ts +91 -0
  8. package/src-new-ts/action/encode.js +20 -0
  9. package/src-new-ts/action/repeat.js +128 -0
  10. package/src-new-ts/action/traverseScene.js +41 -0
  11. package/src-new-ts/data/Network.js +2 -0
  12. package/src-new-ts/data/Scope.js +135 -0
  13. package/src-new-ts/data/Table.js +263 -0
  14. package/src-new-ts/data/Tree.js +3 -0
  15. package/src-new-ts/data/field.ts +115 -0
  16. package/src-new-ts/data/import.ts +96 -0
  17. package/src-new-ts/data/predicate.ts +82 -0
  18. package/src-new-ts/depgraph/DepGraph.js +178 -0
  19. package/src-new-ts/depgraph/Edge.js +9 -0
  20. package/src-new-ts/depgraph/SceneGraph2DepGraph.js +110 -0
  21. package/src-new-ts/depgraph/Signal.js +12 -0
  22. package/src-new-ts/depgraph/operator/BoundsEvaluator.js +30 -0
  23. package/src-new-ts/depgraph/operator/Dataflow.js +41 -0
  24. package/src-new-ts/depgraph/operator/DomainBuilder.js +50 -0
  25. package/src-new-ts/depgraph/updateDepGraph.js +45 -0
  26. package/src-new-ts/depgraph/variable/BoundsVar.js +81 -0
  27. package/src-new-ts/depgraph/variable/ChannelVar.js +17 -0
  28. package/src-new-ts/depgraph/variable/DataScopeVar.js +12 -0
  29. package/src-new-ts/depgraph/variable/DomainVar.js +15 -0
  30. package/src-new-ts/depgraph/variable/FieldVar.js +17 -0
  31. package/src-new-ts/depgraph/variable/LayoutParameter.js +8 -0
  32. package/src-new-ts/depgraph/variable/ScaleVar.js +13 -0
  33. package/src-new-ts/depgraph/variable/Variable.js +39 -0
  34. package/src-new-ts/element/gradient/LinearGradient.js +37 -0
  35. package/src-new-ts/element/group/Collection.js +109 -0
  36. package/src-new-ts/element/group/Group.js +307 -0
  37. package/src-new-ts/element/group/Scene.js +98 -0
  38. package/src-new-ts/element/mark/CircleMark.ts +85 -0
  39. package/src-new-ts/element/mark/Mark.ts +233 -0
  40. package/src-new-ts/element/mark/PathMark.js +483 -0
  41. package/src-new-ts/element/mark/Segment.js +29 -0
  42. package/src-new-ts/element/mark/Vertex.js +118 -0
  43. package/src-new-ts/encode/Scale.ts +115 -0
  44. package/src-new-ts/index.ts +19 -0
  45. package/src-new-ts/layout/Layout.ts +3 -0
  46. package/src-new-ts/render/CanvasRenderer.ts +24 -0
  47. package/src-new-ts/render/SVGRenderer.js +316 -0
  48. package/src-new-ts/util.ts +3 -0
  49. package/src-old/action/Classify.js +53 -0
  50. package/src-old/action/Densify.js +199 -0
  51. package/src-old/action/Partition.js +531 -0
  52. package/src-old/action/Repeat.js +106 -0
  53. package/src-old/action/Repopulate.js +44 -0
  54. package/src-old/action/Stratify.js +156 -0
  55. package/src-old/basic/Gradient.js +37 -0
  56. package/src-old/basic/Point.js +51 -0
  57. package/src-old/basic/Rectangle.js +63 -0
  58. package/src-old/bind/bindToAngle.js +56 -0
  59. package/src-old/bind/bindToAreaMark.js +360 -0
  60. package/src-old/bind/bindToColor.js +114 -0
  61. package/src-old/bind/bindToLink.js +81 -0
  62. package/src-old/bind/bindToPosition.js +283 -0
  63. package/src-old/bind/bindToRadialDistance.js +62 -0
  64. package/src-old/bind/bindToSize.js +235 -0
  65. package/src-old/bind/bindToText.js +60 -0
  66. package/src-old/bind/bindToThickness.js +100 -0
  67. package/src-old/constraint/AffixConstraint.js +129 -0
  68. package/src-old/constraint/AlignConstraint.js +58 -0
  69. package/src-old/core/Encoding.js +336 -0
  70. package/src-old/core/Scale.js +322 -0
  71. package/src-old/core/SceneLoader.js +290 -0
  72. package/src-old/core/SceneValidator.js +232 -0
  73. package/src-old/core/SpecExecutor.js +113 -0
  74. package/src-old/core/SpecGenerator.js +350 -0
  75. package/src-old/data/DataImporter.js +64 -0
  76. package/src-old/data/DataScope.js +124 -0
  77. package/src-old/data/DataTable.js +338 -0
  78. package/src-old/data/Network.js +106 -0
  79. package/src-old/data/Tree.js +251 -0
  80. package/src-old/data/transform/Bin.js +46 -0
  81. package/src-old/data/transform/Filter.js +48 -0
  82. package/src-old/data/transform/Groupby.js +18 -0
  83. package/src-old/data/transform/KDE.js +58 -0
  84. package/src-old/data/transform/Sort.js +14 -0
  85. package/src-old/data/transform/Split.js +5 -0
  86. package/src-old/data/transform/partition.js +46 -0
  87. package/src-old/history/UndoRedoStack +0 -0
  88. package/src-old/index.js +271 -0
  89. package/src-old/indexSVG.js +259 -0
  90. package/src-old/interaction/Interaction.js +91 -0
  91. package/src-old/interaction/MouseEvent.js +8 -0
  92. package/src-old/interaction/Selection.js +9 -0
  93. package/src-old/interaction/brush.js +362 -0
  94. package/src-old/item/Segment.js +29 -0
  95. package/src-old/item/Vertex.js +118 -0
  96. package/src-old/item/composite/Collection.js +106 -0
  97. package/src-old/item/composite/Glyph.js +19 -0
  98. package/src-old/item/composite/Group.js +310 -0
  99. package/src-old/item/composite/Scene.js +1251 -0
  100. package/src-old/item/mark/ArcPath.js +181 -0
  101. package/src-old/item/mark/AreaPath.js +78 -0
  102. package/src-old/item/mark/CirclePath.js +102 -0
  103. package/src-old/item/mark/EllipsePath.js +5 -0
  104. package/src-old/item/mark/Image.js +101 -0
  105. package/src-old/item/mark/LinkPath.js +118 -0
  106. package/src-old/item/mark/Mark.js +163 -0
  107. package/src-old/item/mark/Path.js +494 -0
  108. package/src-old/item/mark/PointText.js +201 -0
  109. package/src-old/item/mark/PolygonPath.js +64 -0
  110. package/src-old/item/mark/RectPath.js +88 -0
  111. package/src-old/item/mark/RingPath.js +92 -0
  112. package/src-old/item/refs/Axis.js +362 -0
  113. package/src-old/item/refs/EncodingAxis.js +515 -0
  114. package/src-old/item/refs/Gridlines.js +144 -0
  115. package/src-old/item/refs/LayoutAxis.js +316 -0
  116. package/src-old/item/refs/Legend.js +273 -0
  117. package/src-old/layout/Circular.js +95 -0
  118. package/src-old/layout/Force.js +52 -0
  119. package/src-old/layout/Grid.js +423 -0
  120. package/src-old/layout/Layout.js +13 -0
  121. package/src-old/layout/Packing.js +56 -0
  122. package/src-old/layout/Stack.js +264 -0
  123. package/src-old/layout/Strata.js +88 -0
  124. package/src-old/layout/Sugiyama.js +59 -0
  125. package/src-old/layout/TidyTree.js +105 -0
  126. package/src-old/layout/Treemap.js +87 -0
  127. package/src-old/renderer/SVGInteractionHandler.js +241 -0
  128. package/src-old/renderer/SVGRenderer.js +325 -0
  129. package/src-old/renderer/WebGLRenderer.js +1097 -0
  130. package/src-old/renderer/WebGLRenderer2.js +249 -0
  131. package/src-old/renderer/threejs/Line2.js +18 -0
  132. package/src-old/renderer/threejs/LineGeometry.js +77 -0
  133. package/src-old/renderer/threejs/LineMaterial.js +605 -0
  134. package/src-old/renderer/threejs/LineSegments2.js +281 -0
  135. package/src-old/renderer/threejs/LineSegmentsGeometry.js +226 -0
  136. package/src-old/renderer/threejs/Wireframe.js +51 -0
  137. package/src-old/renderer/threejs/WireframeGeometry2.js +16 -0
  138. package/src-old/scale/areaSize.js +0 -0
  139. package/src-old/scale/domain.js +38 -0
  140. package/src-old/util/Constants.js +180 -0
  141. package/src-old/util/DataUtil.js +35 -0
  142. package/src-old/util/ItemUtil.js +586 -0
  143. package/src-old/util/Numerical.js +33 -0
  144. package/tests/demo-tests/README.md +80 -0
  145. package/tests/demo-tests/SVG2PNG.js +56 -0
  146. package/tests/demo-tests/demos2CanvasPNGs.js +69 -0
  147. package/tests/demo-tests/demos2ScenesSVGs.js +100 -0
  148. package/tests/demo-tests/pathElementWorker.js +91 -0
  149. package/tests/demo-tests/pixelTest.js +62 -0
  150. package/tests/demo-tests/renderDemos.html +132 -0
  151. package/tests/demo-tests/serializationTest.js +36 -0
  152. package/tests/demo-tests/serializeDemos.html +134 -0
  153. package/tests/unit-tests/README.md +4 -0
  154. package/tests/unit-tests/jasmine-browser.json +21 -0
  155. package/tests/unit-tests/jasmine.json +14 -0
  156. package/tests/unit-tests/testSpec.js +274 -0
  157. package/dist/mascot.js +0 -24446
@@ -0,0 +1,362 @@
1
+ import Group from "../composite/Group";
2
+ import { ItemCounter } from "../../util/ItemUtil";
3
+ import { ItemType } from "../../util/Constants";
4
+ import PointText from "../mark/PointText";
5
+
6
+ export default class Axis extends Group{
7
+
8
+ constructor(args){
9
+ super();
10
+ this.type = ItemType.Axis;
11
+ this.id = this.type + ItemCounter[this.type]++;
12
+
13
+ this._strokeColor = "strokeColor" in args ? args["strokeColor"] : "#555";
14
+ this._textColor = "textColor" in args ? args.textColor : "#555";
15
+ this._fontSize = "fontSize" in args? args.fontSize: "12px";
16
+
17
+ this._tickOffset = "tickOffset" in args ? args["tickOffset"] : 0;
18
+ this._tickSize = "tickSize" in args ? args["tickSize"] : 5;
19
+ this._tickAnchor = args.tickAnchor ? args.tickAnchor : "middle";
20
+
21
+ this._tickVisible = "tickVisible" in args ? args["tickVisible"] : true; // && !args["tickVisible"] ? "hidden" : "visible";
22
+ this._pathVisible = "pathVisible" in args ? args["pathVisible"] : true; // && !args["pathVisible"] ? "hidden" : "visible";
23
+
24
+ this._labelOffset = "labelOffset" in args ? args["labelOffset"] : 15;
25
+ this._labelFormat = "labelFormat" in args ? args["labelFormat"] : "";
26
+
27
+ this._titleOffset = "titleOffset" in args ? args["titleOffset"] : 40;
28
+ if ("titleAnchor" in args) {
29
+ this._titleAnchor = args.titleAnchor;
30
+ } else {
31
+ if (this.channel == "x" || this.channel == "width"){
32
+ this._titleAnchor = this._orientation == "top" ? ["center", "bottom"] : ["center", "top"];
33
+ } else {
34
+ this._titleAnchor = this._orientation == "left" ? ["right", "middle"] : ["left", "middle"];
35
+ }
36
+ }
37
+ this._rotateYTitle = "rotateTitle" in args && !args.rotateTitle ? false : true;
38
+ this._titlePosition = args.titlePosition;
39
+
40
+ if ("labelRotation" in args)
41
+ this._labelRotation = args.labelRotation;
42
+ else
43
+ this._labelRotation = 0;
44
+
45
+ //flip is useful when items are top aligned for example, and the axis needs to start from the top
46
+ //this is different from invert scale, and this is computed when positioning, not specified by users
47
+ //this._flip = "flip" in args ? args["flip"] : false;
48
+ }
49
+
50
+ toJSON() {
51
+ //let json = {args: {}};
52
+ let json = super.toJSON();
53
+ json.type = this.type;
54
+ json.id = this.id;
55
+ json.field = this._field;
56
+ json.channel = this._channel;
57
+ if (!("args" in json))
58
+ json.args = {};
59
+ json.args.orientation = this._orientation;
60
+ json.args.strokeColor = this._strokeColor;
61
+ json.args.textColor = this._textColor;
62
+ json.args.tickOffset = this._tickOffset;
63
+ json.args.tickSize = this._tickSize;
64
+ json.args.tickAnchor = this._tickAnchor;
65
+ json.args.tickVisible = this._tickVisible;
66
+ json.args.pathVisible = this._pathVisible;
67
+ json.args.labelOffset = this._labelOffset;
68
+ json.args.labelFormat = this._labelFormat;
69
+ if (this._labelRotation)
70
+ json.args.labelRotation = this._labelRotation;
71
+ json.args.showTitle = this._showTitle;
72
+ json.args.tickValues = this._tickValues;
73
+ json.args.titleAnchor = this._titleAnchor;
74
+ json.args.titleOffset = this._titleOffset;
75
+ json.args.titlePosition = this._titlePosition;
76
+ json.args.rotateTitle = this._rotateYTitle;
77
+ return json;
78
+ }
79
+
80
+ get field(){
81
+ return this._field;
82
+ }
83
+
84
+ get channel(){
85
+ return this._channel;
86
+ }
87
+
88
+ get orientation(){
89
+ return this._orientation;
90
+ }
91
+
92
+ set orientation(o){
93
+ this._orientation = o;
94
+ this.reposition();
95
+ }
96
+
97
+ get pathX(){
98
+ if (this.channel == "y" || this.channel == "height") {
99
+ if (this._position !== undefined)
100
+ return this._position;
101
+ if (this._path) { // encoding axis
102
+ return this._path.vertices[0].x;
103
+ } else if (this._rules && this._rules.firstChild) {
104
+ return this._rules.firstChild.vertices[0].x;
105
+ }
106
+ }
107
+ return undefined;
108
+ }
109
+
110
+ set pathX(v){
111
+ if (this.channel == "y" || this.channel == "height")
112
+ this._posArg = v;
113
+ this.reposition();
114
+ }
115
+
116
+ get pathPosition() {
117
+ if (this.channel == "x" || this.channel == "width") {
118
+ return this.pathY;
119
+ } else
120
+ return this.pathX;
121
+ }
122
+
123
+ set pathPosition(v) {
124
+ if (this.channel == "x" || this.channel == "width") {
125
+ this.pathY = v;
126
+ } else if (this.channel == "y" || this.channel == "height") {
127
+ this.pathX = v;
128
+ }
129
+ }
130
+
131
+ get pathY(){
132
+ if (this.channel == "x" || this.channel == "width") {
133
+ if (this._position !== undefined)
134
+ return this._position;
135
+ if (this._path) {
136
+ return this._path.vertices[0].y;
137
+ } else if (this._rules && this._rules.firstChild) {
138
+ return this._rules.firstChild.vertices[0].y;
139
+ }
140
+ }
141
+ return undefined;
142
+ }
143
+
144
+ set pathY(v){
145
+ if (this.channel == "x" || this.channel == "width")
146
+ this._posArg = v;
147
+ this.reposition();
148
+ }
149
+
150
+ get tickOffset(){
151
+ return this._tickOffset;
152
+ }
153
+
154
+ set tickOffset(o){
155
+ this._tickOffset = o;
156
+ this._positionTicks();
157
+ }
158
+
159
+ get titleOffset(){
160
+ return this._titleOffset;
161
+ }
162
+
163
+ set titleOffset(o){
164
+ this._titleOffset = o;
165
+ }
166
+
167
+ get tickSize(){
168
+ return this._tickSize;
169
+ }
170
+
171
+ set tickSize(o){
172
+ this._tickSize = o;
173
+ this._positionTicks();
174
+ }
175
+
176
+ set tickValues(values){
177
+ this._tickValues = values;
178
+ this._generateTicks();
179
+ this._positionTicks();
180
+ }
181
+
182
+ get tickValues() {
183
+ return this._tickValues;
184
+ }
185
+
186
+ set labelValues(values){
187
+ this._labelValues = values;
188
+ this._generateLabels();
189
+ this._positionLabels();
190
+ }
191
+
192
+ get labelValues(){
193
+ return this._labelValues;
194
+ }
195
+
196
+ get tickAnchor(){
197
+ return this._tickAnchor;
198
+ }
199
+
200
+ set tickAnchor(o){
201
+ this._tickAnchor = o;
202
+ }
203
+
204
+ get tickVisible(){
205
+ return this._tickVisible;
206
+ }
207
+
208
+ set tickVisible(o){
209
+ this._tickVisible = o;
210
+ for (let l of this._ticks.children)
211
+ l.visibility = o ? "visible" : "hidden";
212
+ }
213
+
214
+ get pathVisible(){
215
+ return this._pathVisible;
216
+ }
217
+
218
+ set pathVisible(o){
219
+ this._pathVisible = o;
220
+ let p = [];
221
+ if (this._path)
222
+ p.push(this._path);
223
+ if (this._rules)
224
+ this._rules.children.forEach(c => p.push(c));
225
+ for (let l of p)
226
+ l.visibility = o ? "visible" : "hidden";
227
+ }
228
+
229
+ get labelOffset(){
230
+ return this._labelOffset;
231
+ }
232
+
233
+ set labelOffset(o){
234
+ this._labelOffset = o;
235
+ this._positionLabels();
236
+ }
237
+
238
+ get labelFormat(){
239
+ return this._labelFormat;
240
+ }
241
+
242
+ set labelFormat(o){
243
+ this._labelFormat = o;
244
+ this._generateLabels();
245
+ this._positionLabels();
246
+ }
247
+
248
+ get labelRotation(){
249
+ return this._labelRotation;
250
+ }
251
+
252
+ set labelRotation(o){
253
+ this._labelRotation = o;
254
+ if (this._labels && this._labels.children) {
255
+ let anchor = this._orientation == "bottom" ? ["center", "top"] : ["center", "bottom"];
256
+ if (o) {
257
+ for (let l of this._labels.children) {
258
+ l._rotate = [this._labelRotation, l.x, l.y];
259
+ l.anchor = ["right", anchor[1]];
260
+ }
261
+ } else {
262
+ for (let l of this._labels.children) {
263
+ l._rotate = undefined;
264
+ }
265
+ }
266
+ }
267
+ }
268
+
269
+ get showTitle(){
270
+ return this._showTitle;
271
+ }
272
+
273
+ set showTitle(s){
274
+ this._showTitle = s;
275
+ if (!this._title) {
276
+ this._generateTitle();
277
+ this._positionTitle();
278
+ }
279
+ this._title.visibility = s ? "visible" : "hidden";
280
+ }
281
+
282
+ get titleAnchor(){
283
+ return this._titleAnchor;
284
+ }
285
+
286
+ set titleAnchor(a){
287
+ this._titleAnchor = a;
288
+ }
289
+
290
+ get titlePosition(){
291
+ return this._titlePosition;
292
+ }
293
+
294
+ set titlePosition(a){
295
+ this._titlePosition = a;
296
+ }
297
+
298
+ get rotateTitle(){
299
+ return this._rotateYTitle;
300
+ }
301
+
302
+ set rotateTitle(r){
303
+ this._rotateYTitle = r;
304
+ }
305
+
306
+ get title(){
307
+ return this._titleText;
308
+ }
309
+
310
+ set title(t){
311
+ this._titleText = t;
312
+ }
313
+
314
+ get includeZero() {
315
+ if (this.encoding)
316
+ return this.encoding.scale.includeZero;
317
+ else
318
+ return false;
319
+ }
320
+
321
+ set includeZero(b) {
322
+ if (this.encoding)
323
+ this.encoding.scale.includeZero = b;
324
+ }
325
+
326
+ _generatePath(){}
327
+
328
+ _generateTicks(){}
329
+
330
+ _generateLabels(){}
331
+
332
+ _generateTitle(){
333
+ this._title = new PointText({"text": this._titleText, fillColor: this._textColor, fontWeight: "bold"});
334
+ this._title.id = this.id + "-title";
335
+ this.addChild(this._title);
336
+ }
337
+
338
+ _positionPath(){}
339
+
340
+ _positionTicks(){}
341
+
342
+ _positionLabels(){}
343
+
344
+ _positionTitle(){}
345
+
346
+ // eslint-disable-next-line no-unused-vars
347
+ matches(item) {}
348
+
349
+ reposition() {
350
+ if (this.encoding)
351
+ this._determineAxisFlip();
352
+ this._positionPath();
353
+ this._positionTicks();
354
+ this._positionLabels();
355
+ if (this._showTitle)
356
+ this._positionTitle();
357
+ if (this._channel === "radialDistance" && this._rotate){
358
+ this._rotate = [this._rotate[0], this._item.parent.x, this._item.parent.y];
359
+ }
360
+ this._updateBounds();
361
+ }
362
+ }