Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I "scale" the percentages? Also, auto-refresh #76

Open
gforster opened this issue Jan 30, 2014 · 4 comments
Open

Can I "scale" the percentages? Also, auto-refresh #76

gforster opened this issue Jan 30, 2014 · 4 comments
Assignees
Labels

Comments

@gforster
Copy link

Hello,

Love the plugin. Two quick questions:

  1. Can I scale the percantage? For example, instead of the pie chart showing 0-100 %, I would like to show 99-100% with decimal places and have the chart reflect that. For example, in my particular use, the current difference between 99.965% and 99.974% looks the same visually & I would like to visualize a greater difference.
  2. Given my configuration below, I would like to auto-refresh the chart. What's the best approach?
function setup_easypie(){
        if ($('.percentage').length) { 
            $.percentage_easy_pie = $('.percentage');   
            $.percentage_easy_pie.easyPieChart({
                animate: 2000,
                trackColor: "#515151",
                scaleColor: "#818181",
                lineCap: 'butt',
                lineWidth: 10,
                barColor: function(percent) {
                    percent /= 100;
                    return "rgb(" + Math.round(255 * (1-percent)) + ", " + Math.round(255 * percent) + ", 0)";
                },
                size: 150
            });
        }
    }
@ghost ghost assigned rendro Jan 30, 2014
@rendro
Copy link
Owner

rendro commented Feb 23, 2014

In this case, you should implement your own update method that transforms your values into new percentage values and use that to call the update method of the plugin. And then change the label in the center to your real percentage.

This is a highly customized behavior which requires changing the implementation.

@bondt
Copy link

bondt commented Sep 6, 2017

@gforster, did you ever get around to this? I am looking for a similar implementation.
In my case, the circle should reflect 0-40 as 0 to 100% respectively.

edit: I see @rendro is working on a V3. :-)

@rendro rendro closed this as completed Sep 7, 2017
@rendro rendro reopened this Sep 7, 2017
@rendro
Copy link
Owner

rendro commented Sep 7, 2017

Didn't mean to close it 😃

As of now you can use the update method to set you value and apply your own transform:

function transformMyValue(inputValue) {
    return inputValue / 40 * 100;
}

$('.chart').data('easyPieChart').update(transformMyValue(35));

@bondt
Copy link

bondt commented Sep 13, 2017

Updating its value will update the canvas as well. For now I'm just updating the innerHTML 40ms after the rendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants