Skip to content

Commit 2c22748

Browse files
committed
skip base64 string if the canvasNode is null
1 parent c15c379 commit 2c22748

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/ChartJS/widgets/Core.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,22 +704,29 @@ define([
704704
_animationComplete: function() {
705705
logger.debug(this.id + "._animationComplete");
706706
if (this.base64Attr) {
707-
this._mxObj.set(this.base64Attr, this._getBase64StringFromCanvasWithBackground("white"));
707+
var base64String = this._getBase64StringFromCanvasWithBackground("white");
708+
if (base64String) {
709+
this._mxObj.set(this.base64Attr, base64String);
710+
}
708711

709712
}
710713
},
711714

712715
/**
713716
* Get Base64 String From Canvas Node with Background
714717
* ---
718+
* @since Dec 7, 2017
719+
* + returns null if the canvasNode is undefined
715720
* @author Conner Charlebois
716721
* @since 10 Nov, 2017
717722
* @param {String} backgroundColor - CSS color for the background fill
718723
* @returns {String} - the base64 String with the background fill applied.
719724
* @see https://stackoverflow.com/a/44174406/1513051
725+
*
720726
*/
721727
_getBase64StringFromCanvasWithBackground: function(backgroundColor) {
722728

729+
if (!this.canvasNode) return null;
723730
var context = this.canvasNode.getContext('2d');
724731
var canvas = context.canvas;
725732
//cache height and width
@@ -748,4 +755,4 @@ define([
748755
}
749756

750757
});
751-
});
758+
});

test/[Test] ChartJS.mpr

0 Bytes
Binary file not shown.

test/widgets/ChartJS.mpk

55 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)