diff --git a/README.md b/README.md index 73d97e2d..eec44099 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,7 @@ const data = [ accessor="population" backgroundColor="transparent" paddingLeft="15" + absolute /> ``` @@ -232,6 +233,7 @@ const data = [ | accessor | string | Property in the `data` object from which the number values are taken | | bgColor | string | background color - if you want to set transparent, input `transparent` or `none`. | | paddingLeft | string | left padding of the pie chart | +| absolute | boolean | shows the values as absolute numbers | ## Contribution graph (heatmap) diff --git a/src/pie-chart.js b/src/pie-chart.js index 770c7f3d..f67fe516 100644 --- a/src/pie-chart.js +++ b/src/pie-chart.js @@ -28,6 +28,11 @@ class PieChart extends AbstractChart { return sum + item[this.props.accessor] }, 0) const slices = chart.curves.map((c, i) => { + if(absolute == true){ + num = c.item[this.props.accessor]; + }else{ + num = Math.round(100 / total * c.item[this.props.accessor]) + '%' + } return ( {Math.round(100 / total * c.item[this.props.accessor])}% { c.item.name } + >{num} { c.item.name } )