I have an AngularJS directive that creates a Sparkline, which I then use inside a couple of modules. The app behaves as expected in Firefox (51..), however when viewed in the Google Chrome browser (56..), the app fails to deliver the desired graphic.
Note that I have tested the actual app from a server and this is not a Cross origin requests issue. Furthermore, upon inspection, no errors are reported on console.
This plunker reproduces my original issue: https://plnkr.co/edit/K9wO5Ibx1Uk8ygkOUGU6?p=preview
Thanks in advance for any assistance.
index.html
<html>
<head>
<link rel="stylesheet" href="style.css" />
<script src="jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="jquery.sparkline.js"></script>
<script src="app.module.js"></script>
<script src="ab-help.module.js"></script>
<script src="ab-help.component.js"></script>
<script src="ab-spkline.directive.js"></script>
</head>
<body ng-app="abMyapp">
<h2>Testing sparkline directive via component in angular </h2>
<p>This is outside the ab-help tags</p>
<spk-line data="30, 1, 14, 10, 8, 15, 6, 13, 2"></spk-line>
<ab-help></ab-help>
</body>
</html>
The various .js parts are compressed below:
// Define the 'app' module
angular.module('abMyapp', ['abHelp']); //note in my original app more modules are injected here, example on plunker only shows one!
// Define the `abHelp` module
angular.module('abHelp', []);
// Register `abHelp` component, along with its associated controller and template
angular.
module('abHelp').
component('abHelp', {
templateUrl: 'ab-help.template.html',
controller: function(){
this.myData = "1, 1, 4, 14, 4, 15, 6, 23, 4";
}
});
//template
<p>This is from inside component</p>
<spk-line data="3, 1, 4, 10, 8, 5, 6, 3, 4"></spk-line> <br>
<spk-line data="{{ $ctrl.myData }}"></spk-line>
The all-important Sparkline directive with thanks for http://jsfiddle.net/NAA5G/ and of course http://omnipotent.net/jquery.sparkline/#s-about, & JQuery, Angular!
angular.module('abMyapp').directive("spkLine", function() {
return {
restrict: "E",
scope: {
data: "@"
},
compile: function(tElement, tAttrs, transclude) {
tElement.replaceWith("<span>" + tAttrs.data + "</span>");
return function(scope, element, attrs) {
attrs.$observe("data", function(newValue) {
element.html(newValue);
element.sparkline('html', {
type: 'line'
});
});
};
}
};
});
Actually sorted by useing release 2.1.2 of the jquery sparkline. This has a tooltips issue which I have raised with issue #188
Thanks for having a look.