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.
- package/README.md +4 -3
- package/dist/mascot-es.js +27745 -0
- package/dist/mascot-min.js +186 -199
- package/dist/mascot-umd.js +27781 -0
- package/js/depGraphVis.js +66 -0
- package/package.json +23 -15
- package/src-new-ts/action/createElement.ts +91 -0
- package/src-new-ts/action/encode.js +20 -0
- package/src-new-ts/action/repeat.js +128 -0
- package/src-new-ts/action/traverseScene.js +41 -0
- package/src-new-ts/data/Network.js +2 -0
- package/src-new-ts/data/Scope.js +135 -0
- package/src-new-ts/data/Table.js +263 -0
- package/src-new-ts/data/Tree.js +3 -0
- package/src-new-ts/data/field.ts +115 -0
- package/src-new-ts/data/import.ts +96 -0
- package/src-new-ts/data/predicate.ts +82 -0
- package/src-new-ts/depgraph/DepGraph.js +178 -0
- package/src-new-ts/depgraph/Edge.js +9 -0
- package/src-new-ts/depgraph/SceneGraph2DepGraph.js +110 -0
- package/src-new-ts/depgraph/Signal.js +12 -0
- package/src-new-ts/depgraph/operator/BoundsEvaluator.js +30 -0
- package/src-new-ts/depgraph/operator/Dataflow.js +41 -0
- package/src-new-ts/depgraph/operator/DomainBuilder.js +50 -0
- package/src-new-ts/depgraph/updateDepGraph.js +45 -0
- package/src-new-ts/depgraph/variable/BoundsVar.js +81 -0
- package/src-new-ts/depgraph/variable/ChannelVar.js +17 -0
- package/src-new-ts/depgraph/variable/DataScopeVar.js +12 -0
- package/src-new-ts/depgraph/variable/DomainVar.js +15 -0
- package/src-new-ts/depgraph/variable/FieldVar.js +17 -0
- package/src-new-ts/depgraph/variable/LayoutParameter.js +8 -0
- package/src-new-ts/depgraph/variable/ScaleVar.js +13 -0
- package/src-new-ts/depgraph/variable/Variable.js +39 -0
- package/src-new-ts/element/gradient/LinearGradient.js +37 -0
- package/src-new-ts/element/group/Collection.js +109 -0
- package/src-new-ts/element/group/Group.js +307 -0
- package/src-new-ts/element/group/Scene.js +98 -0
- package/src-new-ts/element/mark/CircleMark.ts +85 -0
- package/src-new-ts/element/mark/Mark.ts +233 -0
- package/src-new-ts/element/mark/PathMark.js +483 -0
- package/src-new-ts/element/mark/Segment.js +29 -0
- package/src-new-ts/element/mark/Vertex.js +118 -0
- package/src-new-ts/encode/Scale.ts +115 -0
- package/src-new-ts/index.ts +19 -0
- package/src-new-ts/layout/Layout.ts +3 -0
- package/src-new-ts/render/CanvasRenderer.ts +24 -0
- package/src-new-ts/render/SVGRenderer.js +316 -0
- package/src-new-ts/util.ts +3 -0
- package/src-old/action/Classify.js +53 -0
- package/src-old/action/Densify.js +199 -0
- package/src-old/action/Partition.js +531 -0
- package/src-old/action/Repeat.js +106 -0
- package/src-old/action/Repopulate.js +44 -0
- package/src-old/action/Stratify.js +156 -0
- package/src-old/basic/Gradient.js +37 -0
- package/src-old/basic/Point.js +51 -0
- package/src-old/basic/Rectangle.js +63 -0
- package/src-old/bind/bindToAngle.js +56 -0
- package/src-old/bind/bindToAreaMark.js +360 -0
- package/src-old/bind/bindToColor.js +114 -0
- package/src-old/bind/bindToLink.js +81 -0
- package/src-old/bind/bindToPosition.js +283 -0
- package/src-old/bind/bindToRadialDistance.js +62 -0
- package/src-old/bind/bindToSize.js +235 -0
- package/src-old/bind/bindToText.js +60 -0
- package/src-old/bind/bindToThickness.js +100 -0
- package/src-old/constraint/AffixConstraint.js +129 -0
- package/src-old/constraint/AlignConstraint.js +58 -0
- package/src-old/core/Encoding.js +336 -0
- package/src-old/core/Scale.js +322 -0
- package/src-old/core/SceneLoader.js +290 -0
- package/src-old/core/SceneValidator.js +232 -0
- package/src-old/core/SpecExecutor.js +113 -0
- package/src-old/core/SpecGenerator.js +350 -0
- package/src-old/data/DataImporter.js +64 -0
- package/src-old/data/DataScope.js +124 -0
- package/src-old/data/DataTable.js +338 -0
- package/src-old/data/Network.js +106 -0
- package/src-old/data/Tree.js +251 -0
- package/src-old/data/transform/Bin.js +46 -0
- package/src-old/data/transform/Filter.js +48 -0
- package/src-old/data/transform/Groupby.js +18 -0
- package/src-old/data/transform/KDE.js +58 -0
- package/src-old/data/transform/Sort.js +14 -0
- package/src-old/data/transform/Split.js +5 -0
- package/src-old/data/transform/partition.js +46 -0
- package/src-old/history/UndoRedoStack +0 -0
- package/src-old/index.js +271 -0
- package/src-old/indexSVG.js +259 -0
- package/src-old/interaction/Interaction.js +91 -0
- package/src-old/interaction/MouseEvent.js +8 -0
- package/src-old/interaction/Selection.js +9 -0
- package/src-old/interaction/brush.js +362 -0
- package/src-old/item/Segment.js +29 -0
- package/src-old/item/Vertex.js +118 -0
- package/src-old/item/composite/Collection.js +106 -0
- package/src-old/item/composite/Glyph.js +19 -0
- package/src-old/item/composite/Group.js +310 -0
- package/src-old/item/composite/Scene.js +1251 -0
- package/src-old/item/mark/ArcPath.js +181 -0
- package/src-old/item/mark/AreaPath.js +78 -0
- package/src-old/item/mark/CirclePath.js +102 -0
- package/src-old/item/mark/EllipsePath.js +5 -0
- package/src-old/item/mark/Image.js +101 -0
- package/src-old/item/mark/LinkPath.js +118 -0
- package/src-old/item/mark/Mark.js +163 -0
- package/src-old/item/mark/Path.js +494 -0
- package/src-old/item/mark/PointText.js +201 -0
- package/src-old/item/mark/PolygonPath.js +64 -0
- package/src-old/item/mark/RectPath.js +88 -0
- package/src-old/item/mark/RingPath.js +92 -0
- package/src-old/item/refs/Axis.js +362 -0
- package/src-old/item/refs/EncodingAxis.js +515 -0
- package/src-old/item/refs/Gridlines.js +144 -0
- package/src-old/item/refs/LayoutAxis.js +316 -0
- package/src-old/item/refs/Legend.js +273 -0
- package/src-old/layout/Circular.js +95 -0
- package/src-old/layout/Force.js +52 -0
- package/src-old/layout/Grid.js +423 -0
- package/src-old/layout/Layout.js +13 -0
- package/src-old/layout/Packing.js +56 -0
- package/src-old/layout/Stack.js +264 -0
- package/src-old/layout/Strata.js +88 -0
- package/src-old/layout/Sugiyama.js +59 -0
- package/src-old/layout/TidyTree.js +105 -0
- package/src-old/layout/Treemap.js +87 -0
- package/src-old/renderer/SVGInteractionHandler.js +241 -0
- package/src-old/renderer/SVGRenderer.js +325 -0
- package/src-old/renderer/WebGLRenderer.js +1097 -0
- package/src-old/renderer/WebGLRenderer2.js +249 -0
- package/src-old/renderer/threejs/Line2.js +18 -0
- package/src-old/renderer/threejs/LineGeometry.js +77 -0
- package/src-old/renderer/threejs/LineMaterial.js +605 -0
- package/src-old/renderer/threejs/LineSegments2.js +281 -0
- package/src-old/renderer/threejs/LineSegmentsGeometry.js +226 -0
- package/src-old/renderer/threejs/Wireframe.js +51 -0
- package/src-old/renderer/threejs/WireframeGeometry2.js +16 -0
- package/src-old/scale/areaSize.js +0 -0
- package/src-old/scale/domain.js +38 -0
- package/src-old/util/Constants.js +180 -0
- package/src-old/util/DataUtil.js +35 -0
- package/src-old/util/ItemUtil.js +586 -0
- package/src-old/util/Numerical.js +33 -0
- package/tests/demo-tests/README.md +80 -0
- package/tests/demo-tests/SVG2PNG.js +56 -0
- package/tests/demo-tests/demos2CanvasPNGs.js +69 -0
- package/tests/demo-tests/demos2ScenesSVGs.js +100 -0
- package/tests/demo-tests/pathElementWorker.js +91 -0
- package/tests/demo-tests/pixelTest.js +62 -0
- package/tests/demo-tests/renderDemos.html +132 -0
- package/tests/demo-tests/serializationTest.js +36 -0
- package/tests/demo-tests/serializeDemos.html +134 -0
- package/tests/unit-tests/README.md +4 -0
- package/tests/unit-tests/jasmine-browser.json +21 -0
- package/tests/unit-tests/jasmine.json +14 -0
- package/tests/unit-tests/testSpec.js +274 -0
- package/dist/mascot.js +0 -24446
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"srcDir": "src",
|
|
3
|
+
"srcFiles": [],
|
|
4
|
+
"specDir": ".",
|
|
5
|
+
"specFiles": [
|
|
6
|
+
"tests/unit-tests/**/*[sS]pec.?(m)js"
|
|
7
|
+
],
|
|
8
|
+
"helpers": [
|
|
9
|
+
"tests/unit-tests/helpers/**/*.?(m)js"
|
|
10
|
+
],
|
|
11
|
+
"esmFilenameExtension": ".mjs",
|
|
12
|
+
"enableTopLevelAwait": false,
|
|
13
|
+
"env": {
|
|
14
|
+
"stopSpecOnExpectationFailure": false,
|
|
15
|
+
"stopOnSpecFailure": false,
|
|
16
|
+
"random": true
|
|
17
|
+
},
|
|
18
|
+
"browser": {
|
|
19
|
+
"name": "firefox"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import * as msc from "../../dist/mascot-es.js"
|
|
2
|
+
import { divideElement } from "../../src/action/divide.js";
|
|
3
|
+
import { translate } from "../../src/action/translate.js";
|
|
4
|
+
import GridPlacer from "../../src/depgraph/operator/layout/GridPlacer.js";
|
|
5
|
+
import { elementRemoved, layoutSpecified, newCollectionCreated, newMarkCreated, parentChildConnected } from "../../src/depgraph/updateDepGraph.js";
|
|
6
|
+
import { VarType } from "../../src/depgraph/variable/Variable.js";
|
|
7
|
+
import Collection from "../../src/element/group/Collection.js";
|
|
8
|
+
import { GridCorner, GridFillDirection } from "../../src/layout/LayoutConstants.js";
|
|
9
|
+
|
|
10
|
+
import LinearGradient from "../../src/element/gradient/LinearGradient.js"
|
|
11
|
+
|
|
12
|
+
describe("Mascot tests", function() {
|
|
13
|
+
let scn, dt;
|
|
14
|
+
|
|
15
|
+
beforeEach(async function() {
|
|
16
|
+
scn = msc.scene();
|
|
17
|
+
dt = await msc.csv("http://localhost:8020/datasets/csv/GDP Change.csv");// run 'npm run start' first
|
|
18
|
+
expect(dt).toBeDefined();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("repeat mark", async function() {
|
|
22
|
+
let circle = scn.mark("circle", { radius: 6, x: 100, y: 80, fillColor: "orange", strokeWidth: 0, strokeDash:"none", strokeColor: "#222"});
|
|
23
|
+
let coll = scn.repeat(circle, dt, {"attribute": "Year"});
|
|
24
|
+
expect(coll.children.length).toBe(4);
|
|
25
|
+
|
|
26
|
+
let gl = msc.layout("grid");
|
|
27
|
+
coll.layout = gl;
|
|
28
|
+
expect(gl.cellBounds.length).toBe(4);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("rect mark", async function() {
|
|
32
|
+
let rect = scn.mark("rect", { top: 20, left: 100, width: 20, height: 20, fillColor: "orange", strokeWidth: 0});
|
|
33
|
+
let b = rect.bounds;
|
|
34
|
+
expect(b.left).toBe(100);
|
|
35
|
+
expect(b.top).toBe(20);
|
|
36
|
+
expect(b.x).toBe(110);
|
|
37
|
+
expect(b.y).toBe(30);
|
|
38
|
+
//scn.repeat(circle, dt, {"attribute": "company"});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("grid layout: start & direction", async function() {
|
|
42
|
+
let group = new Collection(), placer = new GridPlacer("gridPlacer");
|
|
43
|
+
for (let i = 0; i < 4; i++)
|
|
44
|
+
group.addChild(scn.mark("rect", { top: 20, left: 100, width: 20, height: 20, fillColor: "orange", strokeWidth: 0}));
|
|
45
|
+
|
|
46
|
+
let gl = msc.layout("grid", {numCols: 2, start: GridCorner.TopLeft, direction: GridFillDirection.RowFirst});
|
|
47
|
+
gl.group = group;
|
|
48
|
+
placer.fillGrid(group, gl);
|
|
49
|
+
expect(gl._grid[0][0]).toBe(0);
|
|
50
|
+
expect(gl._grid[0][1]).toBe(1);
|
|
51
|
+
expect(gl._grid[1][0]).toBe(2);
|
|
52
|
+
expect(gl._grid[1][1]).toBe(3);
|
|
53
|
+
|
|
54
|
+
gl = msc.layout("grid", {numCols: 2, start: GridCorner.TopLeft, direction: GridFillDirection.ColumnFirst});
|
|
55
|
+
gl.group = group;
|
|
56
|
+
placer.fillGrid(group, gl);
|
|
57
|
+
expect(gl._grid[0][0]).toBe(0);
|
|
58
|
+
expect(gl._grid[0][1]).toBe(2);
|
|
59
|
+
expect(gl._grid[1][0]).toBe(1);
|
|
60
|
+
expect(gl._grid[1][1]).toBe(3);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
gl = msc.layout("grid", {numCols: 2, start: GridCorner.BottomRight, direction: GridFillDirection.RowFirst});
|
|
64
|
+
gl.group = group;
|
|
65
|
+
placer.fillGrid(group, gl);
|
|
66
|
+
expect(gl._grid[0][0]).toBe(3);
|
|
67
|
+
expect(gl._grid[0][1]).toBe(2);
|
|
68
|
+
expect(gl._grid[1][0]).toBe(1);
|
|
69
|
+
expect(gl._grid[1][1]).toBe(0);
|
|
70
|
+
|
|
71
|
+
gl = msc.layout("grid", {numCols: 2, start: GridCorner.BottomRight, direction: GridFillDirection.ColumnFirst});
|
|
72
|
+
gl.group = group;
|
|
73
|
+
placer.fillGrid(group, gl);
|
|
74
|
+
expect(gl._grid[0][0]).toBe(3);
|
|
75
|
+
expect(gl._grid[0][1]).toBe(1);
|
|
76
|
+
expect(gl._grid[1][0]).toBe(2);
|
|
77
|
+
expect(gl._grid[1][1]).toBe(0);
|
|
78
|
+
|
|
79
|
+
gl = msc.layout("grid", {numCols: 2, start: GridCorner.TopRight, direction: GridFillDirection.RowFirst});
|
|
80
|
+
gl.group = group;
|
|
81
|
+
placer.fillGrid(group, gl);
|
|
82
|
+
expect(gl._grid[0][0]).toBe(1);
|
|
83
|
+
expect(gl._grid[0][1]).toBe(0);
|
|
84
|
+
expect(gl._grid[1][0]).toBe(3);
|
|
85
|
+
expect(gl._grid[1][1]).toBe(2);
|
|
86
|
+
|
|
87
|
+
gl = msc.layout("grid", {numCols: 2, start: GridCorner.TopRight, direction: GridFillDirection.ColumnFirst});
|
|
88
|
+
gl.group = group;
|
|
89
|
+
placer.fillGrid(group, gl);
|
|
90
|
+
expect(gl._grid[0][0]).toBe(2);
|
|
91
|
+
expect(gl._grid[0][1]).toBe(0);
|
|
92
|
+
expect(gl._grid[1][0]).toBe(3);
|
|
93
|
+
expect(gl._grid[1][1]).toBe(1);
|
|
94
|
+
|
|
95
|
+
gl = msc.layout("grid", {numCols: 2, start: GridCorner.BottomLeft, direction: GridFillDirection.RowFirst});
|
|
96
|
+
gl.group = group;
|
|
97
|
+
placer.fillGrid(group, gl);
|
|
98
|
+
expect(gl._grid[0][0]).toBe(2);
|
|
99
|
+
expect(gl._grid[0][1]).toBe(3);
|
|
100
|
+
expect(gl._grid[1][0]).toBe(0);
|
|
101
|
+
expect(gl._grid[1][1]).toBe(1);
|
|
102
|
+
|
|
103
|
+
gl = msc.layout("grid", {numCols: 2, start: GridCorner.BottomLeft, direction: GridFillDirection.ColumnFirst});
|
|
104
|
+
gl.group = group;
|
|
105
|
+
placer.fillGrid(group, gl);
|
|
106
|
+
expect(gl._grid[0][0]).toBe(1);
|
|
107
|
+
expect(gl._grid[0][1]).toBe(3);
|
|
108
|
+
expect(gl._grid[1][0]).toBe(0);
|
|
109
|
+
expect(gl._grid[1][1]).toBe(2);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it ("glyph bounds", async function() {
|
|
113
|
+
let rect = scn.mark("rect", { top: 20, left: 100, width: 20, height: 20, fillColor: "orange", strokeWidth: 0}),
|
|
114
|
+
line = scn.mark("line", {x1: 0, y1: 10, x2: 20, y2: 20});
|
|
115
|
+
let glyph = scn.glyph(rect, line);
|
|
116
|
+
let c1 = scn.repeat(glyph, dt, {"attribute": "Quarter"});
|
|
117
|
+
expect(c1.bounds.width).toBe(120);
|
|
118
|
+
expect(c1.bounds.height).toBe(30);
|
|
119
|
+
expect(c1.bounds.left).toBe(0);
|
|
120
|
+
expect(c1.bounds.top).toBe(10);
|
|
121
|
+
|
|
122
|
+
expect(glyph.refBounds.width).toBe(120);
|
|
123
|
+
expect(glyph.refBounds.height).toBe(30);
|
|
124
|
+
expect(glyph.refBounds.left).toBe(0);
|
|
125
|
+
expect(glyph.refBounds.top).toBe(10);
|
|
126
|
+
|
|
127
|
+
expect(rect.refBounds.width).toBe(20);
|
|
128
|
+
expect(rect.refBounds.height).toBe(20);
|
|
129
|
+
expect(rect.refBounds.left).toBe(100);
|
|
130
|
+
expect(rect.refBounds.top).toBe(20);
|
|
131
|
+
|
|
132
|
+
expect(line.refBounds.width).toBe(20);
|
|
133
|
+
expect(line.refBounds.height).toBe(10);
|
|
134
|
+
expect(line.refBounds.left).toBe(0);
|
|
135
|
+
expect(line.refBounds.top).toBe(10);
|
|
136
|
+
|
|
137
|
+
c1.layout = msc.layout("grid", {numCols: 2, rowGap: 10, colGap: 10});
|
|
138
|
+
let line2 = c1.children[1].children[1];
|
|
139
|
+
|
|
140
|
+
expect(line2.refBounds.width).toBe(20);
|
|
141
|
+
expect(line2.refBounds.height).toBe(10);
|
|
142
|
+
expect(line2.refBounds.left).toBe(130);
|
|
143
|
+
expect(line2.refBounds.top).toBe(10);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("nested collection bounds", async function() {
|
|
147
|
+
let rect = scn.mark("rect", { top: 0, left: 0, width: 100, height: 20, fillColor: "orange", strokeWidth: 0});
|
|
148
|
+
let c1 = scn.repeat(rect, dt, {"attribute": "Quarter"});
|
|
149
|
+
c1.layout = msc.layout("grid", {numCols: 1, rowGap: 10});
|
|
150
|
+
let c = scn.repeat(c1, dt, {attribute: "Year"});
|
|
151
|
+
c.layout = msc.layout("grid", {numCols: 1, rowGap: 10});
|
|
152
|
+
let c2 = c.children[1];
|
|
153
|
+
expect(c1.bounds.width).toBe(100);
|
|
154
|
+
expect(c1.bounds.height).toBe(110);
|
|
155
|
+
expect(c1.bounds.left).toBe(0);
|
|
156
|
+
expect(c1.bounds.top).toBe(0);
|
|
157
|
+
|
|
158
|
+
expect(c2.bounds.width).toBe(100);
|
|
159
|
+
expect(c2.bounds.height).toBe(110);
|
|
160
|
+
expect(c2.bounds.left).toBe(0);
|
|
161
|
+
expect(c2.bounds.top).toBe(120);
|
|
162
|
+
|
|
163
|
+
expect(c.bounds.width).toBe(100);
|
|
164
|
+
expect(c.bounds.height).toBe(470);
|
|
165
|
+
expect(c.bounds.left).toBe(0);
|
|
166
|
+
expect(c.bounds.top).toBe(0);
|
|
167
|
+
|
|
168
|
+
expect(c2.layout.cellBounds[0].top).toBe(120);
|
|
169
|
+
expect(c2.layout.cellBounds[1].top).toBe(150);
|
|
170
|
+
|
|
171
|
+
let r2 = c1.children[1];
|
|
172
|
+
expect(r2.bounds.width).toBe(100);
|
|
173
|
+
expect(r2.bounds.height).toBe(20);
|
|
174
|
+
expect(r2.bounds.left).toBe(0);
|
|
175
|
+
expect(r2.bounds.top).toBe(30);
|
|
176
|
+
expect(r2.refBounds.width).toBe(100);
|
|
177
|
+
expect(r2.refBounds.height).toBe(20);
|
|
178
|
+
expect(r2.refBounds.left).toBe(0);
|
|
179
|
+
expect(r2.refBounds.top).toBe(30);
|
|
180
|
+
|
|
181
|
+
let r6 = c2.children[1];
|
|
182
|
+
expect(r6.bounds.width).toBe(100);
|
|
183
|
+
expect(r6.bounds.height).toBe(20);
|
|
184
|
+
expect(r6.bounds.left).toBe(0);
|
|
185
|
+
expect(r6.bounds.top).toBe(150);
|
|
186
|
+
expect(r6.refBounds.width).toBe(100);
|
|
187
|
+
expect(r6.refBounds.height).toBe(20);
|
|
188
|
+
expect(r6.refBounds.left).toBe(0);
|
|
189
|
+
expect(r6.refBounds.top).toBe(150);
|
|
190
|
+
|
|
191
|
+
translate(c, 100, 100);
|
|
192
|
+
expect(r6.refBounds.width).toBe(100);
|
|
193
|
+
expect(r6.refBounds.height).toBe(20);
|
|
194
|
+
expect(r6.refBounds.left).toBe(100);
|
|
195
|
+
expect(r6.refBounds.top).toBe(250);
|
|
196
|
+
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("divide", async function() {
|
|
200
|
+
let rect = scn.mark("rect", { top: 0, left: 0, width: 100, height: 20, fillColor: "orange", strokeWidth: 0});
|
|
201
|
+
let c1 = scn.repeat(rect, dt, {"attribute": "Year"});
|
|
202
|
+
c1.layout = msc.layout("grid", {numCols: 1, rowGap: 10});
|
|
203
|
+
//let c = scn.divide(rect, dt, {attribute: "Quarter"});
|
|
204
|
+
//c.layout = msc.layout("grid", {numCols: 1, rowGap: 10});
|
|
205
|
+
|
|
206
|
+
let c = divideElement(scn, rect, "Quarter", undefined, dt);
|
|
207
|
+
elementRemoved(rect, scn._depGraph);
|
|
208
|
+
newMarkCreated(c.children[0], scn._depGraph);
|
|
209
|
+
newCollectionCreated(c, scn._depGraph);
|
|
210
|
+
layoutSpecified(c, c.layout, scn._depGraph);
|
|
211
|
+
parentChildConnected(c, c.children[0], scn._depGraph);
|
|
212
|
+
parentChildConnected(c.parent, c, scn._depGraph);
|
|
213
|
+
let rbv = scn._depGraph.findVariable(VarType.CHANNEL, ["x", c]);
|
|
214
|
+
// expect(rbv).toBeDefined();
|
|
215
|
+
// expect(rbv.incomingDataflow.type).toBe(OpType.GRID_LAYOUT);
|
|
216
|
+
//gv = scn._depGraph.getIncomingDataflowOperator(OpType.GRID_LAYOUT, c1);
|
|
217
|
+
// expect(c.layout.type).toBe("stack");
|
|
218
|
+
// let bv = scn._depGraph.getVariable(VarType.BOUNDS, rect),
|
|
219
|
+
// gv = scn._depGraph.getIncomingDataflowOperator(OpType.GRID_LAYOUT, c1);
|
|
220
|
+
// expect(gv).not.toEqual(null);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
describe("LinearGradient Class", function() {
|
|
229
|
+
let linearGradient;
|
|
230
|
+
|
|
231
|
+
beforeEach(function() {
|
|
232
|
+
linearGradient = new LinearGradient();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("should correctly initialize with default parameters", function() {
|
|
236
|
+
expect(linearGradient.x1).toBe(0);
|
|
237
|
+
expect(linearGradient.x2).toBe(100);
|
|
238
|
+
expect(linearGradient.y1).toBe(0);
|
|
239
|
+
expect(linearGradient.y2).toBe(0);
|
|
240
|
+
expect(linearGradient.stops).toEqual([]);
|
|
241
|
+
expect(linearGradient.type).toBeDefined();
|
|
242
|
+
expect(linearGradient.id.startsWith(linearGradient.type)).toBeTrue();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("should correctly initialize with provided parameters", function() {
|
|
246
|
+
const params = { x1: 10, x2: 90, y1: 20, y2: 30 };
|
|
247
|
+
const customGradient = new LinearGradient(params);
|
|
248
|
+
expect(customGradient.x1).toBe(params.x1);
|
|
249
|
+
expect(customGradient.x2).toBe(params.x2);
|
|
250
|
+
expect(customGradient.y1).toBe(params.y1);
|
|
251
|
+
expect(customGradient.y2).toBe(params.y2);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("should add stops correctly", function() {
|
|
255
|
+
linearGradient.addStop(50, 'red', 1);
|
|
256
|
+
expect(linearGradient.stops.length).toBe(1);
|
|
257
|
+
expect(linearGradient.stops[0]).toEqual({ offset: 50, color: 'red', opacity: 1 });
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("should correctly convert to JSON", function() {
|
|
261
|
+
linearGradient.addStop(50, 'red', 1);
|
|
262
|
+
const json = linearGradient.toJSON();
|
|
263
|
+
expect(json.x1).toBe(0);
|
|
264
|
+
expect(json.x2).toBe(100);
|
|
265
|
+
expect(json.y1).toBe(0);
|
|
266
|
+
expect(json.y2).toBe(0);
|
|
267
|
+
expect(json.stops.length).toBe(1);
|
|
268
|
+
expect(json.stops[0]).toEqual({ offset: 50, color: 'red', opacity: 1 });
|
|
269
|
+
expect(json.type).toBeDefined();
|
|
270
|
+
expect(json.id.startsWith(json.type)).toBeTrue();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Add more tests as needed
|
|
274
|
+
});
|