Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
A456B123
Contributor II
Contributor II

Plotly in Qlik Sense Extension - SyntaxError: Unexpected token '<'

Hello everybody,

I'm currently trying to integrate Plotly into Qlik. However, I always get the error message: "Uncaught SyntaxError: Unexpected token '<'".

The Plotly script works outside of Qlik, so I assume that the problem belongs to Qlik himself or my programming skills in Qlik. ;D

This is how I integrated it into Qlik:

 

define( [
        'jquery',
		'qlik',
		'Plotly'
    ],
    function ( $, qlik, Plotly ) {
        'use strict';

        return {

            paint: function ( $element, layout ) {

				$element.empty();
				
				$(document).ready(function() {
					var s = document.createElement("script");
					s.type = "text/javascript";
					s.charset = 'utf-8';
					s.src="https://cdn.plot.ly/plotly-1.2.0.min.js";

					$("head").append(s);
					
				});
				
//############################Other Stuff
            }
        };
});

 

That's how I call it (Simple example from the Plotly page: https://plot.ly/javascript/getting-started/😞

 

TESTER = document.getElementById('tester');
Plotly.plot( TESTER, [{
x: [1, 2, 3, 4, 5],
y: [1, 2, 4, 8, 16] }], {
margin: { t: 0 } } );

 

After calling "Plotly.plot (TESTER ...);" I get the following error message: "Uncaught ReferenceError: Plotly is not defined". I think that's because there were problems interpreting the script...

Can you detect a mistake? The current version with the link "https://cdn.plot.ly/plotly-latest.min.js" and as local  plotly-latest.min.js doesn't work either.

Thank you very much for your help and have a nice weekend

A456B123

Labels (3)
1 Reply
ErikWetterberg

Hi,

you could try to include the link to plotly in your array of dependencies instead of ‘Plotly’, which probably is what causes the error. If Plotly supports loading with requirejs that might work.