Comments (4)
Today I ran into the same problem. I decided it follows,
The file d3pie.js I made a change in the method of getPercentage.
There Were:
getPercentage: function(pie, index) {
return Math.floor((pie.options.data.content[index].value / pie.totalSize) * 100);
}
/*****************************************************************************************/
was:
getPercentage: function(pie, index) {
return Math.round((pie.options.data.content[index].value / pie.totalSize) * 100);
}
I replaced the floor method to method round. And everything started working fine!
from d3pie.
Hey! Yes, it may not always add up to 100% due to rounding issues. @patil-nileshb committed a fix which will ensure the options.labels.percentage.decimalPlaces
setting will be honoured in the outer labels (which I'll get into the next release soon), but the problem you noted will still occur. @iron-viper's fix has also been added (.round(), not .floor()) so that'll help.
Once the next release is available you'll be able to use the options.labels.percentage.decimalPlaces
setting to ensure the values add up better.
from d3pie.
Hi, iron-viper, what change I have to implement in d3pie.min.js to solve problem
from d3pie.
Hi, pramilkprince.
Search:
getPercentage:function(a,b){return Math.floor(a.options.data.content[b].value/a.totalSize*100)}
Replace:
getPercentage:function(a,b){return Math.round(a.options.data.content[b].value/a.totalSize*100)}
from d3pie.
Related Issues (20)
- Cannot read property 'hs' of undefined
- Cannot read property 'hs' of undefined
- size.pieOuterRadius does not respond as in examples
- sector doesnt close if new sector is selected
- Issues with Bootstrap 3 HOT 1
- Pie Labels Overlap HOT 2
- How to get the effect as mentioned in the image and what properties i need to change to get the effect when i click on segment.
- Label lines overlap when there are lots of small segments clustered at the bottom.
- Changeable text color in pie
- How to use it in react?
- Font-family is set to verdana in style attribute HOT 1
- Percentage values not staying equal distant from the chart
- Percentage values in equal distance from donut chart
- I cannot get this to work. HOT 1
- Why sometimes the d3pie does not draw sectors?
- I want to have external legend, how to achieve that? HOT 1
- how can I change the colour of the percentage label inside the pie segment?
- pie parameter missing HOT 1
- Site is down HOT 1
- d3pie integration with formtools or external php
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3pie.