mhemesath / r2d3

Raphael Rendered, Data Driven Documents
MIT License
546 stars 133 forks source link

SVG image support #117

Closed marciocaraballo closed 10 years ago

marciocaraballo commented 11 years ago

Hi, I'm trying to append an image via svg:image, but it isn't showing the image in IE8. Maybe I am missing something, but is the support added for that?

Sorry if this is already an issue or somewhere the solution is given, but I can't find it.

Thanks!

mhemesath commented 11 years ago

Shoot, thats a bug. You can fix it by changing

case 'IMG':
      this.raphaelNode = paper.image('#', 0, 0, 0, 0);
      break;

to

case 'IMAGE':
      this.raphaelNode = paper.image('#', 0, 0, 0, 0);
      break;

here https://github.com/mhemesath/r2d3/blob/master/src/raphael/element.js#L45

marciocaraballo commented 11 years ago

Thank you! However, when you do the paper.image(), don't you have to provide the path to the image about to be loaded? Instead of the '#' ?

I'm just getting familiar with the code, maybe I'm wrong.

Thanks for the fast anwser.

mhemesath commented 11 years ago

Yeah, but the way D3 works I don't have the path at the point the element is appened. So I set it to # until the attribute is set.

mhemesath commented 11 years ago

The href is updated later here https://github.com/mhemesath/r2d3/blob/master/src/raphael/element.js#L144

marciocaraballo commented 11 years ago

Thank you, I'll check that out!

peterbault commented 11 years ago

I'm running into this issue as well in IE8. I tried the suggested fix but it ends up never hitting the case in the switch statement. Later when it tries to update the href, you get a null reference for this.raphaelNode because it was never set.

I've been banging on it for a few hours but can't figure out the solution.

this is an amazing tool btw

amandahebb commented 11 years ago

Hi, I'm finding the same as icespide. Just wondering if you had managed to resolve it at all?

Not sure if this helps but my code is

var img = node.append("svg:Image");
img.attr("href","http://localhost/Images/Test.png")

(I've also tried node.append("Image") but get the same problem)

Thanks

mhemesath commented 10 years ago

I'll take a look at this now, sorry this sat stagnant for so long.