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
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import Path from "./Path";
|
|
2
|
-
import {ItemType} from "../../util/Constants";
|
|
3
|
-
import Rectangle from "../../basic/Rectangle";
|
|
4
|
-
import Point from "../../basic/Point";
|
|
5
|
-
import { degree2radian } from "../../util/ItemUtil";
|
|
6
|
-
|
|
7
|
-
export default class ArcPath extends Path {
|
|
8
|
-
|
|
9
|
-
constructor(args) {
|
|
10
|
-
super(args);
|
|
11
|
-
|
|
12
|
-
this._type = ItemType.Arc;
|
|
13
|
-
this.closed = true;
|
|
14
|
-
this._x = "x" in args ? args.x : 0;
|
|
15
|
-
this._y = "y" in args ? args.y : 0;
|
|
16
|
-
this._innerRadius = "innerRadius" in args ? args.innerRadius : 100;
|
|
17
|
-
this._outerRadius = "outerRadius" in args ? args.outerRadius : 200;
|
|
18
|
-
this._startAngle = "startAngle" in args ? args.startAngle : 0;
|
|
19
|
-
this._endAngle = "endAngle" in args ? args.endAngle : 90;
|
|
20
|
-
this._sr = degree2radian(this._startAngle);
|
|
21
|
-
this._er = degree2radian(this._endAngle);
|
|
22
|
-
|
|
23
|
-
let isx = this._x + this._innerRadius * Math.cos(this._sr), isy = this._y - this._innerRadius * Math.sin(this._sr),
|
|
24
|
-
iex = this._x + this._innerRadius * Math.cos(this._er), iey = this._y - this._innerRadius * Math.sin(this._er),
|
|
25
|
-
osx = this._x + this._outerRadius * Math.cos(this._sr), osy = this._y - this._outerRadius * Math.sin(this._sr),
|
|
26
|
-
oex = this._x + this._outerRadius * Math.cos(this._er), oey = this._y - this._outerRadius * Math.sin(this._er);
|
|
27
|
-
this._setVertices([[isx, isy], [osx, osy], [oex, oey], [iex, iey]]);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get type() {
|
|
31
|
-
return this._innerRadius === 0 ? ItemType.Pie : ItemType.Arc;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
set type(t) {
|
|
35
|
-
this._type = t;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get innerRadius() {
|
|
39
|
-
return this._innerRadius;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
set innerRadius(r) {
|
|
43
|
-
this._innerRadius = r;
|
|
44
|
-
this.vertices[0].x = this._x + this._innerRadius * Math.cos(this._sr);
|
|
45
|
-
this.vertices[0].y = this._y - this._innerRadius * Math.sin(this._sr);
|
|
46
|
-
this.vertices[3].x = this._x + this._innerRadius * Math.cos(this._er);
|
|
47
|
-
this.vertices[3].y = this._y - this._innerRadius * Math.sin(this._er);
|
|
48
|
-
this._updateBounds();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get outerRadius() {
|
|
52
|
-
return this._outerRadius;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get thickness() {
|
|
56
|
-
return this._outerRadius - this._innerRadius;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
set outerRadius(r) {
|
|
60
|
-
this._outerRadius = r;
|
|
61
|
-
this.vertices[1].x = this._x + this._outerRadius * Math.cos(this._sr);
|
|
62
|
-
this.vertices[1].y = this._y - this._outerRadius * Math.sin(this._sr);
|
|
63
|
-
this.vertices[2].x = this._x + this._outerRadius * Math.cos(this._er);
|
|
64
|
-
this.vertices[2].y = this._y - this._outerRadius * Math.sin(this._er);
|
|
65
|
-
this._updateBounds();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
get x() {
|
|
69
|
-
return this._x;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get y() {
|
|
73
|
-
return this._y;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
get center() {
|
|
77
|
-
return new Point(this._x, this._y);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
set x(v) {
|
|
81
|
-
this._x = v;
|
|
82
|
-
this.vertices[0].x = this._x + this._innerRadius * Math.cos(this._sr);
|
|
83
|
-
this.vertices[1].x = this._x + this._outerRadius * Math.cos(this._sr);
|
|
84
|
-
this.vertices[2].x = this._x + this._outerRadius * Math.cos(this._er);
|
|
85
|
-
this.vertices[3].x = this._x + this._innerRadius * Math.cos(this._er);
|
|
86
|
-
this._updateBounds();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
set y(v) {
|
|
90
|
-
this._y = v;
|
|
91
|
-
this.vertices[0].y = this._y - this._innerRadius * Math.sin(this._sr);
|
|
92
|
-
this.vertices[1].y = this._y - this._outerRadius * Math.sin(this._sr);
|
|
93
|
-
this.vertices[2].y = this._y - this._outerRadius * Math.sin(this._er);
|
|
94
|
-
this.vertices[3].y = this._y - this._innerRadius * Math.sin(this._er);
|
|
95
|
-
this._updateBounds();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get startAngle() {
|
|
99
|
-
return this._startAngle;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
get endAngle() {
|
|
103
|
-
return this._endAngle;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
get angle() {
|
|
107
|
-
if (this._endAngle < this._startAngle) {
|
|
108
|
-
return this._endAngle + 360 - this._startAngle;
|
|
109
|
-
} else {
|
|
110
|
-
return this._endAngle - this._startAngle;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
//if the sweep angle of this arc contains the arc argument
|
|
115
|
-
sweepOver(arc) {
|
|
116
|
-
let as = this.startAngle, ae = this.endAngle;
|
|
117
|
-
if (ae < as) ae += 360;
|
|
118
|
-
let bs = arc.startAngle, be = arc.endAngle;
|
|
119
|
-
if (be < bs) be += 360;
|
|
120
|
-
return bs >= as && bs <= ae && be >= as && be <= ae;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
_doTranslate(dx, dy) {
|
|
124
|
-
this._x += dx;
|
|
125
|
-
this._y += dy;
|
|
126
|
-
this.vertices[0].x = this._x + this._innerRadius * Math.cos(this._sr);
|
|
127
|
-
this.vertices[0].y = this._y - this._innerRadius * Math.sin(this._sr);
|
|
128
|
-
this.vertices[1].x = this._x + this._outerRadius * Math.cos(this._sr);
|
|
129
|
-
this.vertices[1].y = this._y - this._outerRadius * Math.sin(this._sr);
|
|
130
|
-
this.vertices[2].x = this._x + this._outerRadius * Math.cos(this._er);
|
|
131
|
-
this.vertices[2].y = this._y - this._outerRadius * Math.sin(this._er);
|
|
132
|
-
this.vertices[3].x = this._x + this._innerRadius * Math.cos(this._er);
|
|
133
|
-
this.vertices[3].y = this._y - this._innerRadius * Math.sin(this._er);
|
|
134
|
-
this._updateBounds();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
_updateBounds() {
|
|
138
|
-
this._bounds = new Rectangle(this._x - this._outerRadius, this._y - this._outerRadius, this._outerRadius * 2, this._outerRadius * 2);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
copyPropertiesTo(target) {
|
|
142
|
-
super.copyPropertiesTo(target);
|
|
143
|
-
target._x = this._x;
|
|
144
|
-
target._y = this._y;
|
|
145
|
-
target._innerRadius = this._innerRadius;
|
|
146
|
-
target._outerRadius = this._outerRadius;
|
|
147
|
-
target._startAngle = this._startAngle;
|
|
148
|
-
target._endAngle = this._endAngle;
|
|
149
|
-
target._sr = this._sr;
|
|
150
|
-
target._er = this._er;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
getSVGPathData() {
|
|
154
|
-
let angle = this._endAngle < this._startAngle? this._endAngle + 360 - this._startAngle : this._endAngle - this._startAngle,
|
|
155
|
-
largeArc = angle > 180 ? 1 : 0;
|
|
156
|
-
let cmds = [
|
|
157
|
-
"M " + this.vertices[0].x + ", " + this.vertices[0].y,
|
|
158
|
-
"L " + this.vertices[1].x + ", " + this.vertices[1].y,
|
|
159
|
-
"A " + [this._outerRadius, this._outerRadius, angle, largeArc, 0, this.vertices[2].x, this.vertices[2].y].join(" "),
|
|
160
|
-
"L " + this.vertices[3].x + ", " + this.vertices[3].y,
|
|
161
|
-
"A " + [this._innerRadius, this._innerRadius, angle, largeArc, 1, this.vertices[0].x, this.vertices[0].y].join(" ")
|
|
162
|
-
];
|
|
163
|
-
return cmds.join(" ");
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
adjustAngle(startAngle, endAngle) {
|
|
167
|
-
this._startAngle = startAngle;
|
|
168
|
-
this._endAngle = endAngle;
|
|
169
|
-
this._sr = degree2radian(this._startAngle);
|
|
170
|
-
this._er = degree2radian(this._endAngle);
|
|
171
|
-
|
|
172
|
-
this.vertices[0].x = this._x + this._innerRadius * Math.cos(this._sr);
|
|
173
|
-
this.vertices[0].y = this._y - this._innerRadius * Math.sin(this._sr);
|
|
174
|
-
this.vertices[1].x = this._x + this._outerRadius * Math.cos(this._sr);
|
|
175
|
-
this.vertices[1].y = this._y - this._outerRadius * Math.sin(this._sr);
|
|
176
|
-
this.vertices[2].x = this._x + this._outerRadius * Math.cos(this._er);
|
|
177
|
-
this.vertices[2].y = this._y - this._outerRadius * Math.sin(this._er);
|
|
178
|
-
this.vertices[3].x = this._x + this._innerRadius * Math.cos(this._er);
|
|
179
|
-
this.vertices[3].y = this._y - this._innerRadius * Math.sin(this._er);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import Path from "./Path";
|
|
2
|
-
import Segment from "../Segment";
|
|
3
|
-
import {ItemType} from "../../util/Constants"
|
|
4
|
-
|
|
5
|
-
export default class AreaPath extends Path {
|
|
6
|
-
|
|
7
|
-
constructor(args) {
|
|
8
|
-
super(args);
|
|
9
|
-
|
|
10
|
-
this.type = ItemType.Area;
|
|
11
|
-
this.closed = true;
|
|
12
|
-
this._orientation = ("orientation" in args) ? args.orientation : undefined;
|
|
13
|
-
this._baseline = ("baseline" in args) ? args.baseline : undefined;
|
|
14
|
-
|
|
15
|
-
//add last segment to close the path
|
|
16
|
-
if (args && "vertices" in args)
|
|
17
|
-
this.segments.push(new Segment(this.vertices[this.vertices.length-1], this.vertices[0], this, this.segmentCounter++));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get baseline() {
|
|
21
|
-
return this._baseline;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
set baseline(b) {
|
|
25
|
-
this._baseline = b;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//this._orientation is set during densification
|
|
29
|
-
get orientation() {
|
|
30
|
-
return this._orientation;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
set orientation(o) {
|
|
34
|
-
this._orientation = o;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get firstVertexPair() {
|
|
38
|
-
return [this.vertices[0], this.vertices[this.vertices.length-1]];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get width() {
|
|
42
|
-
return this.vertices[this.vertices.length/2].x - this.vertices[0].x;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get height() {
|
|
46
|
-
return this.vertices[this.vertices.length/2].y - this.vertices[0].y;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
get left() {
|
|
50
|
-
return this.vertices[0].x;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
get top() {
|
|
54
|
-
return this.vertices[0].y;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
copyPropertiesTo(target) {
|
|
58
|
-
super.copyPropertiesTo(target);
|
|
59
|
-
target._baseline = this._baseline;
|
|
60
|
-
target._orientation = this._orientation;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
resizeArea(wd, ht) {
|
|
64
|
-
let x1 = this.vertices[this.vertices.length/2].x,
|
|
65
|
-
y1 = this.vertices[this.vertices.length/2].y,
|
|
66
|
-
width = this.width,
|
|
67
|
-
height = this.height;
|
|
68
|
-
for (let v of this.vertices) {
|
|
69
|
-
v.x = x1 + (wd/width) * (v.x - x1);
|
|
70
|
-
v.y = y1 + (ht/height) * (v.y - y1);
|
|
71
|
-
}
|
|
72
|
-
this._updateBounds();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
getSVGPathData() {
|
|
76
|
-
return super.getSVGPathData() + " " + 'z';
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import Path from "./Path";
|
|
2
|
-
import Rectangle from "../../basic/Rectangle";
|
|
3
|
-
|
|
4
|
-
export default class CirclePath extends Path {
|
|
5
|
-
|
|
6
|
-
constructor(args) {
|
|
7
|
-
super(args);
|
|
8
|
-
|
|
9
|
-
// this.type = ItemType.Circle;
|
|
10
|
-
// this.closed = true;
|
|
11
|
-
this.attrs["x"] = "x" in args ? args.x : 0;
|
|
12
|
-
this.attrs["y"] = "y" in args ? args.y : 0;
|
|
13
|
-
this.attrs["radius"] = "radius" in args ? args.radius : 100;
|
|
14
|
-
// this.attrs["x"] = args.hasOwnProperty("x") ? args.x : 0;
|
|
15
|
-
// this.attrs["y"] = args.hasOwnProperty("y") ? args.y : 0;
|
|
16
|
-
// this.attrs["radius"] = args.hasOwnProperty("radius") ? args.radius : 100;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get radius() {
|
|
20
|
-
return this.attrs["radius"];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get x() {
|
|
24
|
-
return this.attrs["x"];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get y() {
|
|
28
|
-
return this.attrs["y"]; //this.attrs["y"];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get area() {
|
|
32
|
-
return Math.PI * Math.pow(this.radius, 2);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
set x(v) {
|
|
36
|
-
this.attrs["x"] = v;
|
|
37
|
-
this._updateBounds();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
set y(v) {
|
|
41
|
-
this.attrs["y"] = v;
|
|
42
|
-
this._updateBounds();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
set radius(r) {
|
|
46
|
-
this.attrs["radius"] = r;
|
|
47
|
-
this._updateBounds();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
set area(a) {
|
|
51
|
-
this.attrs["radius"] = Math.sqrt(a);
|
|
52
|
-
this._updateBounds();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// set width(w) {
|
|
56
|
-
// this.attrs["radius"] = w/2;
|
|
57
|
-
// this._updateBounds();
|
|
58
|
-
// }
|
|
59
|
-
|
|
60
|
-
// set height(h) {
|
|
61
|
-
// this.attrs["radius"] = h/2;
|
|
62
|
-
// this._updateBounds();
|
|
63
|
-
// }
|
|
64
|
-
|
|
65
|
-
resize(w, h, xRef, yRef) {
|
|
66
|
-
let r = Math.min(w, h)/2, diff = r - this.attrs["radius"];
|
|
67
|
-
this.attrs["radius"] = r;
|
|
68
|
-
if (xRef == "right") {
|
|
69
|
-
this.attrs["x"] -= diff;
|
|
70
|
-
} else {
|
|
71
|
-
this.attrs["x"] += diff;
|
|
72
|
-
}
|
|
73
|
-
if (yRef == "top") {
|
|
74
|
-
this.attrs["y"] += diff;
|
|
75
|
-
} else {
|
|
76
|
-
this.attrs["y"] -= diff;
|
|
77
|
-
}
|
|
78
|
-
this._updateBounds();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
_doTranslate(dx, dy) {
|
|
82
|
-
this.attrs["x"] += dx;
|
|
83
|
-
this.attrs["y"] += dy;
|
|
84
|
-
this._updateBounds();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
_updateBounds() {
|
|
88
|
-
this._bounds = new Rectangle(this.attrs["x"] - this.attrs["radius"], this.attrs["y"] - this.attrs["radius"], this.attrs["radius"] * 2, this.attrs["radius"] * 2);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
copyPropertiesTo(target) {
|
|
92
|
-
super.copyPropertiesTo(target);
|
|
93
|
-
target.attrs["x"] = this.attrs["x"];
|
|
94
|
-
target.attrs["y"] = this.attrs["y"];
|
|
95
|
-
target.attrs["radius"] = this.attrs["radius"];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
getSVGPathData() {
|
|
99
|
-
return ["M", this.x, this.y, "m", -this.radius, ", 0 a", this.radius, ",", this.radius, "0 1,0", this.radius * 2, ",0 a", this.radius, ",", this.radius, "0 1,0", -(this.radius * 2), ",0"].join(" ");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import Rectangle from "../../basic/Rectangle";
|
|
2
|
-
import { ItemType } from "../../util/Constants";
|
|
3
|
-
import Mark from "./Mark";
|
|
4
|
-
|
|
5
|
-
export default class Image extends Mark {
|
|
6
|
-
|
|
7
|
-
constructor(args) {
|
|
8
|
-
super(args);
|
|
9
|
-
this.type = ItemType.Image;
|
|
10
|
-
this._src = args.src;
|
|
11
|
-
this._x = "x" in args ? args.x : 0;
|
|
12
|
-
this._y = "y" in args ? args.y : 0;
|
|
13
|
-
this._width = "width" in args ? args.width : 100;
|
|
14
|
-
this._height = "height" in args ? args.height: 100;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
toJSON() {
|
|
18
|
-
let json = super.toJSON();
|
|
19
|
-
json.src = this._src;
|
|
20
|
-
json.x = this._x;
|
|
21
|
-
json.y = this._y;
|
|
22
|
-
json.width = this._width;
|
|
23
|
-
json.height = this._height;
|
|
24
|
-
return json;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
get src() {
|
|
29
|
-
return this._src;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
set src(s) {
|
|
33
|
-
this._src = s;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get width() {
|
|
37
|
-
return this._width;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
set width(w) {
|
|
41
|
-
this._width = w;
|
|
42
|
-
this._updateBounds();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get height() {
|
|
46
|
-
return this._height;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
set height(h) {
|
|
50
|
-
this._height = h;
|
|
51
|
-
this._updateBounds();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get x() {
|
|
55
|
-
return this._x;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
set x(v) {
|
|
59
|
-
this._x = v;
|
|
60
|
-
this._updateBounds();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get y() {
|
|
64
|
-
return this._y;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
set y(v) {
|
|
68
|
-
this._y = v;
|
|
69
|
-
this._updateBounds();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get bounds() {
|
|
73
|
-
if (!this._bounds)
|
|
74
|
-
this._updateBounds();
|
|
75
|
-
return this._bounds;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
_updateBounds() {
|
|
79
|
-
this._bounds = new Rectangle(this._x, this._y, this._width, this._height);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
copyPropertiesTo(target) {
|
|
83
|
-
target.attrs = Object.assign({}, this.attrs);
|
|
84
|
-
target.styles = Object.assign({}, this.styles);
|
|
85
|
-
|
|
86
|
-
if (this._dataScope)
|
|
87
|
-
target._dataScope = this._dataScope.clone();
|
|
88
|
-
|
|
89
|
-
target.x = this._x;
|
|
90
|
-
target.y = this._y;
|
|
91
|
-
target.width = this._width;
|
|
92
|
-
target.height = this._height;
|
|
93
|
-
target.src = this._src;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
_doTranslate(dx, dy) {
|
|
97
|
-
this._x += dx;
|
|
98
|
-
this._y += dy;
|
|
99
|
-
this._updateBounds();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import Rectangle from "../../basic/Rectangle";
|
|
2
|
-
import { ItemType } from "../../util/Constants";
|
|
3
|
-
import { SVGProvider } from "../../util/ItemUtil";
|
|
4
|
-
import Path from "./Path";
|
|
5
|
-
|
|
6
|
-
export default class LinkPath extends Path {
|
|
7
|
-
|
|
8
|
-
constructor(args) {
|
|
9
|
-
super(args);
|
|
10
|
-
|
|
11
|
-
this.type = ItemType.Link;
|
|
12
|
-
this.linkMode = "linkMode" in args ? args.linkMode : "linear";
|
|
13
|
-
|
|
14
|
-
this.source = undefined;
|
|
15
|
-
this.target = undefined;
|
|
16
|
-
this.directed = "directed" in args ? args.directed : false;
|
|
17
|
-
|
|
18
|
-
this.sourceAnchor = "sourceAnchor" in args ? args.sourceAnchor : ["center", "middle"];
|
|
19
|
-
this.targetAnchor = "targetAnchor" in args ? args.targetAnchor : ["center", "middle"];
|
|
20
|
-
this.sourceOffset = "sourceOffset" in args ? args.sourceOffset : [0, 0];
|
|
21
|
-
this.targetOffset = "targetOffset" in args ? args.targetOffset : [0, 0];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//Implemented according to bezier curve implementation in d3
|
|
26
|
-
// https://github.com/d3/d3-shape/blob/main/src/link/index.js
|
|
27
|
-
radialvalue(x, y) {
|
|
28
|
-
let xBar = x- Math.PI / 2;
|
|
29
|
-
x = y * Math.cos(xBar);
|
|
30
|
-
y = y * Math.sin(x);
|
|
31
|
-
return [x, y];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
bezierCurveHorizontal(x1, y1, x2, y2) {
|
|
35
|
-
return `M ${x1} ${y1} C ${(x1+x2)/2} ${y1} ${x1} ${y2} ${x2} ${y2}`
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
bezierCurveVertical(x1, y1, x2, y2) {
|
|
39
|
-
return `M ${x1} ${y1} C ${x1} ${(y1+y2)/2} ${x2} ${y1} ${x2} ${y2}`
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
bezierCurveRadial(x1, y1, x2, y2) {
|
|
43
|
-
let r0 = this.radialvalue(x1, y1),
|
|
44
|
-
r1 = this.radialvalue(x1, (y1 + y2) / 2),
|
|
45
|
-
r2 = this.radialvalue(x2, y1),
|
|
46
|
-
r3 = this.radialvalue(x2, y2);
|
|
47
|
-
|
|
48
|
-
return `M ${r0[0]} ${r0[1]} C ${r1[0]} ${r1[1]} ${r2[0]} ${r2[1]} ${r3[0]} ${r3[1]}`
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
arc(x1, y1, x2, y2, clockwise) {
|
|
52
|
-
let sx = x1, ex = x2, sy = y1, ey = y2;
|
|
53
|
-
if (!this.directed && x1 > x2) {
|
|
54
|
-
sx = x2;
|
|
55
|
-
ex = x1;
|
|
56
|
-
sy = y2;
|
|
57
|
-
ey = y1;
|
|
58
|
-
}
|
|
59
|
-
let rx = Math.abs(sx-ex)/2,
|
|
60
|
-
ry = Math.abs(sy-ey)/2,
|
|
61
|
-
r = Math.max(rx, ry),
|
|
62
|
-
sweep_flag = clockwise ? 1 : 0;
|
|
63
|
-
return `M ${sx} ${sy} A ${r} ${r} 0 0 ${sweep_flag} ${ex} ${ey}`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
_updateBounds() {
|
|
67
|
-
if (this.source != undefined && this.target != undefined){
|
|
68
|
-
let x1 = this.source.bounds[this.sourceAnchor[0]] + this.sourceOffset[0],
|
|
69
|
-
y1 = this.source.bounds[this.sourceAnchor[1]] + this.sourceOffset[1],
|
|
70
|
-
x2 = this.target.bounds[this.targetAnchor[0]] + this.targetOffset[0],
|
|
71
|
-
y2 = this.target.bounds[this.targetAnchor[1]] + this.targetOffset[1];
|
|
72
|
-
this._bounds = new Rectangle(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x1 - x2), Math.abs(y1 - y2));
|
|
73
|
-
} else {
|
|
74
|
-
this._bounds = new Rectangle(0,0,0,0);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
getSVGPathData() {
|
|
80
|
-
if (this.source === undefined || this.target === undefined)
|
|
81
|
-
return "";
|
|
82
|
-
let x1 = this.source.bounds[this.sourceAnchor[0]] + this.sourceOffset[0],
|
|
83
|
-
y1 = this.source.bounds[this.sourceAnchor[1]] + this.sourceOffset[1],
|
|
84
|
-
x2 = this.target.bounds[this.targetAnchor[0]] + this.targetOffset[0],
|
|
85
|
-
y2 = this.target.bounds[this.targetAnchor[1]] + this.targetOffset[1];
|
|
86
|
-
switch (this.linkMode) {
|
|
87
|
-
case "curveHorizontal":
|
|
88
|
-
return this.bezierCurveHorizontal(x1, y1, x2, y2);
|
|
89
|
-
case "curveVertical":
|
|
90
|
-
return this.bezierCurveVertical(x1, y1, x2, y2);
|
|
91
|
-
case "arcClockwise":
|
|
92
|
-
return this.arc(x1, y1, x2, y2, true);
|
|
93
|
-
case "arcAntiClockwise":
|
|
94
|
-
return this.arc(x1, y1, x2, y2, false);
|
|
95
|
-
case "linear":
|
|
96
|
-
default:
|
|
97
|
-
return `M ${x1} ${y1} L ${x2} ${y2}`;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
copyPropertiesTo(target) {
|
|
102
|
-
super.copyPropertiesTo(target);
|
|
103
|
-
target.sourceAnchor = this.sourceAnchor.slice();
|
|
104
|
-
target.targetAnchor = this.targetAnchor.slice();
|
|
105
|
-
target.sourceOffset = this.sourceOffset.slice();
|
|
106
|
-
target.targetOffset = this.targetOffset.slice();
|
|
107
|
-
target.linkMode = this.linkMode;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
getPointAt(frac) {
|
|
111
|
-
const svg = SVGProvider.getSVG();
|
|
112
|
-
let path = document.createElementNS("http://www.w3.org/2000/svg", 'path');
|
|
113
|
-
path.setAttribute("d", this.getSVGPathData());
|
|
114
|
-
svg.appendChild(path);
|
|
115
|
-
let len = path.getTotalLength();
|
|
116
|
-
return path.getPointAtLength(len * frac);
|
|
117
|
-
}
|
|
118
|
-
}
|