Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/export chart #54

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
6 changes: 6 additions & 0 deletions beer-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
<button class="refresh-curr-beer-chart" title="Refresh"></button>
<div class="beer-chart-legend-label">Refresh Chart</div>
<br class="crystal" />
</div>
<div class="beer-chart-legend-row">
<button class="save-curr-beer-chart" title="Save"></button>
<div class="beer-chart-legend-label">Save Chart</div>
<br class="crystal" />
<img id="hiddenBeerChartImg" style="display: none;" />
</div>
<div class="beer-chart-legend-row last">
<button class="chart-help" title="Help"></button>
Expand Down
1 change: 1 addition & 0 deletions control-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<button id="new-controls">New</button>
<button id="edit-controls">Edit</button>
<button id="saveas-controls">Save As</button>
<button id="savepng-controls">Save as Image</button>
<button id="refresh-controls">Refresh</button>
<button id="help-profile" class="profile-help">Help</button>
</div>
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function prepareJSON($input) {
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="js/spin.js"></script>
<script type="text/javascript" src="js/dygraph-combined.js"></script>
<script type="text/javascript" src="js/dygraph-extra.js"></script>
<script type="text/javascript">
// pass parameters to JavaScript
window.tempFormat = <?php echo "'$tempFormat'" ?>;
Expand Down
8 changes: 8 additions & 0 deletions js/beer-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ 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(currBeerChart, img);

});

var idx = 0;
$('#curr-beer-chart-legend .beer-chart-legend-row').each(function() {
if ( ! $(this).hasClass("time") && ! $(this).is(":hidden") ) {
Expand Down Expand Up @@ -518,6 +525,7 @@ $(document).ready(function(){
$("button.refresh-curr-beer-chart").button({ icons: {primary: "ui-icon-refresh" }, text: false }).click(function(){
drawBeerChart(window.beerName, 'curr-beer-chart');
});


$('#chart-help-popup')
.dialog({
Expand Down
8 changes: 8 additions & 0 deletions js/control-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function applySettings(){
var profileTable;
var profileEdit;
var profileSelect;
var currBeerProfileChart;

function renderProfile(beerProfile) {
"use strict";
Expand All @@ -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 );
}

Expand Down Expand Up @@ -323,6 +325,7 @@ function drawProfileChart(divId, profileObj) {
profileObj.toCSV(true, ['date', 'temperature']),
chartConfig
);
currBeerProfileChart = chart;
}

function loadProfile(profile, onProfileLoaded) {
Expand Down Expand Up @@ -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();
Expand Down
Loading