@opendata-ai/openchart-vanilla 6.5.1 → 6.5.2
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/dist/index.js +16 -29
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/animation.ts +2 -1
- package/src/mount.ts +19 -6
- package/src/svg-renderer.ts +1 -32
package/dist/index.js
CHANGED
|
@@ -3264,7 +3264,7 @@ function cancelAnimations(svg) {
|
|
|
3264
3264
|
svg.classList.remove("oc-animate");
|
|
3265
3265
|
}
|
|
3266
3266
|
}
|
|
3267
|
-
function setupAnimationCleanup(svg) {
|
|
3267
|
+
function setupAnimationCleanup(svg, onComplete) {
|
|
3268
3268
|
const style = svg.style;
|
|
3269
3269
|
const duration = parseFloat(style.getPropertyValue("--oc-animation-duration")) || 600;
|
|
3270
3270
|
const stagger = parseFloat(style.getPropertyValue("--oc-animation-stagger")) || 0;
|
|
@@ -3274,6 +3274,7 @@ function setupAnimationCleanup(svg) {
|
|
|
3274
3274
|
const totalTime = totalStagger + duration + annotationDelay + 500;
|
|
3275
3275
|
const timer2 = setTimeout(() => {
|
|
3276
3276
|
svg.classList.remove("oc-animate");
|
|
3277
|
+
onComplete?.();
|
|
3277
3278
|
}, totalTime);
|
|
3278
3279
|
return () => {
|
|
3279
3280
|
clearTimeout(timer2);
|
|
@@ -3955,32 +3956,7 @@ function renderAnnotation(parent, annotation, index2) {
|
|
|
3955
3956
|
if (annotation.label?.visible) {
|
|
3956
3957
|
if (annotation.label.connector) {
|
|
3957
3958
|
const c2 = annotation.label.connector;
|
|
3958
|
-
if (c2.style === "
|
|
3959
|
-
const pointsDown = c2.to.y > c2.from.y;
|
|
3960
|
-
const caretSize = 4;
|
|
3961
|
-
const labelLines = annotation.label.text.split("\n");
|
|
3962
|
-
const labelFontSize = annotation.label.style.fontSize ?? 12;
|
|
3963
|
-
const labelLineHeight = labelFontSize * (annotation.label.style.lineHeight ?? 1.3);
|
|
3964
|
-
const textBottom = annotation.label.y + (labelLines.length - 1) * labelLineHeight + labelFontSize * 0.25;
|
|
3965
|
-
const textTop = annotation.label.y - labelFontSize;
|
|
3966
|
-
const gapEdge = pointsDown ? textBottom : textTop;
|
|
3967
|
-
const midY = (gapEdge + c2.to.y) / 2;
|
|
3968
|
-
const tipX = c2.to.x;
|
|
3969
|
-
const tipY = pointsDown ? midY + caretSize / 2 : midY - caretSize / 2;
|
|
3970
|
-
const baseY = pointsDown ? tipY - caretSize : tipY + caretSize;
|
|
3971
|
-
const path = createSVGElement("path");
|
|
3972
|
-
path.setAttribute("class", "oc-annotation-connector");
|
|
3973
|
-
setAttrs(path, {
|
|
3974
|
-
d: `M${tipX - caretSize},${baseY} L${tipX},${tipY} L${tipX + caretSize},${baseY}`,
|
|
3975
|
-
fill: "none",
|
|
3976
|
-
stroke: c2.stroke,
|
|
3977
|
-
"stroke-width": 1.5,
|
|
3978
|
-
"stroke-opacity": 0.4,
|
|
3979
|
-
"stroke-linecap": "round",
|
|
3980
|
-
"stroke-linejoin": "round"
|
|
3981
|
-
});
|
|
3982
|
-
g.appendChild(path);
|
|
3983
|
-
} else if (c2.style === "curve") {
|
|
3959
|
+
if (c2.style === "curve") {
|
|
3984
3960
|
renderCurvedArrow(g, c2.from, c2.to, c2.stroke);
|
|
3985
3961
|
} else {
|
|
3986
3962
|
const connector = createSVGElement("line");
|
|
@@ -5561,6 +5537,7 @@ function createChart(container, spec, options) {
|
|
|
5561
5537
|
let resizeTimer = null;
|
|
5562
5538
|
let isFirstRender = true;
|
|
5563
5539
|
let cleanupAnimations = null;
|
|
5540
|
+
let pendingResize = false;
|
|
5564
5541
|
let selectedElement = options?.selectedElement ?? null;
|
|
5565
5542
|
let overlayElement = null;
|
|
5566
5543
|
let isTextEditingActive = false;
|
|
@@ -5927,7 +5904,13 @@ function createChart(container, spec, options) {
|
|
|
5927
5904
|
container.classList.remove("oc-dark");
|
|
5928
5905
|
}
|
|
5929
5906
|
if (shouldAnimate && svgElement) {
|
|
5930
|
-
cleanupAnimations = setupAnimationCleanup(svgElement)
|
|
5907
|
+
cleanupAnimations = setupAnimationCleanup(svgElement, () => {
|
|
5908
|
+
cleanupAnimations = null;
|
|
5909
|
+
if (pendingResize) {
|
|
5910
|
+
pendingResize = false;
|
|
5911
|
+
resize();
|
|
5912
|
+
}
|
|
5913
|
+
});
|
|
5931
5914
|
}
|
|
5932
5915
|
if (isFirstRender) {
|
|
5933
5916
|
isFirstRender = false;
|
|
@@ -5943,7 +5926,10 @@ function createChart(container, spec, options) {
|
|
|
5943
5926
|
}
|
|
5944
5927
|
function resize() {
|
|
5945
5928
|
if (destroyed) return;
|
|
5946
|
-
if (cleanupAnimations)
|
|
5929
|
+
if (cleanupAnimations) {
|
|
5930
|
+
pendingResize = true;
|
|
5931
|
+
return;
|
|
5932
|
+
}
|
|
5947
5933
|
render();
|
|
5948
5934
|
}
|
|
5949
5935
|
function doExport(format, exportOptions) {
|
|
@@ -5973,6 +5959,7 @@ function createChart(container, spec, options) {
|
|
|
5973
5959
|
if (cleanupAnimations) {
|
|
5974
5960
|
cleanupAnimations();
|
|
5975
5961
|
cleanupAnimations = null;
|
|
5962
|
+
pendingResize = false;
|
|
5976
5963
|
}
|
|
5977
5964
|
cancelAnimations(svgElement);
|
|
5978
5965
|
if (resizeTimer !== null) {
|