react-chartjs icon indicating copy to clipboard operation
react-chartjs copied to clipboard

How to write the custom label inside donuts chart

Open sunnybogawat opened this issue 9 years ago • 6 comments

I am using the implementation in reactJs component and I am not understanding how I can write the custom label inside donuts chart. I am not able to found any hint for this. Could you please lets us know how to set the custom label.

sunnybogawat avatar Apr 19 '16 10:04 sunnybogawat

any update on this?

sunnybogawat avatar Apr 28 '16 10:04 sunnybogawat

You'll need to use the chart options object:

http://www.chartjs.org/docs/#doughnut-pie-chart-chart-options

dougmolineux avatar Apr 28 '16 21:04 dougmolineux

Thanks for the reply. I saw this options before but I am using react-chartjs component and haven't found any configuration for showing data in the center of the donuts chart specific to component. I am getting the canvas object from DOM do you know is there any way to show data in the center using this object.

sunnybogawat avatar Apr 29 '16 03:04 sunnybogawat

Any update on this ? i also need the same functionality

pankaj805 avatar Apr 04 '17 11:04 pankaj805

@pankaj805 See my comment here if you are still looking for a solution. https://github.com/chartjs/Chart.js/issues/78#issuecomment-289264197

scorgn avatar Apr 21 '17 14:04 scorgn

Hi, this solution dosnt work on my code. Can someone help me? This is my code.

`var config = { type: 'doughnut', data: { datasets: [{ data: [ data.VSTPS_OEEDATOF[0].PctOEE, "100" - data.VSTPS_OEEDATOF[0].PctOEE, ], backgroundColor: [ "#8A8A8A", "#FFFFFF", ] }, { data: [ "100", ], backgroundColor: [ "#DED6D6", ] } ] }, options: { responsive: true, elements: { center: { text: '90%', color: '#FF6384', fontStyle: 'Arial', sidePadding: 20, } } } };

    var ctx = document.getElementById("chart-area").getContext("2d");
    window.myDoughnut = new Chart(ctx, config);`

And this my html plage <div id="canvas-holder" style="width:18%"> <canvas id="chart-area" /> </div>

Thank you in advise.

iratierana avatar Nov 17 '17 09:11 iratierana