Skip to content

Commit a689afa

Browse files
committed
merge base64 from Eric
2 parents 3b8d60a + b18deb2 commit a689afa

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

src/ChartJS/widgets/Core.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,21 @@ define([
705705

706706
_animationComplete: function () {
707707
logger.debug(this.id + "._animationComplete");
708+
if(this.base64Attr) {
709+
var ctx = this.canvasNode.getContext('2d');
710+
var imgData=ctx.getImageData(0,0,this.canvasNode.width,this.canvasNode.height);
711+
var data=imgData.data;
712+
for(var i=0;i<data.length;i+=4){
713+
if(data[i+3]<255){
714+
data[i]=255;
715+
data[i+1]=255;
716+
data[i+2]=255;
717+
data[i+3]=255;
718+
}
719+
}
720+
ctx.putImageData(imgData,0,0);
721+
this._mxObj.set(this.base64Attr, this.canvasNode.toDataURL("image/jpeg"));
722+
}
708723
// Use this.canvasNode.toDataURL() to get an image
709724
}
710725

src/ChartJS/widgets/DoughnutChart/DoughnutChart.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@
211211
<description>Microflow to invoke when chart canvas is clicked. This Microflow will pass the Dataset object 'Data set entity'</description>
212212
<returnType type="Void"></returnType>
213213
</property>
214-
<property key="onDestroyMf" type="microflow" required="false" entityProperty="sourceentity">
215-
<caption>On Destroy Microflow</caption>
216-
<category>Behavior</category>
217-
<description>Microflow to be called when the widget is destroyed. This can be used to destroy the Chart Entity from 'Data Source'.
218-
219-
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>
220-
<returnType type="Void"></returnType>
221-
</property>
214+
<property key="base64Attr" type="attribute" required="false">
215+
<caption>Base 64 Attribute</caption>
216+
<category>Behavior</category>
217+
<description>The attribute to store the base64 encoding of the chart when rendered.</description>
218+
<attributeTypes>
219+
<attributeType name="String"/>
220+
</attributeTypes>
221+
</property>
222222
<!-- Settings -->
223223
<property key="responsive" type="boolean" required="true" defaultValue="true">
224224
<caption>Responsive</caption>

src/ChartJS/widgets/DoughnutChart/widget/DoughnutChart.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ define([
108108
this._resize();
109109
}));
110110

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

116116
// Add class to determain chart type

test/widgets/ChartJS.mpk

70 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)