Is it possible to get an item from a json array to change an attribute of a rect in raphaels.js? [closed]

3

I would like to make an array that could serve as a database for my map represented by these 3 rectangles. The array will contain numbers that will serve as indicators for the colors of the rectangles. If item 1 of the array is 0, rectangle 1 will be red, if item 2 of array is 1, rectangle 2 will be blue and if item 3 of array is 2 the rectangle 3 will be yellow. I know the code can get a bit tricky, but can anyone tell me if it's possible to use this array as a DB in my application?

var r = Raphael('map', '2048', '1024');
var set = r.set();

set.push(
  r.rect(1757.6, 39.4, 18.1, 44.9),
  r.rect(1736.5, 39.4, 18.1, 44.9),
  r.rect(1715.3, 39.4, 18.1, 44.9)
);

set.attr({
  fill: '#3953A4',
  stroke: 'none'
});

var glow;
set.hover(
  function() {
    glow = this.glow({
      width: 7,
      fill: true,
      opacity: 1,
      color: '#24d'
    });
}, function() {
     glow.remove();
});

Here is the json array

var quadra_a = {[
  "lote0" : "RED",
  "lote1" : "BLUE",
  "lote2" : "YELLOW"
]};

I would like to know how to modify the attr fill of the map in rapaheljs with the array item in json.

    
asked by anonymous 11.06.2014 / 20:03

0 answers