JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://npmcdn.com/chart.js/dist/Chart.bundle.js"></script>
<canvas id="chart"></canvas>
JavaScript
Chart.controllers.doughnut.prototype.calculateTotal = function() {
return 100;
};
var ctx = document.getElementById('chart').getContext('2d');
var value1 = 50, value2= 90
new Chart(ctx, {
type: 'doughnut',
data: {
datasets: [{
data: [value1, 0],
backgroundColor: [
"#FF6384",
"#00CCFF"
]
}, {
data: [0, value2],
backgroundColor: [
"#FF6384",
"#00CCFF"
]
}],
labels: ['element 1', 'element 2']
},
options: {
rotation: Math.PI,
circumference: Math.PI,
cutoutPercentage: 77,
legend: {
position: 'right'
}
}
})