Skip to content

Commit

Permalink
implemented Base64 attribute on DonutChart
Browse files Browse the repository at this point in the history
  • Loading branch information
tieniber committed Nov 8, 2017
1 parent 5ecd2e0 commit b18deb2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/ChartJS/widgets/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,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
8 changes: 8 additions & 0 deletions src/ChartJS/widgets/DoughnutChart/DoughnutChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,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="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
4 changes: 3 additions & 1 deletion src/ChartJS/widgets/DoughnutChart/widget/DoughnutChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ define([
}));

// Set the con
html.set(this._numberNode, this._data.object.get(this.numberInside).toString());
if(this.numberInside) {
html.set(this._numberNode, this._data.object.get(this.numberInside).toString());
}

// Add class to determain chart type
this._addChartClass("chartjs-doughnut-chart");
Expand Down
Binary file modified test/widgets/ChartJS.mpk
Binary file not shown.

0 comments on commit b18deb2

Please sign in to comment.