expressive-charts 0.1.0 → 0.2.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 +18 -0
- package/README.md +10 -9
- package/dist/{chunk-ZIGBM4NY.js → chunk-V5IUTXRW.js} +23 -6
- package/dist/chunk-V5IUTXRW.js.map +1 -0
- package/dist/{drawing-Du6DAgrW.d.cts → drawing-DWZIXIeR.d.cts} +6 -0
- package/dist/{drawing-Du6DAgrW.d.ts → drawing-DWZIXIeR.d.ts} +6 -0
- package/dist/{effect-OcyvtfZi.d.ts → effect-CZUckY0l.d.ts} +1 -1
- package/dist/{effect-dPmXiWlL.d.cts → effect-CcGdU41j.d.cts} +1 -1
- package/dist/expressive-charts.css +5 -5
- package/dist/expressive-charts.global.js +50 -50
- package/dist/expressive-charts.global.js.map +1 -1
- package/dist/icons/sport.js +1 -1
- package/dist/index.cjs +819 -359
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +105 -8
- package/dist/index.d.ts +105 -8
- package/dist/index.js +788 -349
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +22 -5
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-ZIGBM4NY.js.map +0 -1
package/dist/testing.cjs
CHANGED
|
@@ -781,7 +781,7 @@ function checkCount(n, multiple) {
|
|
|
781
781
|
}
|
|
782
782
|
|
|
783
783
|
// src/core/geometry/describe/mark.ts
|
|
784
|
-
function assemble({ key, series, walk, thickness, outline, bounds, center, pivot, segments }) {
|
|
784
|
+
function assemble({ key, series, walk, thickness, outline, bounds, center, pivot, labelBounds, segments }) {
|
|
785
785
|
return {
|
|
786
786
|
key,
|
|
787
787
|
...series === void 0 ? {} : { series },
|
|
@@ -796,6 +796,7 @@ function assemble({ key, series, walk, thickness, outline, bounds, center, pivot
|
|
|
796
796
|
bounds,
|
|
797
797
|
center,
|
|
798
798
|
pivot,
|
|
799
|
+
...labelBounds === void 0 ? {} : { labelBounds },
|
|
799
800
|
...segments === void 0 ? {} : { segments }
|
|
800
801
|
};
|
|
801
802
|
}
|
|
@@ -803,6 +804,18 @@ function finite(builder, field, value) {
|
|
|
803
804
|
if (!Number.isFinite(value)) throw new RangeError(`describe.${builder}: ${field} must be a finite number, got ${value}.`);
|
|
804
805
|
return value;
|
|
805
806
|
}
|
|
807
|
+
function labelBoxes(builder, boxes) {
|
|
808
|
+
if (!boxes) return boxes;
|
|
809
|
+
for (let i = 0; i < boxes.length; i++) {
|
|
810
|
+
const { x, y, width, height } = boxes[i];
|
|
811
|
+
if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(width) && width >= 0 && Number.isFinite(height) && height >= 0) continue;
|
|
812
|
+
finite(builder, `labelBounds[${i}].x`, x);
|
|
813
|
+
finite(builder, `labelBounds[${i}].y`, y);
|
|
814
|
+
size(builder, `labelBounds[${i}].width`, width);
|
|
815
|
+
size(builder, `labelBounds[${i}].height`, height);
|
|
816
|
+
}
|
|
817
|
+
return boxes;
|
|
818
|
+
}
|
|
806
819
|
function size(builder, field, value) {
|
|
807
820
|
if (!(Number.isFinite(value) && value >= 0)) {
|
|
808
821
|
throw new RangeError(`describe.${builder}: ${field} must be a finite number \u2265 0, got ${value}.`);
|
|
@@ -837,7 +850,8 @@ function describeArc(spec) {
|
|
|
837
850
|
outline: closedOutline(sides),
|
|
838
851
|
bounds: boundsOf(sides.flat().flatMap(extremes)),
|
|
839
852
|
center: walk.point(0.5),
|
|
840
|
-
pivot: center
|
|
853
|
+
pivot: center,
|
|
854
|
+
labelBounds: labelBoxes("arc", spec.labelBounds)
|
|
841
855
|
});
|
|
842
856
|
}
|
|
843
857
|
|
|
@@ -854,6 +868,7 @@ function describeBar(spec) {
|
|
|
854
868
|
size("bar", "height", height);
|
|
855
869
|
const radius = size("bar", "radius", spec.radius ?? 0);
|
|
856
870
|
const gap = size("bar", "gap", spec.gap ?? 0);
|
|
871
|
+
const labelBounds = labelBoxes("bar", spec.labelBounds);
|
|
857
872
|
const horizontal = baseline === "left" || baseline === "right";
|
|
858
873
|
const length = horizontal ? width : height;
|
|
859
874
|
const thickness = horizontal ? height : width;
|
|
@@ -906,7 +921,7 @@ function describeBar(spec) {
|
|
|
906
921
|
})
|
|
907
922
|
)
|
|
908
923
|
);
|
|
909
|
-
return part(0, length, radius, { key, series, bounds: { x, y, width, height }, segments });
|
|
924
|
+
return part(0, length, radius, { key, series, bounds: { x, y, width, height }, labelBounds, segments });
|
|
910
925
|
}
|
|
911
926
|
function frame({ x, y, width: w, height: h, baseline }) {
|
|
912
927
|
switch (baseline) {
|
|
@@ -947,7 +962,8 @@ function describeLine(spec) {
|
|
|
947
962
|
outline: openOutline(walk),
|
|
948
963
|
bounds: { x: box.x - pad, y: box.y - pad, width: box.width + width, height: box.height + width },
|
|
949
964
|
center: walk.point(0.5),
|
|
950
|
-
pivot: first
|
|
965
|
+
pivot: first,
|
|
966
|
+
labelBounds: labelBoxes("line", spec.labelBounds)
|
|
951
967
|
});
|
|
952
968
|
}
|
|
953
969
|
|
|
@@ -970,7 +986,8 @@ function describePoint(spec) {
|
|
|
970
986
|
]),
|
|
971
987
|
bounds: { x: center.x - r, y: center.y - r, width: 2 * r, height: 2 * r },
|
|
972
988
|
center,
|
|
973
|
-
pivot: center
|
|
989
|
+
pivot: center,
|
|
990
|
+
labelBounds: labelBoxes("point", spec.labelBounds)
|
|
974
991
|
});
|
|
975
992
|
}
|
|
976
993
|
|