-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid recursive event replay loops (#8738)
* chart._lastEvent = null while processing onHover * Pass replay flag to external tooltip * Add test for replay * cc
- Loading branch information
Showing
5 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
function drawMousePoint(ctx, center) { | ||
ctx.beginPath(); | ||
ctx.arc(center.x, center.y, 8, 0, Math.PI * 2); | ||
ctx.fillStyle = 'yellow'; | ||
ctx.fill(); | ||
} | ||
|
||
const canvas = document.createElement('canvas'); | ||
canvas.width = 512; | ||
canvas.height = 512; | ||
const ctx = canvas.getContext('2d'); | ||
|
||
module.exports = { | ||
config: { | ||
type: 'pie', | ||
data: { | ||
datasets: [{ | ||
backgroundColor: ['red', 'green', 'blue'], | ||
hoverBackgroundColor: 'black', | ||
data: [1, 1, 1] | ||
}] | ||
} | ||
}, | ||
options: { | ||
canvas: { | ||
width: 512, | ||
height: 512 | ||
}, | ||
async run(chart) { | ||
ctx.drawImage(chart.canvas, 0, 0, 256, 256); | ||
|
||
const arc = chart.getDatasetMeta(0).data[0]; | ||
const center = arc.getCenterPoint(); | ||
await jasmine.triggerMouseEvent(chart, 'mousemove', arc); | ||
drawMousePoint(chart.ctx, center); | ||
ctx.drawImage(chart.canvas, 256, 0, 256, 256); | ||
|
||
chart.toggleDataVisibility(0); | ||
chart.update(); | ||
drawMousePoint(chart.ctx, center); | ||
ctx.drawImage(chart.canvas, 0, 256, 256, 256); | ||
|
||
await jasmine.triggerMouseEvent(chart, 'mouseout', arc); | ||
ctx.drawImage(chart.canvas, 256, 256, 256, 256); | ||
|
||
Chart.helpers.clearCanvas(chart.canvas); | ||
chart.ctx.drawImage(canvas, 0, 0); | ||
} | ||
} | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters