Skip to content

Commit be655e1

Browse files
committed
fix: set key to use during join of g.graph
1 parent 6c4cd24 commit be655e1

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/chart.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,18 @@ export class Chart extends EventEmitter.EventEmitter {
534534
const graphs = content
535535
.merge(contentEnter)
536536
.selectAll(':scope > g.graph')
537-
.data((d: FunctionPlotOptions) => {
538-
return d.data.map(datumDefaults)
539-
})
537+
.data(
538+
(d: FunctionPlotOptions) => {
539+
return d.data.map(datumDefaults)
540+
},
541+
(d: any) => {
542+
// The key is the function set or other value that uniquely identifies the datum.
543+
return d.fn || d.r || d.x || d.text
544+
}
545+
)
546+
547+
// exit
548+
graphs.exit().remove()
540549

541550
// enter
542551
const graphsEnter = graphs.enter().append('g').attr('class', 'graph')
@@ -550,9 +559,6 @@ export class Chart extends EventEmitter.EventEmitter {
550559
selection.call(globals.graphTypes[d.graphType](self))
551560
selection.call(helpers(self))
552561
})
553-
554-
// exit
555-
graphs.exit().remove()
556562
}
557563

558564
buildZoomHelper() {
-14.1 KB
Loading

0 commit comments

Comments
 (0)