rendro / easy-pie-chart

easy pie chart is a lightweight plugin to draw simple, animated pie charts for single values

Home Page:http://rendro.github.io/easy-pie-chart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use 20 sections for scale instead of 24

skolarianer opened this issue · comments

I suggest to divide the scale in 20 sections instead of 24. Percentage is using the decimal system and not the duodecimal system. Therefore it is a bit confusing when for example the 10% track ends between two bars. Using 20 sections leads to bars in 5% steps which is IMHO more reasonable.

        /**
         * Draw the scale of the chart
         */
        var drawScale = function() {
                var offset;
                var length;

                ctx.lineWidth = 1;
                ctx.fillStyle = options.scaleColor;

                ctx.save();
                for (var i = 20; i > 0; --i) {
                        if (i % 5 === 0) {
                                length = options.scaleLength;
                                offset = 0;
                        } else {
                                length = options.scaleLength * 0.6;
                                offset = options.scaleLength - length;
                        }
                        ctx.fillRect(-options.size/2 + offset, 0, length, 1);
                        ctx.rotate(Math.PI / 10);
                }
                ctx.restore();
        };