Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Extension issue

Hello, I have  a problem in implementing an extension into my qvw.

The code  is the following one:

<!DOCTYPE html>

<html>

<body>

<script src="http://d3js.org/d3.v3.min.js"></script>

<script src="http://d3js.org/topojson.v1.min.js"></script>

<script src="http://datamaps.github.io/scripts/datamaps.world.min.js"></script>

<div id="container" style="position: relative; width: 500px; height: 300px;"></div>

<script>

    var map = new Datamap({

        element: document.getElementById('container'),

        fills: {

            defaultFill: 'rgba(23,48,210,0.9)' //any hex, color name or rgb/rgba value

        }

    });

</script>

</body>

</html>

and it's working fine ; the libraries are working and the javascript code is working fibe.

I tried to implement it in qlikview:

Qva.LoadScript("http://datamaps.github.io/scripts/datamaps.world.min.js", function() {

Qva.LoadScript("http://d3js.org/topojson.v1.min.js", function() {

Qva.LoadScript("http://d3js.org/d3.v3.min.js", function() {

Qva.AddExtension('map2', function() {

var html="";

var _this = this;

html='<div id="container"; style="position: relative; width: 300px; height: 140px;"></div>';

var map = new Datamap({

        element: document.getElementById('container'),

        fills: {

            defaultFill: 'rgba(23,48,210,0.9)' //any hex, color name or rgb/rgba value

        }

    });

this.Element.innerHTML+=html;

},true);

});

});

});

and I receive the following error:

'An error has occured in the script on this page

LINE: 0

CHAR: 0

ERROR: Script error

CODE: 0

url: http://d3js.org/d3.v3.min.js

Can you please help me? Thank you very much!

1 Solution

Accepted Solutions
Brian_Munz
Employee
Employee

The problem is that you're trying to run d3 on a div that hasn't been added to the extension yet.  If you simply move this.Element.innerHTML += html; to be above the code that adds the map, it works fine.  I tested this code and I saw a map:

Qva.LoadScript("http://datamaps.github.io/scripts/datamaps.world.min.js", function() {

  Qva.LoadScript("http://d3js.org/topojson.v1.min.js", function() {

  Qva.LoadScript("http://d3js.org/d3.v3.min.js", function() {

  Qva.AddExtension('map2', function() {

  var html = "";

  var _this = this;

  html = '<div id="container"; style="position: relative; width: 300px; height: 140px;"></div>';

  this.Element.innerHTML += html;

  var map = new Datamap({

  element : document.getElementById('container'),

  fills : {

  defaultFill : 'rgba(23,48,210,0.9)' //any hex, color name or rgb/rgba value

  }

  });

  }, true);

  });

  });

});

View solution in original post

8 Replies
Brian_Munz
Employee
Employee

The problem is that you're trying to run d3 on a div that hasn't been added to the extension yet.  If you simply move this.Element.innerHTML += html; to be above the code that adds the map, it works fine.  I tested this code and I saw a map:

Qva.LoadScript("http://datamaps.github.io/scripts/datamaps.world.min.js", function() {

  Qva.LoadScript("http://d3js.org/topojson.v1.min.js", function() {

  Qva.LoadScript("http://d3js.org/d3.v3.min.js", function() {

  Qva.AddExtension('map2', function() {

  var html = "";

  var _this = this;

  html = '<div id="container"; style="position: relative; width: 300px; height: 140px;"></div>';

  this.Element.innerHTML += html;

  var map = new Datamap({

  element : document.getElementById('container'),

  fills : {

  defaultFill : 'rgba(23,48,210,0.9)' //any hex, color name or rgb/rgba value

  }

  });

  }, true);

  });

  });

});

Not applicable
Author

Hello, I tried on another computer and it worked perfectly, but on mine didn't worked.

Same error in including Javascript library d3..

Do you have any hints?

Not applicable
Author

Also on antoher computer didn't worked. So, on 2 didn't worked, on another it worked. I don't think it's a proxy issue.

Brian_Munz
Employee
Employee

What version of IE are the computers running?

Not applicable
Author

Internet Explorer 8

Brian_Munz
Employee
Employee

Is the computer who has it working running IE 9 or higher?

Not applicable
Author

Hello!!!

Thank you very much!!!!!

I installed Internet explorer 9. Seems that the version of the javascript library was working on IE 9+.

Thank you, again!!!!!!!!!!!

Brian_Munz
Employee
Employee

No problem!

D3 is a javascript library that only works with more modern browsers such as IE9 and above.