Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
radialLinear: fix getIndexAngle when there are no labels (left) (#10020)
* Resolve animation if indexAngle is NaN * make it private * add test * use chart.js helper instead of own logic * implement feedback * remove extra line * my precious bits
- Loading branch information
1 parent
f1c9931
commit d24fe14
Showing
3 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const canvas = document.createElement('canvas'); | ||
canvas.width = 512; | ||
canvas.height = 512; | ||
const ctx = canvas.getContext('2d'); | ||
|
||
module.exports = { | ||
config: { | ||
type: 'polarArea', | ||
data: { | ||
labels: ['A'], | ||
datasets: [{ | ||
data: [20], | ||
backgroundColor: 'red', | ||
}] | ||
}, | ||
options: { | ||
animation: { | ||
duration: 0, | ||
easing: 'linear' | ||
}, | ||
responsive: false, | ||
plugins: { | ||
legend: false, | ||
title: false, | ||
tooltip: false, | ||
filler: false | ||
}, | ||
scales: { | ||
r: { | ||
ticks: { | ||
display: false, | ||
} | ||
} | ||
} | ||
}, | ||
}, | ||
options: { | ||
canvas: { | ||
height: 512, | ||
width: 512 | ||
}, | ||
run: function(chart) { | ||
chart.options.animation.duration = 8000; | ||
chart.toggleDataVisibility(0); | ||
chart.update(); | ||
const animator = Chart.animator; | ||
// disable animator | ||
const backup = animator._refresh; | ||
animator._refresh = function() { }; | ||
|
||
return new Promise((resolve) => { | ||
window.requestAnimationFrame(() => { | ||
const anims = animator._getAnims(chart); | ||
const start = anims.items[0]._start; | ||
for (let i = 0; i < 16; i++) { | ||
animator._update(start + i * 500); | ||
let x = i % 4 * 128; | ||
let y = Math.floor(i / 4) * 128; | ||
ctx.drawImage(chart.canvas, x, y, 128, 128); | ||
} | ||
Chart.helpers.clearCanvas(chart.canvas); | ||
chart.ctx.drawImage(canvas, 0, 0); | ||
|
||
animator._refresh = backup; | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
} | ||
}; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.