The issues are
- You get the raw DOM nodes, and not the RaphaelJS wrapped objects (because you use
document.getElementsByTagName
) - You set
data
but try to access it throughattr
. - In the fiddle, the
newSet
is not correctly built becuase you use thei
variable which goes from 1 to 5.. to calculate the index you need to account for both of the loop counter.
So the changes made are
When populating the newSet
var index = (i*5) + y;
newSet[index] = paper.set();
When clearing and populating the chart use newSet
newSet[x].forEach(function(item){
if (item.type=='text')
attr=item;
});
to get the text node.
Working demo at Have a look at http://jsfiddle.net/G94sQ/22/
You can ofcourse use id
to simplify the code
To assign an id
just use text.id = 'your-id'
When creating the newSet
text.id = 'weight-'+weight;
and when clearing/populating
attr = paper.getById('weight-'+obj.weight);
Working demo at http://jsfiddle.net/G94sQ/23/
(additionally: you are using jquery 1.11 in which the .toggle
method just shows/hide the element and does not rotate the click
functions as earlier versions. So I changed your code to 1.4.2 as a quick fix..)