score:2

Accepted answer

there is a plugin for what you want to do: https://github.com/ciprianciurea/chartjs-plugin-doughnutlabel

score:1

i actually ended up doing this:

<div style="position: relative;" data-bind="dxpiechart: {
  //chart initialization code from above...
}">
    <div style="position: absolute; top: 50%; margin-top: -15px; left: 50%; font-size: 30px; line-height: 30px; margin-left: -50px; width: 100px; text-align: center;" data-bind="text: alarmids().length"></div>
    <div style="position: absolute; top: 50%; margin-top: 15px; left: 50%; font-size: 15px; line-height: 15px; margin-left: -50px; width: 100px; text-align: center;">alarms</div>
</div>

when it binds the chart it doesn't overwrite any internal html, so this works brilliantly.

score:3

as a workaround until the open issue is complete, you could just draw your own total on the canvas element itself.

you will have to manually calculate the x/y position on the canvas (like [150,100] in this example).

var canvas=document.getelementbyid("mychart");
var ctx=canvas.getcontext("2d");
ctx.font="36px verdana";
ctx.filltext("76",150,100);

Related Query

More Query from same tag