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

Unable to update pie chart #178

Open
Zaid-Mirza opened this issue Aug 4, 2016 · 2 comments
Open

Unable to update pie chart #178

Zaid-Mirza opened this issue Aug 4, 2016 · 2 comments

Comments

@Zaid-Mirza
Copy link

Scenaria is,

I m updating data-percent value dynamically of pie chart using Jquery. Value updated sucessfully but animation does not happen again. I tried below code but it gives error update is not defined

$('.chart-circle').data('easyPieChart').update(40);

@ghost
Copy link

ghost commented Feb 24, 2017

Hi Zaid, did you found solution to this problem?
I have the same problem here! Thanks

@BBoyBreaker
Copy link

BBoyBreaker commented Sep 2, 2017

i got it working after doing the following :
`var active = false;
var element = document.querySelector('.chart');
var chart = new EasyPieChart(element, {
// your options goes here
});
chart.update(0);

function isScrolledIntoView(elem)
{
var docViewTop = jQuery(window).scrollTop();
var docViewBottom = docViewTop + jQuery(window).height();
var elemTop = jQuery(elem).offset().top;
var elemBottom = elemTop + jQuery(elem).height();
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}

jQuery( document ).ready(function() {
// in my case i only update it when the user is scrolled to it
if(isScrolledIntoView(jQuery('.chart')) && !active) {
charts.forEach(function(chart) {
chart.update(chart.el.dataset.percent);
});
active = true;
}
});`

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

No branches or pull requests

2 participants