From 836f6b62fab9f082dbdec724cd2890e584d88f77 Mon Sep 17 00:00:00 2001 From: M0ritzWeide Date: Fri, 22 Mar 2019 11:12:56 +0100 Subject: [PATCH 1/2] Added property 'absolute' to Pie Chart If property absolute is added to PieChart () the values change from percentage to the absolute numbers. --- src/pie-chart.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 } ) From c9b48cded614483d3d75c0c482114da641b1976d Mon Sep 17 00:00:00 2001 From: MW00 Date: Fri, 22 Mar 2019 11:26:20 +0100 Subject: [PATCH 2/2] Updated README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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)