| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<link rel="stylesheet" type="text/css" href="../css/tests.css"> |
| 5 |
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> |
| 6 |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> |
| 7 |
<script src="../../../dist/js/epoch.js"></script> |
| 8 |
<script src="../js/data.js"></script> |
| 9 |
<link rel="stylesheet" type="text/css" href="../../../dist/css/epoch.css"> |
| 10 |
<style> |
| 11 |
body { background: #333; color: #d0d0d0; } |
| 12 |
a:link, a:visited { color: white; color: white; } |
| 13 |
|
| 14 |
.epoch { |
| 15 |
height: 220px; |
| 16 |
} |
| 17 |
|
| 18 |
#sparkline { height: 50px; } |
| 19 |
|
| 20 |
</style> |
| 21 |
</head> |
| 22 |
<body class="epoch-theme-dark"> |
| 23 |
<h1>Real-time Chart Model / Data Test</h1> |
| 24 |
<p class="breadcrumbs"><a href="../index.html">Epoch Chart Tests</a> » Real-time Chart Model / Data Test</p> |
| 25 |
|
| 26 |
<p><button class="next">Next</button></p> |
| 27 |
|
| 28 |
<div id="gauge" class="epoch gauge-small"></div> |
| 29 |
<div id="sparkline" class="epoch"></div> |
| 30 |
<div id="area" class="epoch"></div> |
| 31 |
<div id="bar" class="epoch"></div> |
| 32 |
|
| 33 |
<script> |
| 34 |
$(function() { |
| 35 |
var rnd = function() { return Math.random(); }; |
| 36 |
|
| 37 |
var data = []; |
| 38 |
for (var j = 0; j < 3; j++) { |
| 39 |
var layer = []; |
| 40 |
for (var i = 0; i < 80; i++) { |
| 41 |
layer.push(rnd()); |
| 42 |
} |
| 43 |
data.push(layer); |
| 44 |
} |
| 45 |
|
| 46 |
// Setup the model |
| 47 |
window.model = new Epoch.Model({ |
| 48 |
dataFormat: { |
| 49 |
name: 'array', |
| 50 |
options: { startTime: (new Date().getTime() / 1000)|0 } |
| 51 |
} |
| 52 |
}); |
| 53 |
model.setData(data); |
| 54 |
|
| 55 |
// Make the charts and associate them with the model |
| 56 |
window.sparkline = $('#sparkline').epoch({ |
| 57 |
type: 'time.line', |
| 58 |
axes: ['left', 'right'], |
| 59 |
model: model |
| 60 |
}); |
| 61 |
|
| 62 |
window.area = $('#area').epoch({ |
| 63 |
type: 'time.area', |
| 64 |
axes: ['left', 'right', 'bottom'], |
| 65 |
model: model |
| 66 |
}); |
| 67 |
|
| 68 |
window.bar = $('#bar').epoch({ |
| 69 |
type: 'time.bar', |
| 70 |
axes: ['left', 'right', 'bottom'], |
| 71 |
model: model |
| 72 |
}); |
| 73 |
|
| 74 |
window.gauge = $('#gauge').epoch({ |
| 75 |
type: 'time.gauge', |
| 76 |
model: model |
| 77 |
}) |
| 78 |
|
| 79 |
$('button.next').click(function(e) { |
| 80 |
model.push([rnd(), rnd(), rnd()]); |
| 81 |
}); |
| 82 |
}) |
| 83 |
</script> |
| 84 |
</body> |
| 85 |
</html> |