Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const data = [
accessor="population"
backgroundColor="transparent"
paddingLeft="15"
absolute
/>
```

Expand All @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion src/pie-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<G key={Math.random()}>
<Path
Expand All @@ -48,7 +53,7 @@ class PieChart extends AbstractChart {
fontSize={c.item.legendFontSize}
x={this.props.width / 2.5}
y={-(this.props.height / 2.5) + ((this.props.height * 0.8) / this.props.data.length * i) + 12*2}
>{Math.round(100 / total * c.item[this.props.accessor])}% { c.item.name }
>{num} { c.item.name }
</Text>
</G>
)
Expand Down