Skip to content

Commit

Permalink
merge base64 from Eric
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcharlebois committed Nov 8, 2017
2 parents 3b8d60a + b18deb2 commit a689afa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
15 changes: 15 additions & 0 deletions src/ChartJS/widgets/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,21 @@ define([

_animationComplete: function () {
logger.debug(this.id + "._animationComplete");
if(this.base64Attr) {
var ctx = this.canvasNode.getContext('2d');
var imgData=ctx.getImageData(0,0,this.canvasNode.width,this.canvasNode.height);
var data=imgData.data;
for(var i=0;i<data.length;i+=4){
if(data[i+3]<255){
data[i]=255;
data[i+1]=255;
data[i+2]=255;
data[i+3]=255;
}
}
ctx.putImageData(imgData,0,0);
this._mxObj.set(this.base64Attr, this.canvasNode.toDataURL("image/jpeg"));
}
// Use this.canvasNode.toDataURL() to get an image
}

Expand Down
16 changes: 8 additions & 8 deletions src/ChartJS/widgets/DoughnutChart/DoughnutChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@
<description>Microflow to invoke when chart canvas is clicked. This Microflow will pass the Dataset object 'Data set entity'</description>
<returnType type="Void"></returnType>
</property>
<property key="onDestroyMf" type="microflow" required="false" entityProperty="sourceentity">
<caption>On Destroy Microflow</caption>
<category>Behavior</category>
<description>Microflow to be called when the widget is destroyed. This can be used to destroy the Chart Entity from 'Data Source'.

Note: This is experimental. In case of non-persistent objects this should not be necessary, and in MX 7 this is useless. Only use this if you experience memory leaks in Mendix 5</description>
<returnType type="Void"></returnType>
</property>
<property key="base64Attr" type="attribute" required="false">
<caption>Base 64 Attribute</caption>
<category>Behavior</category>
<description>The attribute to store the base64 encoding of the chart when rendered.</description>
<attributeTypes>
<attributeType name="String"/>
</attributeTypes>
</property>
<!-- Settings -->
<property key="responsive" type="boolean" required="true" defaultValue="true">
<caption>Responsive</caption>
Expand Down
6 changes: 3 additions & 3 deletions src/ChartJS/widgets/DoughnutChart/widget/DoughnutChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ define([
this._resize();
}));

if (this.numberInside && this._numberNode) {
var content = this._data.object.get(this.numberInside);
html.set(this._numberNode, content !== null ? content.toString() : "");
// Set the con
if (this.numberInside) {
html.set(this._numberNode, this._data.object.get(this.numberInside).toString());
}

// Add class to determain chart type
Expand Down
Binary file modified test/widgets/ChartJS.mpk
Binary file not shown.

0 comments on commit a689afa

Please sign in to comment.