From cfd458d5b6c16f20766a6e48a5b6de908b6c261d Mon Sep 17 00:00:00 2001 From: str4d Date: Wed, 23 Aug 2017 19:51:23 +0100 Subject: [PATCH 1/3] Add link to export timeline charts as PNGs --- codespeed/static/css/main.css | 16 ++++++++++++++++ codespeed/static/css/timeline.css | 3 +++ codespeed/static/js/timeline.js | 6 +++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/codespeed/static/css/main.css b/codespeed/static/css/main.css index da86b438..4750b78c 100644 --- a/codespeed/static/css/main.css +++ b/codespeed/static/css/main.css @@ -484,6 +484,22 @@ p.note { background-image: url(../images/note.png); } +div.plotpng a { + background-color: #F1F1F1; + background-repeat: no-repeat; + background-position: 3px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + border-radius: 10px; + -moz-box-shadow: 3px 3px 3px #888; + -webkit-box-shadow: 3px 3px 3px #888; + box-shadow: 3px 3px 3px #888; + float: right; + margin-top: 20px; + padding: 1em; + text-decoration: underline; +} + div.footer{ color: white; font-size: small; diff --git a/codespeed/static/css/timeline.css b/codespeed/static/css/timeline.css index 937a177e..e4c189a9 100644 --- a/codespeed/static/css/timeline.css +++ b/codespeed/static/css/timeline.css @@ -1,3 +1,6 @@ select#baseline { width: 100%; } +div#plotdescription { + margin-right: 55px; +} diff --git a/codespeed/static/js/timeline.js b/codespeed/static/js/timeline.js index 51731fcf..c6e780c9 100644 --- a/codespeed/static/js/timeline.js +++ b/codespeed/static/js/timeline.js @@ -165,7 +165,11 @@ function renderPlot(data) { digits++; } } - $("#plotgrid").html('
'); + $("#plotgrid").html('
PNG
'); + + $("#pnglink").click(function() { + window.location = $("#plot").jqplotToImageStr(); + }); if (data.benchmark_description) { $("#plotdescription").html('

' + data.benchmark + ': ' + data.benchmark_description + '

'); From d91c362f78edd8becd7e851559cb984149dc7ff0 Mon Sep 17 00:00:00 2001 From: str4d Date: Fri, 25 Aug 2017 11:12:33 +0100 Subject: [PATCH 2/3] Add links to export comparison charts as PNGs --- codespeed/static/js/comparison.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/codespeed/static/js/comparison.js b/codespeed/static/js/comparison.js index b05d77e6..cf723697 100644 --- a/codespeed/static/js/comparison.js +++ b/codespeed/static/js/comparison.js @@ -54,9 +54,14 @@ function refreshContent() { if (benchmarks.length === 0) { continue; } var plotid = "plot" + plotcounter; - $("#plotwrapper").append('
'); + var pngid = "pnglink" + plotcounter; + $("#plotwrapper").append('
'); plotcounter++; renderComparisonPlot(plotid, benchmarks, exes, enviros, conf.bas, conf.chart, conf.hor); + $("#" + pngid).data("plot", plotid); + $("#" + pngid).click(function() { + window.location = $("#" + $(this).data("plot")).jqplotToImageStr(); + }); } }); } From a29f1273d18272d270c27fcde836a0e5b9a71a2c Mon Sep 17 00:00:00 2001 From: str4d Date: Fri, 25 Aug 2017 11:45:03 +0100 Subject: [PATCH 3/3] Workaround for Chrome removing top frame navigation to data URLs See https://stackoverflow.com/a/45789588/3317191 --- codespeed/static/js/comparison.js | 7 ++++++- codespeed/static/js/timeline.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/codespeed/static/js/comparison.js b/codespeed/static/js/comparison.js index cf723697..028204a9 100644 --- a/codespeed/static/js/comparison.js +++ b/codespeed/static/js/comparison.js @@ -60,7 +60,12 @@ function refreshContent() { renderComparisonPlot(plotid, benchmarks, exes, enviros, conf.bas, conf.chart, conf.hor); $("#" + pngid).data("plot", plotid); $("#" + pngid).click(function() { - window.location = $("#" + $(this).data("plot")).jqplotToImageStr(); + var string = $("#" + $(this).data("plot")).jqplotToImageStr(); + var iframe = "" + var x = window.open(); + x.document.open(); + x.document.write(iframe); + x.document.close(); }); } }); diff --git a/codespeed/static/js/timeline.js b/codespeed/static/js/timeline.js index c6e780c9..9653968a 100644 --- a/codespeed/static/js/timeline.js +++ b/codespeed/static/js/timeline.js @@ -168,7 +168,12 @@ function renderPlot(data) { $("#plotgrid").html('
'); $("#pnglink").click(function() { - window.location = $("#plot").jqplotToImageStr(); + var string = $("#plot").jqplotToImageStr(); + var iframe = "" + var x = window.open(); + x.document.open(); + x.document.write(iframe); + x.document.close(); }); if (data.benchmark_description) {