Giter Club home page Giter Club logo

Comments (4)

iron-viper avatar iron-viper commented on September 7, 2024

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.

benkeen avatar benkeen commented on September 7, 2024

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.

pramilkprince avatar pramilkprince commented on September 7, 2024

Hi, iron-viper, what change I have to implement in d3pie.min.js to solve problem

from d3pie.

iron-viper avatar iron-viper commented on September 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.