diff --git a/control-panel.php b/control-panel.php
index 181e259..9977710 100644
--- a/control-panel.php
+++ b/control-panel.php
@@ -39,6 +39,7 @@
+
diff --git a/js/beer-chart.js b/js/beer-chart.js
index a2d58ef..0db96d1 100644
--- a/js/beer-chart.js
+++ b/js/beer-chart.js
@@ -439,8 +439,8 @@ function drawBeerChart(beerToDraw, div){
$("button.save-curr-beer-chart").button({ icons: {primary: "ui-icon-refresh" }, text: false }).click(function(){
var img = document.getElementById('hiddenBeerChartImg');
- Dygraph.Export.asPNG(beerChart, img);
- window.location.href = img.src.replace('image/png','image/octet-stream');
+ Dygraph.Export.asPNG(currBeerChart, img);
+
});
var idx = 0;
diff --git a/js/control-panel.js b/js/control-panel.js
index cd780e4..5953c18 100644
--- a/js/control-panel.js
+++ b/js/control-panel.js
@@ -158,6 +158,7 @@ function applySettings(){
var profileTable;
var profileEdit;
var profileSelect;
+var currBeerProfileChart;
function renderProfile(beerProfile) {
"use strict";
@@ -166,6 +167,7 @@ function renderProfile(beerProfile) {
$("#profileTableName").text(decodeURIComponent(window.profileName));
$("button#edit-controls").show();
$("button#saveas-controls").show();
+ $("button#savepng-controls").show();
drawProfileChart("profileChartDiv", profileTable );
}
@@ -323,6 +325,7 @@ function drawProfileChart(divId, profileObj) {
profileObj.toCSV(true, ['date', 'temperature']),
chartConfig
);
+ currBeerProfileChart = chart;
}
function loadProfile(profile, onProfileLoaded) {
@@ -586,6 +589,11 @@ $(document).ready(function(){
profileEdit.render( profileTable.toJSON() );
showProfileEditDialog(true, "Save Temperature Profile As", true);
}).hide();
+
+ $("button#savepng-controls").button({ icons: {primary: "ui-icon-copy" } }).click(function() {
+ var img = document.getElementById('hiddenBeerChartImg');
+ Dygraph.Export.asPNG(currBeerProfileChart, img);
+ }).hide();
$("button#help-profile").button({ icons: {primary: "ui-icon-help" } }).click(function() {
showProfileHelpDialog();
diff --git a/js/dygraph-extra.js b/js/dygraph-extra.js
index cdeff8c..3e8f04d 100644
--- a/js/dygraph-extra.js
+++ b/js/dygraph-extra.js
@@ -79,7 +79,12 @@ Dygraph.Export.isSupported = function () {
Dygraph.Export.asPNG = function (dygraph, img, userOptions) {
"use strict";
var canvas = Dygraph.Export.asCanvas(dygraph, userOptions);
- img.src = canvas.toDataURL();
+ //img.src = canvas.toDataURL();
+ window.open(canvas.toDataURL("image/png"));
+
+ //img.download = "chart.png";
+ //img.href = canvas.toDataURL("image/png").replace(/^data:image\/[^;]/, 'data:application/octet-stream');
+
};
/**