Skip to content

Commit

Permalink
fix: when chart's data changed, clear the append shape. Closed #227.
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ committed Aug 3, 2018
1 parent e79d7eb commit 9090379
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions demos/0-interacion-pie-select.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<body>
<div>
<canvas id="mountNode"></canvas>
<button id="changeBtn"> changeData </button>
</div>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="../build/f2-all.js"></script>
Expand Down Expand Up @@ -85,6 +86,11 @@
});

chart.render();

var btn = document.querySelector('#changeBtn')
btn.onclick = function() {
chart.changeData([ { name: 'test1', percent: 0.1, a: '1'}, { name: 'test2', percent: 0.1, a: '1'} ])
}
</script>
</body>
</html>
13 changes: 13 additions & 0 deletions src/interaction/pie-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ class PieSelect extends Interaction {
});
}

constructor(cfg, chart) {
super(cfg, chart);
const self = this;
chart.registerPlugins({
clearInner() {
self.halo && self.halo.remove(true);
self.selected = false;
self.selectedShape = null;
self.lastShape = null;
}
});
}

start(ev) {
const chart = this.chart;
if (ev.type === 'tap') {
Expand Down

0 comments on commit 9090379

Please sign in to comment.