benpickles/peity — Issue #6: Each .piety call creates new 'span' tags to contain values
Author: dooburt
Created: 2011-10-19 10:31:46+00:00
State: open

Firstly, great plugin. It's super easy to use and you should be commended on your work :)

I have written a 'timeline' style slider which onchange fires a 'drawPie' function containing the following peity code:

function drawPie() {
$('#pieData .pie').peity("pie", {
radius: function () {
return this.getAttribute("data-radius")
},
colours: function () {
return [squads.away.color, squads.home.color]
}
});
}

The issue I am having is that each call to drawPie creates a new span tag within #pieData. Peity continues to work (hazzah!), but creates multiples of the span tags without limit (boo!). I'm not sure if this is by design or my implementation.

For clarity, this is the 'change' function of the slider which fires drawPie:

....
change: function (e, ui) {
//alert('changed '+ $('#matchtimeline option').eq(ui.values[0]).text() );
//fire changes to charts...
//change the span first
var homepossession = Math.floor(Math.random()*100);
var awaypossession = 100 - homepossession;
$('#pieData .pie').text(homepossession + "/" + awaypossession);
drawPie();
}
....

Help is appreciated.