GithubHelp home page GithubHelp logo

rendro / easy-pie-chart Goto Github PK

View Code? Open in Web Editor NEW
2.1K 2.1K 503.0 367 KB

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

License: MIT License

JavaScript 76.57% HTML 13.55% CSS 7.53% CoffeeScript 2.35%

easy-pie-chart's People

Contributors

alex-pex avatar amsross avatar brunocavalcante avatar chafnan avatar chenys avatar dotansimha avatar epost avatar evrpress avatar frankvanrest avatar jennieji avatar levito avatar linkgod avatar mediastuttgart avatar nullcosmos avatar peters avatar procynic avatar rendro avatar scatcher avatar sgtpepper43 avatar stereoscott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easy-pie-chart's Issues

Angular version better documentation

Please you should add some example or a better documentation for the use of angularJs.

I'm trying to migrate to angularJs, but cannot make change to barcolor according to percent.

This was done with:

        barColor: function(percent) {
            percent /= 100;
            return "rgb(" + Math.round(255 * (1-percent)) + ", " + Math.round(255 * percent) + ", 0)";
        },

But how can I made the same with angularJs?

Check this plunker: http://plnkr.co/edit/7yQ1SiIPHFh62yxwnW9e?p=preview

Thanks

HTML Content

Hi,

I'd like the content of my 'chart' div to be two line, rather than just one 'percent' or 'total' line. When I put in a
or any other HTML that would cause a line break, the second line is displayed outside the graphic below it. Am I doing something wrong? Is there a way to do this?

Thanks,

  • Adam

angular module: Move options into single attribute and provide it as json

We should provide the options format for the angular module as JSON format in a separated attribute to be more conventional. That also will solve issues like referencing to variables (#44).

Example for easy-pie-chart:

<div 
    easypiehcart
    ng-options="{ barColor: '#ef1e25', trackColor': '#f2f2f2', 'scaleColor': '#dfe0e0', 'scaleLength': 5 }"
    ng-percent="percent"
></div>

A way better:

<div easypiechart ng-options="options" ng-percent="percent"></div>
var app = angular.module('app', ['easypiechart']);
app.controller('chartCtrl', ['$scope', function ($scope) {
    $scope.percent = 65;
    $scope.options = { 
        barColor: '#ef1e25', 
        trackColor: '#f2f2f2', 
        scaleColor: '#dfe0e0', 
        scaleLength: 5
    };
}]);

What do you think about it ?

Better parameter handling for colors

If trackColor or scaleColor are set without the preceding # then the plugin fails to color the chart on FF (it works fine in chrome).

I would add a simple check to add the # to the beginning of the color if it's not there.

Negative values

Greetings,

Excellent work with this plugin, just for the record, I got some negative values (or imcoplete ones) after a webpage reload (Ctrl + R or F5), for example, I tell to the plugin draw 35% sometimes it draws 29% or so, in a worse scenario it give me negative percents, also the negative percents appear after a long time stay on the page.

This is my code:

$('.percentage-light').easyPieChart({
barColor: function(percent) {
percent /= 100;
return "rgb(" + Math.round(255 * (1-percent)) + ", " + Math.round(255 * percent) + ", 0)";
},
trackColor: '#666',
scaleColor: false,
lineCap: 'butt',
rotate: -90,
lineWidth: 15,
animate: 1000,
onStep: function(value) {
this.$el.find('span').text(~~value);
}
});

image001

Thanks for your help.
Andrés.

Gradient color

Why not add a function to create a gradient color from 0 to 100?

0% in IE8 shows full pie chart

Hi there,

It seems that in IE8 any chart at 0% shows a full pie chart, but if you go up just by 1% it shows correctly. It also shows 100% as full bar. Is there a simple workaround for this?

Easing animations?

Apologies if this has been brought up before, but is it possible to add easing effects to the line animation?

Cheers!

[AngularJS] Options dynamically

Is it possible to change options dynamically, and chart redraw automatically ? I have tried and with no success.

Something like this:

var app = angular.module('app', ['easypiechart']);
app.controller('chartCtrl', ['$scope', function ($scope,frameworkFactory) {
...
   $scope.start = function(){
        var data = frameworkFactory.getData();
        data.$get().then(function(v){
            $scope.percent = data[$scope.data].percent;
            $scope.options = data[$scope.data].options;
        });
    }
    $scope.start();
...

Showing an img as Value

Hello.

I am using your plugin to show a countdown until a webrequest gets started. Thsi webrequest takes about 3 seconds. During that time I would like to show a preloader-gif inside the piechart.

I have tried this: $('span', $('.chart')).text('>img src="images/ajax-loader.gif" /<');

I have reversed the < > because github would try to parse it.

Instead of the image it prints just the raw text.

Any idea how I could do that ?

Updating on load

Hi there

I'm trying to use this in an application but have a problem in that the HTML is generated via an XSL transformation, I can get a number value into the div but can't seem to get the value into the data-percentage attribute. So I'm trying to find a way of updating the data-percentage attribute with the value of another element - am guessing this is done somehow using this.$el. but can't find an example of this anywhere. Would i need to give the data attribute a starting value like 0 and update on window load?

Many thanks in advance for any help

Animate causes random values on ios

I was using easy-pie-chart in a website template, when I noticed that on my iphone 4 (safari), the charts were coming up with random values - sometimes in the negatives, and 4 digits long. Both the charts and the numbers were random. I disabled all other js (other than jquery) and they were still all over the show. At a guess, I disabled animation and they acted fine.

This is what was in my initilization code and html if you want to try and replicate it. I would try and help solve it, but I have no idea what I'm doing with javascript

<script>
$(function() {
    $('.chart').easyPieChart({
        barColor: '#60899a',
        trackColor: false,
        scaleColor: false,
        lineCap: 'round',
        rotate: 180,
        lineWidth: 10,
        size: 150,
        //animate: 1000,


        onStep: function(value) {
            this.$el.find('span').text(~~value);
        }

    });
});
</script>

<div class="chart" data-percent="50"><span>50</span></div>

Update data(percent) with new percent in update() method

Since the plugin can be initialized from data-percent via this.$el.data('percent) the update() method should update the data parameter to the new percent.

this.update = function(percent) {
      percent = parseFloat(percent) || 0;
      _this.$el.data('percent', percent);
      // ... continue

I don't know coffee script or I would make a pull request.

edit: formatting with backticks

Responsive?

Is the Chart Responsive?

I tried setting the width & height of the canvas element as well as it's div container to smaller sizes as resolutions decrease. It works fine in Chrome, but if I open it up on my iPhone the size doesn't change.

Any suggestions?

Animate causes random values on ios

I was using easy-pie-chart in a website template, when I noticed that on my iphone 4 (safari), the charts were coming up with random values - sometimes in the negatives, and 4 digits long. Both the charts and the numbers were random. I disabled all other js (other than jquery) and they were still all over the show. At a guess, I disabled animation and they acted fine.

This is what was in my initilization code and html if you want to try and replicate it. I would try and help solve it, but I have no idea what I'm doing with javascript

$(function() {
$('.chart').easyPieChart({
barColor: '#60899a',
trackColor: false,
scaleColor: false,
lineCap: 'round',
rotate: 180,
lineWidth: 10,
size: 150,
//animate: 1000,
onStep: function(value) {
this.$el.find('span').text(~~value);
}
});
});

50

reload "onmouseover" but keep the same value

Hello, Thank you for this work.
I was trying a way to reload the chart "onmouseover" and I did that by adding it here --> jQuery ('.updateEasyPieChart').on('mouseover', function(e) {...}. But I dont know how to update it, but keep the same percentage value(ex:80%). There is anyway to do that?

Thank you

Draw arrow at the end of the chart

Hi

It would be great to add support for drawing arrow (or other shapes) at the end of the chart. I guess there are 2 ways to do it, either place an image at the end or draw it directly on canvas. I am struggling with this currently, is there anyone with some ideas how to achieve this?

Thanks

Lazy Load

Is there any way to animate only when it appears on screen on computers also support for mobile devices, thanks

Unable to get IE8 working except compatibility mode

Running the old-ie.html demo, the chart didn't render in IE8 "standards mode". Seems to work fine in IE7 and IE8 compatibility mode. Hoping to get this solved. I noticed the problem in my app and tried it on the demo app with the same results.

Result:
image

Missing update function for other attributes too

I would like to add some simple interactivity to the chart, for example a simple hover, that would change the barColor...

so I did ...
var pie_options = {
....,
barColor : "#bbb"
}
$(selector).easyPieChart(pie_options);

$(selector).on("mouseover", function(){
pieOptions.barColor: "#666";
$(selector).easyPieChart(pie_options);
});

but nothing happens

AngularJS Directive: set options with variables

hi! At first thx for the great plugin and the angular support :) From the examples I have seen that the options for the chart are passed as strings. Is it possible to configure the chart instance using scope variables in the controller? As a result the configuration would be reusable and very flexible.

Mootools + jQuery + easyPieChart

Hi Robert,

We are using your code in a site where we have jQuery and Mootools side by side and unfortunately your script failed to work in this environment.

Here is an example:
http://jsfiddle.net/6ZdNZ/

Error is:
TypeError: this.renderer.draw is not a function

At:
// initial draw
this.renderer.draw(currentValue);

setting 'trackColor:false' disables lineWidth

Hello,

it seems like using a trackColor with value of false makes the piechart not use the lineWidth, rendering the chart with 1px.

Is this to be expected?

I mean, having a different lineWidth and no trackColor is an "extension request" or an "issue report"?

thank You.

100 on data-percent shows 99% on pie

Hi great plugin and great work. just noticed that in your example page and in my page as well, if I put 100 in the data attribute then it shows always 99% on the bar. am i doing something wrong ?

Have you got fix for Retina displays

I noted today, testing that on retina display ( such as iPad4 ) the canvas shrinks. I have read some articles on setting the retina display ( hidef ) within the script, just wondered if a implemented fix has been made or if indeed others have similar issues

chart inner circle color

Could you please make this plugin that also allows you too give your chart a color for your inner circle.

Is there a way to add a GOAL setting to the chart?

Enhancement suggestion: Would like to be able to show current percentage (e.g. 40%) with a target/goal of 60%. When the current value = goal, change the color of the bar (to be green), otherwise the bar is red. Something like the below...
goals

AMD support

Hi there

Can you add AMD support? For RequireJS ...

Thx!

Not working on iPad 1

There is an javscript error. 'undefined' is not a function.
It seem it is only a problem with an old safari version

Implemented it:

jQuery(document).ready(function($) {
    $('.chart').easyPieChart({
        size: '200',
        lineWidth: '6',
        lineCap: 'square',
        scaleColor: '#d5d5d5',
        trackColor: '#eeeeee',
        barColor: '#0099cc',
        easing: 'easeOutBounce',
        onStep: function(from, to, percent) {
            $(this.el).find('.percent').text(Math.round(percent));
        }
    });

    var chart = window.chart = $('.chart').data('easyPieChart');

    $('.js_update').on('click', function() {
        chart.update(Math.random()*100);
    });
});

Custom track styles

Hi, Is it possible to add a inset shadow to the track so the graph will pop more? I know I can only send a color hex value through for now.

"scaleColor: false" shows up as an error on Firefox for MAC 13.0.1

Hi there,

When the scaleColor is set to false, the chart will not be render on firefox I don't know why. I look up the Error Console and it shows:

uncaught exception: [Exception... "Could not convert Javascript argument arg 0 [[email protected]]" nsresult: "0x80570009(NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: ... :: <TOP_LEVEL> :: line 70" data: no];

Can someone look into the issue? Thanks

AMD Support not working (RequireJS)

I keep on getting Uncaught TypeError: Cannot read property 'fn' of undefined which means PieChart is trying to execute before jQuery is loaded.

My RequireJS looks good though..

requirejs.config({
    "baseUrl": "/theme/Ias/js/lib",
    "paths": {
        "app":"../app",
        "jquery":"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min",
        "jquery-ui":'jquery-ui-1.10.3.effects.min',
        "EasyPieChart":"jquery.easypiechart.min",
        "typekit":"//use.typekit.net/knu6zcf",
    },         
});

requirejs(["app/common"]);

The example in IE8 on XP doesn't work.

I've had a problem with making your plugin work with IE8 and then realized that your example doesn't work either. The code fails at date.now() on line 131. I've tried a few different ways to fix it but when I use Date().getTime() for example then the percentages seem to go in all directions. It's like there is slight flicker at the end of the animation and then a change in percentages that doesn't seem to make sense. FF and Chrome are fine displaying the right values.

Sam

use pie chart with php

I try to use EASY PIE CHART but i have some problems to use the chart because I would like to use a numb instead a percentage. is it possible?

In my JS I put this:

var chart = x
$(function() {
$('.chart').data('easyPieChart').update(chart);
});

and into my php:

the problem is when my chart variable change i don't see my chart!!!

Decimal places

Would it be possible to display numbers with decimal places in the center? They are all rounded at the moment. 58,7% makes 59% in the chart. Perhaps there could be an option to configure this.

Render the graph in full-size canvas

Hey,

Thank you so much for taking care of that little bug with firefox. Here's a another question or possibly a request. I guess when you create a pie chart there's always a border gap reserved for scale in canvas. Is it possible to remove that gap and let the pie chart take the whole space of canvas when the scaleColor is set to false? Once again, thanks for the great work here.

Brian

Add tests for a better development process

I think we should add tests for all features and implementations to guarantee a better and more stable development process.

My suggestion is to add Jasmine tests and integrate them with the grunt workflow for fast and automated testing.

Ideas, insights, comments or thoughts are welcome.

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.