Improving javascript and Fixing minor curves drawing bug

Everything now is fully "dynamic"
This commit is contained in:
Starow 2014-08-12 14:00:00 +02:00
parent ef6bece82c
commit 8d6c2f4288
2 changed files with 30 additions and 6 deletions

View file

@ -132,19 +132,32 @@ function create_queue_table() {
$(document).ready(function () { $(document).ready(function () {
var data = []; var data = [];
var tmp_tab = [];
var curves_labels = [];
var x = new Date(); var x = new Date();
data.push([x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); for (i = 0; i < glob_tabvar.row1.length; i++){
tmp_tab.push(0);
curves_labels.push(glob_tabvar.row1[i][0]);
}
tmp_tab.unshift(x);
curves_labels.unshift("date");
data.push(tmp_tab);
//data.push([x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
var g = new Dygraph(document.getElementById("Graph"), data, var g = new Dygraph(document.getElementById("Graph"), data,
{ {
labels: curves_labels,
drawPoints: false, drawPoints: false,
showRoller: true, showRoller: true,
rollPeriod: 10, rollPeriod: 10,
labelsKMB: true, labelsKMB: true,
logscale: true, logscale: true,
drawGapEdgePoints: true,
legend: "always",
connectSeparatedPoints: true, connectSeparatedPoints: true,
fillGraph: true, fillGraph: true,
stepPlot: true, //stepPlot: true,
includeZero: true, includeZero: true,
}); });
@ -158,17 +171,17 @@ $(document).ready(function () {
$('#server-name').html(html); $('#server-name').html(html);
setTimeout(function() { setTimeout(function() {
var x = new Date(); var x = new Date();
var youpi = []; var tmp_values = [];
refresh(); refresh();
update_values(); update_values();
create_queue_table(); create_queue_table();
for (i = 0; i < (glob_tabvar.row1).length; i++){ for (i = 0; i < (glob_tabvar.row1).length; i++){
youpi.push(glob_tabvar.row1[i][1]); tmp_values.push(glob_tabvar.row1[i][1]);
} }
youpi.unshift(x); tmp_values.unshift(x);
data.push(youpi); data.push(tmp_values);
if (data.length > 1800) { if (data.length > 1800) {
data.shift(); data.shift();

View file

@ -17,6 +17,17 @@
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery.js') }}"></script> <script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script> <script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
<script>
function update_values() {
$SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
$.getJSON($SCRIPT_ROOT+"/_stuff",
function(data) {
window.glob_tabvar = data;
});
};
update_values();
</script>
</head> </head>
<body> <body>