expressive-charts 0.5.0 → 0.7.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/CHANGELOG.md +55 -1
- package/README.md +7 -7
- package/dist/{drawing-Ypmq-2h6.d.ts → drawing-OmQV-0BB.d.cts} +8 -2
- package/dist/{drawing-Ypmq-2h6.d.cts → drawing-OmQV-0BB.d.ts} +8 -2
- package/dist/{effect-CMo-2gPf.d.ts → effect-DYCLY_6e.d.cts} +28 -4
- package/dist/{effect-C786hGyJ.d.cts → effect-HCWnmB72.d.ts} +28 -4
- package/dist/expressive-charts.global.js +10 -10
- package/dist/expressive-charts.global.js.map +1 -1
- package/dist/icons/sport.d.cts +1 -1
- package/dist/icons/sport.d.ts +1 -1
- package/dist/index.cjs +1226 -234
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -17
- package/dist/index.d.ts +102 -17
- package/dist/index.js +1159 -226
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +36 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +12 -3
- package/dist/testing.d.ts +12 -3
- package/dist/testing.js +20 -3
- package/dist/testing.js.map +1 -1
- package/dist/{transition-Bu1NsQor.js → transition-romki_A6.js} +70 -12
- package/dist/transition-romki_A6.js.map +1 -0
- package/package.json +3 -3
- package/dist/transition-Bu1NsQor.js.map +0 -1
package/dist/testing.cjs
CHANGED
|
@@ -258,6 +258,22 @@ function mergeFields(current, next) {
|
|
|
258
258
|
else result[field] = value;
|
|
259
259
|
return result;
|
|
260
260
|
}
|
|
261
|
+
// src/core/text-box.ts
|
|
262
|
+
const TEXT_SIZE = 12.5;
|
|
263
|
+
const AVERAGE_WIDTH = .6;
|
|
264
|
+
const ASCENT = 1.05;
|
|
265
|
+
const SIDE = .16;
|
|
266
|
+
function boxAround(at, anchor, width, size) {
|
|
267
|
+
return {
|
|
268
|
+
x: (anchor === "end" ? at.x - width : anchor === "middle" ? at.x - width / 2 : at.x) - SIDE * size,
|
|
269
|
+
y: at.y - ASCENT * size,
|
|
270
|
+
width: width + 2 * SIDE * size,
|
|
271
|
+
height: 1.3 * size
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function estimatedBox(content, style) {
|
|
275
|
+
return boxAround(style.at, style.anchor, content.length * TEXT_SIZE * AVERAGE_WIDTH, TEXT_SIZE);
|
|
276
|
+
}
|
|
261
277
|
// src/core/easing.ts
|
|
262
278
|
const easeInOutCubic = (t) => t < .5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
263
279
|
// src/core/tween.ts
|
|
@@ -345,6 +361,7 @@ function runScope(options) {
|
|
|
345
361
|
icons: options.icons,
|
|
346
362
|
batch: options.batch,
|
|
347
363
|
...options.previous ? { previous: options.previous } : {},
|
|
364
|
+
...options.texts ? { texts: options.texts } : {},
|
|
348
365
|
tween(tweenOptions) {
|
|
349
366
|
const own = tweenOptions.signal;
|
|
350
367
|
const running = tween({
|
|
@@ -584,6 +601,18 @@ function testContext(options = {}) {
|
|
|
584
601
|
const layer = recordingLayer();
|
|
585
602
|
const mark = recordingMark();
|
|
586
603
|
const icons = new Map((options.icons ?? []).map((icon) => [icon.name, icon]));
|
|
604
|
+
const held = [...options.held ?? []];
|
|
605
|
+
let holding;
|
|
606
|
+
const texts = {
|
|
607
|
+
box: estimatedBox,
|
|
608
|
+
held: () => held,
|
|
609
|
+
hold(box) {
|
|
610
|
+
holding = box;
|
|
611
|
+
},
|
|
612
|
+
get holding() {
|
|
613
|
+
return holding;
|
|
614
|
+
}
|
|
615
|
+
};
|
|
587
616
|
const scope = runScope({
|
|
588
617
|
clock,
|
|
589
618
|
motion,
|
|
@@ -594,7 +623,8 @@ function testContext(options = {}) {
|
|
|
594
623
|
index: 0,
|
|
595
624
|
count: 1
|
|
596
625
|
},
|
|
597
|
-
previous: options.previous
|
|
626
|
+
previous: options.previous,
|
|
627
|
+
texts
|
|
598
628
|
});
|
|
599
629
|
return {
|
|
600
630
|
...scope.context,
|
|
@@ -602,8 +632,12 @@ function testContext(options = {}) {
|
|
|
602
632
|
clock,
|
|
603
633
|
layer,
|
|
604
634
|
mark,
|
|
635
|
+
texts,
|
|
605
636
|
abort: scope.abort,
|
|
606
|
-
clear
|
|
637
|
+
clear() {
|
|
638
|
+
scope.clear();
|
|
639
|
+
holding = void 0;
|
|
640
|
+
},
|
|
607
641
|
change: scope.change
|
|
608
642
|
};
|
|
609
643
|
}
|