Skip to content

Commit

Permalink
skip base64 string if the canvasNode is null
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcharlebois committed Dec 7, 2017
1 parent c15c379 commit 2c22748
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ChartJS/widgets/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,22 +704,29 @@ define([
_animationComplete: function() {
logger.debug(this.id + "._animationComplete");
if (this.base64Attr) {
this._mxObj.set(this.base64Attr, this._getBase64StringFromCanvasWithBackground("white"));
var base64String = this._getBase64StringFromCanvasWithBackground("white");
if (base64String) {
this._mxObj.set(this.base64Attr, base64String);
}

}
},

/**
* Get Base64 String From Canvas Node with Background
* ---
* @since Dec 7, 2017
* + returns null if the canvasNode is undefined
* @author Conner Charlebois
* @since 10 Nov, 2017
* @param {String} backgroundColor - CSS color for the background fill
* @returns {String} - the base64 String with the background fill applied.
* @see https://stackoverflow.com/a/44174406/1513051
*
*/
_getBase64StringFromCanvasWithBackground: function(backgroundColor) {

if (!this.canvasNode) return null;
var context = this.canvasNode.getContext('2d');
var canvas = context.canvas;
//cache height and width
Expand Down Expand Up @@ -748,4 +755,4 @@ define([
}

});
});
});
Binary file modified test/[Test] ChartJS.mpr
Binary file not shown.
Binary file modified test/widgets/ChartJS.mpk
Binary file not shown.

0 comments on commit 2c22748

Please sign in to comment.