Skip to content

Instantly share code, notes, and snippets.

@asizer
Forked from mbostock/.block
Last active August 29, 2015 14:04
Show Gist options
  • Save asizer/6c1ebde585085df78bda to your computer and use it in GitHub Desktop.
Save asizer/6c1ebde585085df78bda to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.x.axis path {
display: none;
}
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.js"></script>
<script>
var margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var parseDate = d3.time.format("%d-%b-%y").parse;
var x = d3.time.scale()
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var line = d3.svg.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.close); });
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
data = [{
"x": 1406739606000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406739666000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406739726000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406739786000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406739846000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406739906000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406739966000,
"y": 1,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740026000,
"y": 1,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740086000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740146000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740206000,
"y": 1,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740266000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740326000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740386000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740446000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740506000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740566000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740626000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740686000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740746000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740806000,
"y": 1,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740866000,
"y": 1,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740926000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406740986000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741046000,
"y": 1,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741106000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741166000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741226000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741286000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741346000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741406000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741466000,
"y": 0,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741526000,
"y": 8,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406741537000,
"y": 2,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}, {
"x": 1406742438000,
"y": 17,
"color": null,
"hostname": "EPODSDEV1",
"countername": "CPU % Total",
"alerts": [{
"_id": "789c6086-e1da-490e-9811-430e7e0e4472",
"IsAlert": false,
"AlertType": "$gte",
"ValidationValue": 85
}],
"shape": "square",
"series": 0
}];
x.domain(d3.extent(data, function(d) {
return d.x;
}));
y.domain(d3.extent(data, function(d) { return d.y; }));
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Price ($)");
svg.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment