Skip to content

Commit 67c125c

Browse files
committed
Fix annotation update on 1.x branch.
1 parent c27f9fa commit 67c125c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/helpers/annotations.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ export default function annotations(options: { owner: Chart }) {
4141
return [[[xRange[0], 0], [xRange[1], 0]]]
4242
}
4343
})
44+
const pathEnter = path.enter().append('path')
4445
path
45-
.enter()
46-
.append('path')
46+
.merge(pathEnter)
4747
.attr('stroke', '#eee')
4848
.attr('d', line as any)
4949
path.exit().remove()
@@ -61,9 +61,13 @@ export default function annotations(options: { owner: Chart }) {
6161
}
6262
]
6363
})
64+
const textEnter = text.enter().append('text')
65+
6466
text
65-
.enter()
66-
.append('text')
67+
.merge(textEnter)
68+
.text(function (d) {
69+
return d.text
70+
})
6771
.attr('y', function (d) {
6872
return d.hasX ? 3 : 0
6973
})
@@ -79,9 +83,6 @@ export default function annotations(options: { owner: Chart }) {
7983
.attr('transform', function (d) {
8084
return d.hasX ? 'rotate(-90)' : ''
8185
})
82-
.text(function (d) {
83-
return d.text
84-
})
8586
text.exit().remove()
8687

8788
// enter + update

0 commit comments

Comments
 (0)