Skip to content

Commit

Permalink
Add test for RTL legend hitboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Jul 7, 2021
1 parent 387c95d commit e032d68
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/fixtures/plugin.legend/horizontal-rtl-hitbox.js
@@ -0,0 +1,52 @@
module.exports = {
description: 'https://github.com/chartjs/Chart.js/issues/9278',
config: {
type: 'pie',
data: {
labels: ['aaa', 'bb', 'c'],
datasets: [{
data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
backgroundColor: 'red'
}]
},
options: {
plugins: {
legend: {
position: 'top',
rtl: 'true',
}
},
layout: {
padding: {
top: 50,
left: 30,
right: 30,
bottom: 50
}
}
},
plugins: [{
id: 'legend-hit-box',
afterDraw(chart) {
const ctx = chart.ctx;
ctx.save();
ctx.strokeStyle = 'green';
ctx.lineWidth = 1;

const legend = chart.legend;
legend.legendHitBoxes.forEach(box => {
ctx.strokeRect(box.left, box.top, box.width, box.height);
});

ctx.restore();
}
}]
},
options: {
spriteText: true,
canvas: {
width: 400,
height: 300
},
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e032d68

Please sign in to comment.