reactchartjs / react-chartjs-2

React components for Chart.js, the most popular charting library
https://react-chartjs-2.js.org
MIT License
6.6k stars 2.36k forks source link

Display label inside pie/donut chart #133

Closed yss14 closed 7 years ago

yss14 commented 7 years ago

Is it possible to display a label inside each bar of a pie chart or donut chart?

bildschirmfoto 2017-05-09 um 16 37 32

VicFrolov commented 7 years ago

This is exactly what I need, would love to know if this is possible.

gmp26 commented 7 years ago

This can be done with a plugin. See http://www.chartjs.org/samples/latest/advanced/data-labelling.html for suitable plugin code.

jerairrest commented 7 years ago

See https://github.com/jerairrest/react-chartjs-2/issues/149 as well.

sridhark158 commented 6 years ago

it's worked good with pieceLabel https://emn178.github.io/Chart.PieceLabel.js/samples/demo/

ergunpp commented 5 years ago

I have the problem that datalabels for example for omega 3 value is not displaying nicely. Is there an easy solution for that?

screen shot 2018-12-22 at 20 45 18
JKLeGend commented 5 years ago

I have the problem that datalabels for example for omega 3 value is not displaying nicely. Is there an easy solution for that?

screen shot 2018-12-22 at 20 45 18

https://github.com/jerairrest/react-chartjs-2/issues/201 https://chartjs-plugin-datalabels.netlify.com/guide/positioning.html#clamping https://chartjs-plugin-datalabels.netlify.com/guide/positioning.html#overlap if label is out of box, adding padding for layout works as well. hope it helps~

pravin-d commented 5 years ago

it's worked good with pieceLabel https://emn178.github.io/Chart.PieceLabel.js/samples/demo/

The link has changed to https://emn178.github.io/chartjs-plugin-labels/samples/demo/

santoshwebinno commented 3 years ago

the option part is not working.. import React from 'react'; import { Card, Table } from "react-bootstrap" import {Doughnut} from 'react-chartjs-2';

class DoughnutChart extends React.Component { state={ dataLine:{ labels: ['ETH','DAI','USDT'], datasets: [ { data: [30, 40, 30], backgroundColor: ["#868DAC", "#F2A919", "#6297A4"], hoverBackgroundColor: [ "#7482C4", "#FEAB09", "#488695" ], } ], options: { plugins: { labels: { render: 'percentage', fontColor: ['green', 'white', 'red'], precision: 2 } }, }, } } render() { return (

ETH pool 50000 PAYR
USDT pool 50000 PAYR
DAI pool 50000 PAYR
);

} } export default DoughnutChart;