Commit 4b21c2cc authored by Mahdi Mahmoudy's avatar Mahdi Mahmoudy
Browse files

download chart option

parent 6ed199e2
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
<input type="checkbox" ng-model="$parent.showChildren"> Show children <input type="checkbox" ng-model="$parent.showChildren"> Show children
</label> </label>
<a class="button small" ng-click="applyOptions();$close()">Apply</a> <a class="button small" ng-click="applyOptions();$close()">Apply</a>
<a class="button small" ng-click="downloadChart();$close()">Download Chart</a>
</pane> </pane>
</dropdown-toggle> </dropdown-toggle>
</div> </div>
......
...@@ -22,6 +22,36 @@ angular ...@@ -22,6 +22,36 @@ angular
scope.applyOptions = function(){ scope.applyOptions = function(){
that.drawChart(scope); that.drawChart(scope);
}; };
scope.downloadChart = function() {
if (!scope.termBoxHeight) {
return;
}
if (!scope.termBoxWidth) {
return;
}
// Requesting a larger chart from the service
var chartPromise = chartService.getChart(
scope.ids,
scope.showIds,
scope.showKey,
Math.round(scope.termBoxWidth * 2.5),
Math.round(scope.termBoxHeight * 2.5),
Math.round(scope.fontSize * 2.5),
scope.showSlimColours,
scope.showChildren,
);
chartPromise.then(function(d) {
var a = document.createElement("a");
a.href = "data:image/png;base64," + d.data;
a.download = scope.title + ".png";
a.click();
});
}
this.drawChart(scope); this.drawChart(scope);
}, },
drawChart: function(scope) { drawChart: function(scope) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment