Skip to content

Commit

Permalink
plot: Add missing assets
Browse files Browse the repository at this point in the history
  • Loading branch information
tsenart committed Aug 13, 2018
1 parent 65989a8 commit 055ddc6
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ vendor
*.lz

.DS_Store
lib/plot/assets/*
!lib/plot/assets/VERSIONS
117 changes: 117 additions & 0 deletions lib/plot/assets/dygraph.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* Default styles for the dygraphs charting library.
*/

.dygraph-legend {
position: absolute;
font-size: 14px;
z-index: 10;
width: 250px; /* labelsDivWidth */
/*
dygraphs determines these based on the presence of chart labels.
It might make more sense to create a wrapper div around the chart proper.
top: 0px;
right: 2px;
*/
background: white;
line-height: normal;
text-align: left;
overflow: hidden;
}

/* styles for a solid line in the legend */
.dygraph-legend-line {
display: inline-block;
position: relative;
bottom: .5ex;
padding-left: 1em;
height: 1px;
border-bottom-width: 2px;
border-bottom-style: solid;
/* border-bottom-color is set based on the series color */
}

/* styles for a dashed line in the legend, e.g. when strokePattern is set */
.dygraph-legend-dash {
display: inline-block;
position: relative;
bottom: .5ex;
height: 1px;
border-bottom-width: 2px;
border-bottom-style: solid;
/* border-bottom-color is set based on the series color */
/* margin-right is set based on the stroke pattern */
/* padding-left is set based on the stroke pattern */
}

.dygraph-roller {
position: absolute;
z-index: 10;
}

/* This class is shared by all annotations, including those with icons */
.dygraph-annotation {
position: absolute;
z-index: 10;
overflow: hidden;
}

/* This class only applies to annotations without icons */
/* Old class name: .dygraphDefaultAnnotation */
.dygraph-default-annotation {
border: 1px solid black;
background-color: white;
text-align: center;
}

.dygraph-axis-label {
/* position: absolute; */
/* font-size: 14px; */
z-index: 10;
line-height: normal;
overflow: hidden;
color: black; /* replaces old axisLabelColor option */
}

.dygraph-axis-label-x {
}

.dygraph-axis-label-y {
}

.dygraph-axis-label-y2 {
}

.dygraph-title {
font-weight: bold;
z-index: 10;
text-align: center;
/* font-size: based on titleHeight option */
}

.dygraph-xlabel {
text-align: center;
/* font-size: based on xLabelHeight option */
}

/* For y-axis label */
.dygraph-label-rotate-left {
text-align: center;
/* See http://caniuse.com/#feat=transforms2d */
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
}

/* For y2-axis label */
.dygraph-label-rotate-right {
text-align: center;
/* See http://caniuse.com/#feat=transforms2d */
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
}
6 changes: 6 additions & 0 deletions lib/plot/assets/dygraph.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions lib/plot/assets/html2canvas.min.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions lib/plot/assets/plot.html.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!doctype html>
<html>
<head>
<title>{{.Title}}</title>
<meta charset="utf-8">
<style>{{.DygraphsCSS}}</style>
</head>
<body>
<div id="latencies" style="font-family: Courier; width: 100%%; height: 600px"></div>
<button id="download">Download as PNG</button>
<script>{{.HTML2CanvasJS}}</script>
<script>{{.DygraphsJS}}</script>
<script>
document.getElementById("download").addEventListener("click", function(e) {
html2canvas(document.body, {background: "#fff"}).then(function(canvas) {
var url = canvas.toDataURL('image/png').replace(/^data:image\/[^;]/, 'data:application/octet-stream');
var a = document.createElement("a");
a.setAttribute("download", "vegeta-plot.png");
a.setAttribute("href", url);
a.click();
});
});
var container = document.getElementById("latencies");
var opts = {{.Opts}};
var data = {{.Data}};
var plot = new Dygraph(container, data, opts);
</script>
</body>
</html>

0 comments on commit 055ddc6

Please sign in to comment.