Accepted answer

The issues are

  1. You get the raw DOM nodes, and not the RaphaelJS wrapped objects (because you use document.getElementsByTagName)
  2. You set data but try to access it through attr.
  3. In the fiddle, the newSet is not correctly built becuase you use the i 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

    if (item.type=='text')

to get the text node.
Working demo at Have a look at

You can ofcourse use id to simplify the code

To assign an id just use = 'your-id'

When creating the newSet = 'weight-'+weight;

and when clearing/populating

attr = paper.getById('weight-'+obj.weight);

Working demo at

(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..)

Related Query

More Query from same tag