JSFiddle - React, Tailwind, and code Playground
HTML
<div class="legend">
<ul>
<li>Time Left</li>
<li>Clicks per second</li>
</ul>
</div>
CSS
body {
background: #f4f4f4;
background: url('http://i.imgur.com/yE7vcOO.jpg');
background-size: cover;
}
.legend ul {
margin: 5px 15px;
width: 300px;
background: white;
box-shadow: 0 0 5px rgba(0,0,0,.3);
}
.legend li {
font: 12px sans-serif;
padding: 7px 30px;
position: relative;
}
.legend li:nth-child(1):before {
content: '';
width: 15px;
height: 8px;
border-radius: 50%;
position: absolute;
left: 9px;
top: 8px;
display: block;
background: rgba(0,0,200,.7);
}
.legend li:nth-child(2):before {
content: '';
width: 15px;
height: 8px;
border-radius: 50%;
position: absolute;
left: 9px;
top: 8px;
display: block;
background: rgba(0,100,0,.3);
}
svg {
font: 10px sans-serif;
background: white;
box-shadow: 0 0 5px rgba(0,0,0,.3);
margin-left: 15px;
}
.arc {
fill: rgba(0,0,200,0.7);
stroke: #000;
stroke-width: 0px;
}
.arc2 {
fill: rgba(0,100,0,0.3);
stroke: #000;
stroke-width: 0px;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.grid .tick line {
stroke: lightgrey;
opacity: 0.7;
}
.grid path {
stroke-width: 0;
}
.legend rect {
fill:white;
stroke:black;
opacity:0.8;
}
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for...
JavaScript
var n = 5, // Number of Minutes to track.
data = [0],
data2 = [0];
var margin = {top: 40, right: 20, bottom: 60, left: 60},
width = 768 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.scale.linear()
.domain([0, n])
.range([0, width]);
var y = d3.scale.linear()
.domain([0, 60])
.range([height, 0]);
var line = d3.svg.line()
.x(function(d, i) { return x(( (i) / 60) - (1/60)); })
.y(function(d, i) { return y(d); });
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 + ")");
svg.append("defs").append("clipPath")
.attr("id", "clip")
.append("rect")
.attr("width", width)
.attr("height", height);
var xAxis = svg.append("g")
.attr("class", "grid x axis")
.attr("transform", "translate(0," + y(0) + ")")
.call(d3.svg.axis().scale(x).ticks(10).orient("bottom").tickSize(-height, 0, 0));
var yAxis = svg.append("g")
.attr("class", "grid y axis")
.call(d3.svg.axis().scale(y).ticks(10).orient("left").tickSize(-width, 0, 0));
var path = svg.append("g")
.attr("clip-path", "url(#clip)")
.append("path")
.datum(data)
.attr("class", "arc")
.attr("d", line);
var path2 = svg.append("g")
.attr("clip-path", "url(#clip)")
.append("path")
.datum(data2)
.attr("class", "arc2")
.attr("d", line);
svg.append("text")
.attr("class", "x label")
.attr("text-anchor", "end")
.attr("x", width)
.attr("y", height + 40)
.text("Minutes");
svg.append("text")
.attr("class", "y label")
.attr("text-anchor", "end")
.attr("y", -40)
.attr("dy", ".75em")
.attr("transform", "rotate(-90)")
.text("BOPS / Seconds left on Timer");
var connection = new...