From 67c125c5a0632cfc56d129fbcac5117850d2b21e Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Sat, 2 Nov 2024 16:28:49 -0400 Subject: [PATCH] Fix annotation update on 1.x branch. --- src/helpers/annotations.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/helpers/annotations.ts b/src/helpers/annotations.ts index ef55eb4a..d4b465b7 100644 --- a/src/helpers/annotations.ts +++ b/src/helpers/annotations.ts @@ -41,9 +41,9 @@ export default function annotations(options: { owner: Chart }) { return [[[xRange[0], 0], [xRange[1], 0]]] } }) + const pathEnter = path.enter().append('path') path - .enter() - .append('path') + .merge(pathEnter) .attr('stroke', '#eee') .attr('d', line as any) path.exit().remove() @@ -61,9 +61,13 @@ export default function annotations(options: { owner: Chart }) { } ] }) + const textEnter = text.enter().append('text') + text - .enter() - .append('text') + .merge(textEnter) + .text(function (d) { + return d.text + }) .attr('y', function (d) { return d.hasX ? 3 : 0 }) @@ -79,9 +83,6 @@ export default function annotations(options: { owner: Chart }) { .attr('transform', function (d) { return d.hasX ? 'rotate(-90)' : '' }) - .text(function (d) { - return d.text - }) text.exit().remove() // enter + update