plotboilerplate 1.17.0 → 1.18.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 +63 -6
- package/changelog.md +25 -0
- package/dist/index.esm.js +152 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +155 -28
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/Bounds.d.ts +11 -0
- package/src/cjs/Bounds.js +14 -0
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/Circle.d.ts +36 -2
- package/src/cjs/Circle.js +81 -1
- package/src/cjs/Circle.js.map +1 -1
- package/src/cjs/MouseHandler.d.ts +3 -2
- package/src/cjs/MouseHandler.js +16 -14
- package/src/cjs/MouseHandler.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +3 -1
- package/src/cjs/PlotBoilerplate.js +8 -1
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/draw.d.ts +8 -2
- package/src/cjs/draw.js +23 -8
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +4 -2
- package/src/cjs/drawgl.js +5 -2
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +4 -2
- package/src/cjs/drawutilssvg.js +8 -2
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +3 -1
- package/src/cjs/interfaces/DrawLib.js +1 -0
- package/src/cjs/interfaces/DrawLib.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +2 -0
- package/src/cjs/interfaces/core.js +1 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/datastructures/Color.d.ts +3 -1
- package/src/cjs/utils/datastructures/Color.js +17 -6
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/esm/Bounds.d.ts +11 -0
- package/src/esm/Bounds.js +14 -0
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/Circle.d.ts +36 -2
- package/src/esm/Circle.js +81 -1
- package/src/esm/Circle.js.map +1 -1
- package/src/esm/MouseHandler.d.ts +3 -2
- package/src/esm/MouseHandler.js +16 -14
- package/src/esm/MouseHandler.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +3 -1
- package/src/esm/PlotBoilerplate.js +8 -1
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/draw.d.ts +8 -2
- package/src/esm/draw.js +22 -8
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +4 -2
- package/src/esm/drawgl.js +4 -2
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +4 -2
- package/src/esm/drawutilssvg.js +7 -2
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +3 -1
- package/src/esm/interfaces/DrawLib.js +1 -0
- package/src/esm/interfaces/DrawLib.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +2 -0
- package/src/esm/interfaces/core.js +1 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/datastructures/Color.d.ts +3 -1
- package/src/esm/utils/datastructures/Color.js +17 -6
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/ts/Bounds.ts +15 -0
- package/src/ts/Circle.ts +92 -2
- package/src/ts/MouseHandler.ts +16 -15
- package/src/ts/PlotBoilerplate.ts +8 -1
- package/src/ts/draw.ts +23 -8
- package/src/ts/drawgl.ts +4 -2
- package/src/ts/drawutilssvg.ts +7 -2
- package/src/ts/interfaces/DrawLib.ts +3 -1
- package/src/ts/interfaces/core.ts +3 -2
- package/src/ts/utils/datastructures/Color.ts +17 -6
package/src/esm/Circle.d.ts
CHANGED
|
@@ -9,13 +9,16 @@
|
|
|
9
9
|
* @modified 2021-01-20 Added UID.
|
|
10
10
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
11
11
|
* @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
12
|
-
* @
|
|
12
|
+
* @modified 2022-08-15 Added the `containsPoint` function.
|
|
13
|
+
* @modified 2022-08-23 Added the `lineIntersection` function.
|
|
14
|
+
* @modified 2022-08-23 Added the `closestPoint` function.
|
|
15
|
+
* @version 1.4.0
|
|
13
16
|
**/
|
|
14
17
|
import { Line } from "./Line";
|
|
15
18
|
import { Vector } from "./Vector";
|
|
16
19
|
import { VertTuple } from "./VertTuple";
|
|
17
20
|
import { Vertex } from "./Vertex";
|
|
18
|
-
import { SVGSerializable, UID } from "./interfaces";
|
|
21
|
+
import { SVGSerializable, UID, XYCoords } from "./interfaces";
|
|
19
22
|
/**
|
|
20
23
|
* @classdesc A simple circle: center point and radius.
|
|
21
24
|
*
|
|
@@ -69,6 +72,16 @@ export declare class Circle implements SVGSerializable {
|
|
|
69
72
|
* @param {number} radius - The radius of the circle.
|
|
70
73
|
*/
|
|
71
74
|
constructor(center: Vertex, radius: number);
|
|
75
|
+
/**
|
|
76
|
+
* Check if the given circle is fully contained inside this circle.
|
|
77
|
+
*
|
|
78
|
+
* @method containsPoint
|
|
79
|
+
* @param {XYCoords} point - The point to check if it is contained in this circle.
|
|
80
|
+
* @instance
|
|
81
|
+
* @memberof Circle
|
|
82
|
+
* @return {boolean} `true` if the given point is inside this circle.
|
|
83
|
+
*/
|
|
84
|
+
containsPoint(point: XYCoords): boolean;
|
|
72
85
|
/**
|
|
73
86
|
* Check if the given circle is fully contained inside this circle.
|
|
74
87
|
*
|
|
@@ -126,6 +139,27 @@ export declare class Circle implements SVGSerializable {
|
|
|
126
139
|
* @return {Line|null} The intersection points (as a line) or null if the two circles do not intersect.
|
|
127
140
|
**/
|
|
128
141
|
circleIntersection(circle: Circle): Line | null;
|
|
142
|
+
/**
|
|
143
|
+
* Calculate the intersection points (if exists) with the given infinite line (defined by two points).
|
|
144
|
+
*
|
|
145
|
+
* @method lineIntersection
|
|
146
|
+
* @instance
|
|
147
|
+
* @memberof Circle
|
|
148
|
+
* @param {Vertex} a- The first of the two points defining the line.
|
|
149
|
+
* @param {Vertex} b - The second of the two points defining the line.
|
|
150
|
+
* @return {Line|null} The intersection points (as a line) or null if this circle does not intersect the line given.
|
|
151
|
+
**/
|
|
152
|
+
lineIntersection(a: Vertex, b: XYCoords): Line | null;
|
|
153
|
+
/**
|
|
154
|
+
* Calculate the closest point on the outline of this circle to the given point.
|
|
155
|
+
*
|
|
156
|
+
* @method closestPoint
|
|
157
|
+
* @instance
|
|
158
|
+
* @memberof Circle
|
|
159
|
+
* @param {XYCoords} vert - The point to find the closest circle point for.
|
|
160
|
+
* @return {Vertex} The closest point on this circle.
|
|
161
|
+
**/
|
|
162
|
+
closestPoint(vert: XYCoords): Vertex;
|
|
129
163
|
/**
|
|
130
164
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
131
165
|
* After calling this function the object might not hold valid data any more and
|
package/src/esm/Circle.js
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* @modified 2021-01-20 Added UID.
|
|
10
10
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
11
11
|
* @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
12
|
-
* @
|
|
12
|
+
* @modified 2022-08-15 Added the `containsPoint` function.
|
|
13
|
+
* @modified 2022-08-23 Added the `lineIntersection` function.
|
|
14
|
+
* @modified 2022-08-23 Added the `closestPoint` function.
|
|
15
|
+
* @version 1.4.0
|
|
13
16
|
**/
|
|
14
17
|
import { Line } from "./Line";
|
|
15
18
|
import { UIDGenerator } from "./UIDGenerator";
|
|
@@ -44,6 +47,18 @@ export class Circle {
|
|
|
44
47
|
this.center = center;
|
|
45
48
|
this.radius = radius;
|
|
46
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Check if the given circle is fully contained inside this circle.
|
|
52
|
+
*
|
|
53
|
+
* @method containsPoint
|
|
54
|
+
* @param {XYCoords} point - The point to check if it is contained in this circle.
|
|
55
|
+
* @instance
|
|
56
|
+
* @memberof Circle
|
|
57
|
+
* @return {boolean} `true` if the given point is inside this circle.
|
|
58
|
+
*/
|
|
59
|
+
containsPoint(point) {
|
|
60
|
+
return this.center.distance(point) < this.radius;
|
|
61
|
+
}
|
|
47
62
|
/**
|
|
48
63
|
* Check if the given circle is fully contained inside this circle.
|
|
49
64
|
*
|
|
@@ -155,6 +170,71 @@ export class Circle {
|
|
|
155
170
|
var y4 = p2.y + (h * (p1.x - p0.x)) / d;
|
|
156
171
|
return new Line(new Vertex(x3, y3), new Vertex(x4, y4));
|
|
157
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Calculate the intersection points (if exists) with the given infinite line (defined by two points).
|
|
175
|
+
*
|
|
176
|
+
* @method lineIntersection
|
|
177
|
+
* @instance
|
|
178
|
+
* @memberof Circle
|
|
179
|
+
* @param {Vertex} a- The first of the two points defining the line.
|
|
180
|
+
* @param {Vertex} b - The second of the two points defining the line.
|
|
181
|
+
* @return {Line|null} The intersection points (as a line) or null if this circle does not intersect the line given.
|
|
182
|
+
**/
|
|
183
|
+
lineIntersection(a, b) {
|
|
184
|
+
// Based on the math from
|
|
185
|
+
// https://mathworld.wolfram.com/Circle-LineIntersection.html
|
|
186
|
+
const interA = new Vertex();
|
|
187
|
+
const interB = new Vertex();
|
|
188
|
+
// First do a transformation, because the calculation is based on a cicle at (0,0)
|
|
189
|
+
const transA = new Vertex(a).sub(this.center);
|
|
190
|
+
const transB = new Vertex(b).sub(this.center);
|
|
191
|
+
const diff = transA.difference(transB);
|
|
192
|
+
// There is a special case if diff.y=0, where the intersection is not calcuatable.
|
|
193
|
+
// Use an non-zero epsilon here to approximate this case.
|
|
194
|
+
// TODO for the future: find a better solution
|
|
195
|
+
if (Math.abs(diff.y) === 0) {
|
|
196
|
+
diff.y = 0.000001;
|
|
197
|
+
}
|
|
198
|
+
const dist = transA.distance(transB);
|
|
199
|
+
const det = transA.x * transB.y - transA.y * transB.x;
|
|
200
|
+
const distSquared = dist * dist;
|
|
201
|
+
const radiusSquared = this.radius * this.radius;
|
|
202
|
+
// Check if circle and line have an intersection at all
|
|
203
|
+
if (radiusSquared * distSquared - det * det < 0) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const belowSqrt = this.radius * this.radius * dist * dist - det * det;
|
|
207
|
+
const sqrt = Math.sqrt(belowSqrt);
|
|
208
|
+
interA.x = (det * diff.y + Math.sign(diff.y) * diff.x * sqrt) / distSquared;
|
|
209
|
+
interB.x = (det * diff.y - Math.sign(diff.y) * diff.x * sqrt) / distSquared;
|
|
210
|
+
interA.y = (-det * diff.x + Math.abs(diff.y) * sqrt) / distSquared;
|
|
211
|
+
interB.y = (-det * diff.x - Math.abs(diff.y) * sqrt) / distSquared;
|
|
212
|
+
return new Line(interA.add(this.center), interB.add(this.center));
|
|
213
|
+
// return new Line(interA, interB);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Calculate the closest point on the outline of this circle to the given point.
|
|
217
|
+
*
|
|
218
|
+
* @method closestPoint
|
|
219
|
+
* @instance
|
|
220
|
+
* @memberof Circle
|
|
221
|
+
* @param {XYCoords} vert - The point to find the closest circle point for.
|
|
222
|
+
* @return {Vertex} The closest point on this circle.
|
|
223
|
+
**/
|
|
224
|
+
closestPoint(vert) {
|
|
225
|
+
const lineIntersection = this.lineIntersection(this.center, vert);
|
|
226
|
+
if (!lineIntersection) {
|
|
227
|
+
// Note: this case should not happen as a radial from the center always intersect this circle.
|
|
228
|
+
return new Vertex();
|
|
229
|
+
}
|
|
230
|
+
// Return closed of both
|
|
231
|
+
if (lineIntersection.a.distance(vert) < lineIntersection.b.distance(vert)) {
|
|
232
|
+
return lineIntersection.a;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return lineIntersection.b;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
158
238
|
/**
|
|
159
239
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
160
240
|
* After calling this function the object might not hold valid data any more and
|
package/src/esm/Circle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.js","sourceRoot":"","sources":["../ts/Circle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Circle.js","sourceRoot":"","sources":["../ts/Circle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;IAeI;AAEJ,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC;;;;;;;;;;IAUI;AACJ,MAAM,OAAO,MAAM;IAsCjB;;;;;;;OAOG;IACH,YAAY,MAAc,EAAE,MAAc;QA7C1C;;YAEI;QACK,cAAS,GAAW,QAAQ,CAAC;QA2CpC,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;OAQG;IACH,aAAa,CAAC,KAAe;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IACnD,CAAC;IAED;;;;;;;;OAQG;IACH,cAAc,CAAC,MAAc;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3E,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,IAAoB;QAC/B,MAAM,kBAAkB,GAAW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GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClE,IAAI,CAAC,gBAAgB,EAAE;YACrB,8FAA8F;YAC9F,OAAO,IAAI,MAAM,EAAE,CAAC;SACrB;QACD,wBAAwB;QACxB,IAAI,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzE,OAAO,gBAAgB,CAAC,CAAC,CAAC;SAC3B;aAAM;YACL,OAAO,gBAAgB,CAAC,CAAC,CAAC;SAC3B;IACH,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;EASD,YAAY;AAPL,kBAAW,GAAG;IACnB,MAAM,EAAE,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE;QACxC;mDACkC;QAClC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC;IACxE,CAAC;CACF,CAAC"}
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* @modified 2020-10-04 Added extended JSDoc comments.
|
|
18
18
|
* @modified 2020-11-25 Added the `isTouchEvent` param.
|
|
19
19
|
* @modified 2021-01-10 The mouse handler is now also working with SVGElements.
|
|
20
|
-
* @
|
|
20
|
+
* @modified 2022-08-16 Fixed a bug in the mouse button detection.
|
|
21
|
+
* @version 1.2.1
|
|
21
22
|
*
|
|
22
23
|
* @file MouseHandler
|
|
23
24
|
* @public
|
|
@@ -150,7 +151,7 @@ export declare class MouseHandler {
|
|
|
150
151
|
* @memberof MouseHandler
|
|
151
152
|
* @instance
|
|
152
153
|
* @private
|
|
153
|
-
* @param {MouseEvent}
|
|
154
|
+
* @param {MouseEvent} event - The mouse event to get the relative position for.
|
|
154
155
|
* @param {string} eventName - The name of the firing event.
|
|
155
156
|
* @return {XMouseEvent}
|
|
156
157
|
*/
|
package/src/esm/MouseHandler.js
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* @modified 2020-10-04 Added extended JSDoc comments.
|
|
18
18
|
* @modified 2020-11-25 Added the `isTouchEvent` param.
|
|
19
19
|
* @modified 2021-01-10 The mouse handler is now also working with SVGElements.
|
|
20
|
-
* @
|
|
20
|
+
* @modified 2022-08-16 Fixed a bug in the mouse button detection.
|
|
21
|
+
* @version 1.2.1
|
|
21
22
|
*
|
|
22
23
|
* @file MouseHandler
|
|
23
24
|
* @public
|
|
@@ -107,8 +108,8 @@ export class MouseHandler {
|
|
|
107
108
|
// +-------------------------------------------------
|
|
108
109
|
this.name = name;
|
|
109
110
|
this.element = element;
|
|
110
|
-
this.mouseDownPos =
|
|
111
|
-
this.mouseDragPos =
|
|
111
|
+
this.mouseDownPos = undefined;
|
|
112
|
+
this.mouseDragPos = undefined;
|
|
112
113
|
// this.mousePos = null;
|
|
113
114
|
this.mouseButton = -1;
|
|
114
115
|
this.listeners = {};
|
|
@@ -177,26 +178,27 @@ export class MouseHandler {
|
|
|
177
178
|
* @memberof MouseHandler
|
|
178
179
|
* @instance
|
|
179
180
|
* @private
|
|
180
|
-
* @param {MouseEvent}
|
|
181
|
+
* @param {MouseEvent} event - The mouse event to get the relative position for.
|
|
181
182
|
* @param {string} eventName - The name of the firing event.
|
|
182
183
|
* @return {XMouseEvent}
|
|
183
184
|
*/
|
|
184
|
-
mkParams(
|
|
185
|
-
|
|
186
|
-
const
|
|
185
|
+
mkParams(event, eventName) {
|
|
186
|
+
var _a, _b;
|
|
187
|
+
const rel = this.relPos(event);
|
|
188
|
+
const xEvent = event;
|
|
187
189
|
xEvent.params = {
|
|
188
190
|
element: this.element,
|
|
189
191
|
name: eventName,
|
|
190
192
|
isTouchEvent: false,
|
|
191
193
|
pos: rel,
|
|
192
|
-
button:
|
|
193
|
-
leftButton:
|
|
194
|
-
middleButton:
|
|
195
|
-
rightButton:
|
|
196
|
-
mouseDownPos: this.mouseDownPos,
|
|
197
|
-
draggedFrom: this.mouseDragPos,
|
|
194
|
+
button: event.button,
|
|
195
|
+
leftButton: event.button === 0,
|
|
196
|
+
middleButton: event.button === 1,
|
|
197
|
+
rightButton: event.button === 2,
|
|
198
|
+
mouseDownPos: (_a = this.mouseDownPos) !== null && _a !== void 0 ? _a : { x: NaN, y: NaN },
|
|
199
|
+
draggedFrom: (_b = this.mouseDragPos) !== null && _b !== void 0 ? _b : { x: NaN, y: NaN },
|
|
198
200
|
wasDragged: this.mouseDownPos != null && (this.mouseDownPos.x != rel.x || this.mouseDownPos.y != rel.y),
|
|
199
|
-
dragAmount: this.
|
|
201
|
+
dragAmount: this.mouseDragPos != null ? { x: rel.x - this.mouseDragPos.x, y: rel.y - this.mouseDragPos.y } : { x: 0, y: 0 }
|
|
200
202
|
};
|
|
201
203
|
return xEvent;
|
|
202
204
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MouseHandler.js","sourceRoot":"","sources":["../ts/MouseHandler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MouseHandler.js","sourceRoot":"","sources":["../ts/MouseHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;IAwBI;AAmBJ,MAAM,OAAO,WAAY,SAAQ,UAAU;CAE1C;AACD,MAAM,OAAO,WAAY,SAAQ,UAAU;CAE1C;AAMD;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAYvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2DI;IACJ,YAAY,OAAiC,EAAE,IAAa;QArEpD,iBAAY,GAAyC,SAAS,CAAC;QAC/D,iBAAY,GAAyC,SAAS,CAAC;QACvE,WAAW;QACX,yEA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EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAkB,CAAC,CAAC;IACrF,CAAC;CACF"}
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
* @modified 2021-03-29 Clearing `currentClassName` and `currentId` after drawing each drawable.
|
|
75
75
|
* @modified 2021-04-25 Extending `remove` to accept arrays of drawables.
|
|
76
76
|
* @modified 2021-11-16 Adding the `PBText` drawable.
|
|
77
|
-
* @
|
|
77
|
+
* @modified 2022-08-01 Added `title` to the params.
|
|
78
|
+
* @version 1.15.1
|
|
78
79
|
*
|
|
79
80
|
* @file PlotBoilerplate
|
|
80
81
|
* @fileoverview The main class.
|
|
@@ -313,6 +314,7 @@ export declare class PlotBoilerplate {
|
|
|
313
314
|
* @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).
|
|
314
315
|
* @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).
|
|
315
316
|
* Note that changes from the postDraw hook might not be visible in the export.
|
|
317
|
+
* @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
|
|
316
318
|
*/
|
|
317
319
|
constructor(config: PBParams);
|
|
318
320
|
/**
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
* @modified 2021-03-29 Clearing `currentClassName` and `currentId` after drawing each drawable.
|
|
75
75
|
* @modified 2021-04-25 Extending `remove` to accept arrays of drawables.
|
|
76
76
|
* @modified 2021-11-16 Adding the `PBText` drawable.
|
|
77
|
-
* @
|
|
77
|
+
* @modified 2022-08-01 Added `title` to the params.
|
|
78
|
+
* @version 1.15.1
|
|
78
79
|
*
|
|
79
80
|
* @file PlotBoilerplate
|
|
80
81
|
* @fileoverview The main class.
|
|
@@ -188,6 +189,7 @@ export class PlotBoilerplate {
|
|
|
188
189
|
* @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).
|
|
189
190
|
* @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).
|
|
190
191
|
* Note that changes from the postDraw hook might not be visible in the export.
|
|
192
|
+
* @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
|
|
191
193
|
*/
|
|
192
194
|
constructor(config) {
|
|
193
195
|
/**
|
|
@@ -403,6 +405,11 @@ export class PlotBoilerplate {
|
|
|
403
405
|
else {
|
|
404
406
|
throw "Element is neither a canvas nor an svg element.";
|
|
405
407
|
}
|
|
408
|
+
// At this point the event cacher element is deinfed and located at highest elevation.
|
|
409
|
+
// Set `title` attribut?
|
|
410
|
+
if (config.title) {
|
|
411
|
+
this.eventCatcher.setAttribute("title", config.title);
|
|
412
|
+
}
|
|
406
413
|
this.draw.scale.set(this.config.scaleX, this.config.scaleY);
|
|
407
414
|
this.fill.scale.set(this.config.scaleX, this.config.scaleY);
|
|
408
415
|
this.vertices = [];
|