Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE 9/10/11 + Canvas + SVG + orgchart.js #40

Closed
reappergrimd opened this issue Jul 26, 2016 · 10 comments
Closed

IE 9/10/11 + Canvas + SVG + orgchart.js #40

reappergrimd opened this issue Jul 26, 2016 · 10 comments

Comments

@reappergrimd
Copy link

Hi
Firstly ,Great work on your project.
Secondly , i have picked up an issue where when using the addnode function and providing
an SVG ( i have checked the formatting all correct and the function works perfectly in chrome) it will not display any thing in the bound canvas objects.

when using the Canvas and SVG without the orgchart.js it seems to work fine in both ie and chrome,
but it has come down to i really want to use your orgchart.js as it handles so nicely.

Here is a snippet that works in chrome ( i have a loop around this code to produce more levels)


var data = '<svg width="400px" height="200px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
'<title> designation</title>' +
'<g id="columnGroup">' +
'<rect x="65" y="10" width="75" height="110" fill="gainsboro"/>' +
' <text x="0" y="30" font-size="18px" font-weight="bold" fill="crimson">' +
'<tspan x="0" dy="1.5em"> test 0 </tspan>' +
'<tspan x="0" dy="1em"> test 1 </tspan>' +
'<tspan x="0" dy="1em"> test 2</tspan>' +
'</text>' +
'<text x="250" y="30" font-size="18px" text-anchor="middle">' +
'<tspan x="250" font-weight="bold" fill="crimson">Actual</tspan>' +
'<tspan x="250" dy="1.5em"> 7 </tspan>' +
'<tspan x="250" dy="1em"> 8 </tspan>' +
'<tspan x="250" dy="1em"> 3 </tspan>' +
'</text>' +
'<text x="350" y="30" font-size="18px" text-anchor="middle">' +
'<tspan x="350" font-weight="bold" fill="crimson">Plan</tspan>' +
'<tspan x="350" dy="1.5em"> 8 </tspan>' +
'<tspan x="350" dy="1em"> 8 </tspan>' +
 '<tspan x="350" dy="1em"> 2 </tspan>' +
'</text>' +
'</g>' +
'</svg>';


var img = new Image();
var DOMURL = window.URL || window.webkitURL || self;
var svg = new Blob([data], { type: 'image/svg+xml;charset=utf-8' });
var url = DOMURL.createObjectURL(svg);

o.addNode(Id, reportingid, 'u', '', '', '', '', '', '', url, 'C');
o.drawChart('canvas1', 'c', true);

@dabeng
Copy link
Owner

dabeng commented Jul 27, 2016

Wow, so awesome use case!Give me some moments to comprehand your scenario

@reappergrimd
Copy link
Author

Sorry was in a hurry when i posted this ;) it is a interesting use case that i have spent quite a bit of time on myself.

As i don't have a clear vision of where you intend to take your project in the future i did not feel i should be the one to make changes that would ultimately change your library to only fit my needs.

The code above forms part of a database call via json return that i use to populate not a org chart as much but a node based diagram for my wireless systems performance at home( i can see the activity on my nodes in the house ... looks cool haha)

@dabeng
Copy link
Owner

dabeng commented Jul 29, 2016

Sorry @reappergrimd , going through all your code snippets and descriptions, I still can't get your point. I guess that maybe you just want embed svg into the nodes of orgchart, right?

@reappergrimd
Copy link
Author

Morning , Basically yes , the code works perfectly in a chrome environment and the svg is embedded but not in IE.

@dabeng
Copy link
Owner

dabeng commented Aug 3, 2016

Hi @reappergrimd , is the following picture what you want?
screenshot from 2016-08-03 09-37-25

@reappergrimd
Copy link
Author

reappergrimd commented Aug 4, 2016

Hi , sorry for the delay. in essence that is exactly the view i would like in IE.
"It's like you can read my mind :) )

@dabeng
Copy link
Owner

dabeng commented Aug 4, 2016

Hello.In fact, through my testing , I got the similar snapshot in IE 9/10/11, just there is a bit difference in fonts.
2016-08-05_6-00-09

@reappergrimd
Copy link
Author

Would you mind sharing your code you used to accomplish this, i want to make sure i haven't messed up somewhere :)

@dabeng
Copy link
Owner

dabeng commented Aug 9, 2016

I just append the img composed of svg to the root node.

    $('#chart-container').orgchart({
      'data' : datascource,
      'depth': 2,
      'nodeContent': 'title'
    });

    var data = '<svg width="400px" height="200px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
      '<title> designation</title>' +
      '<g id="columnGroup">' +
      '<rect x="65" y="10" width="75" height="110" fill="gainsboro"/>' +
      ' <text x="0" y="30" font-size="18px" font-weight="bold" fill="crimson">' +
      '<tspan x="0" dy="1.5em"> test 0 </tspan>' +
      '<tspan x="0" dy="1em"> test 1 </tspan>' +
      '<tspan x="0" dy="1em"> test 2</tspan>' +
      '</text>' +
      '<text x="250" y="30" font-size="18px" text-anchor="middle">' +
      '<tspan x="250" font-weight="bold" fill="crimson">Actual</tspan>' +
      '<tspan x="250" dy="1.5em"> 7 </tspan>' +
      '<tspan x="250" dy="1em"> 8 </tspan>' +
      '<tspan x="250" dy="1em"> 3 </tspan>' +
      '</text>' +
      '<text x="350" y="30" font-size="18px" text-anchor="middle">' +
      '<tspan x="350" font-weight="bold" fill="crimson">Plan</tspan>' +
      '<tspan x="350" dy="1.5em"> 8 </tspan>' +
      '<tspan x="350" dy="1em"> 8 </tspan>' +
       '<tspan x="350" dy="1em"> 2 </tspan>' +
      '</text>' +
      '</g>' +
      '</svg>';

      var img = new Image();
      var DOMURL = window.URL || window.webkitURL || self;
      var svg = new Blob([data], { type: 'image/svg+xml;charset=utf-8' });
      var url = DOMURL.createObjectURL(svg);
      var img = document.createElement("img");
      img.src = url;
      img.height = 130;
      $('.content:first').html(img);

@dabeng
Copy link
Owner

dabeng commented Aug 9, 2016

In fact, I am also interested to know why you build up common table with svg rather than

, ,

@dabeng dabeng closed this as completed Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants