Skip to content

i solved the issue 12067 #12069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script src="https://npmcdn.com/chart.js@latest/dist/chart.umd.js"></script>
<div class="myChartDiv">
<canvas id="myChart" width="600" height="400"></canvas>
</div>

<script src="js.js"></script>
<!-- css -->
<style>
.myChartDiv {
max-width: 600px;
max-height: 400px;
}
</style>
43 changes: 43 additions & 0 deletions js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: "doughnut",
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [
{
label: "# of Votes",
data: [12, 19, 3, 5, 2, 3]
}
]
},
options: {
plugins: {
legend: {
position: 'right',
labels: {
textAlign: 'right',
},
// rtl: true,
}
}
},
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, 100, box.height);//i changed the box.width to 100
});

ctx.restore();
}
}
]
});