Commit 0a2fc8ca authored by Piers Williams's avatar Piers Williams

Updated to remember last 3 sets of data

parent 49d4d7a0
Pipeline #878 passed with stages
in 30 seconds
......@@ -82,25 +82,60 @@ function filterRules(query){
});
}
function updateGraph(json){
var data = ["Your Agent"];
$.each(data, function(index, value){
for(var i = 0; i < 26; i++) value.push(0);
function updateData(json){
// Go through and change name of things to be
$.each(allData, function(index, value){
value[0] = "Agent " + (index + 2);
});
var data = ["Current Agent"];
for(var i = 0; i < 26; i++) data.push(0);
var tableItem = {
score:0,moves:0,lives:0
}
$.each(json, function(index, value){
data[0][value.score + 1]+= 1;
data[value.score + 1]+= 1;
tableItem.score += value.score;
tableItem.moves += value.moves;
tableItem.lives += value.lives;
});
allData.push();
tableItem.score /= json.length;
tableItem.moves /= json.length;
tableItem.lives /= json.length;
// Add to front and remove from back
allData.unshift(data);
tableData.unshift(tableItem);
if(allData.length > 3){
allData.pop();
}
if(tableData.length > 3){
tableData.pop();
}
}
function updateGraph(){
$('#graph').effect('highlight');
chart.load({
columns: allData
});
}
function updateTable(){
var tableRows = $("#resultsTable tbody tr");
console.log(tableRows);
$.each(tableData, function(index, value){
tableRows[0].cells[index + 1].innerHTML = value.score;
tableRows[1].cells[index + 1].innerHTML = value.moves;
tableRows[2].cells[index + 1].innerHTML = value.lives;
});
}
function doStuffGraph(){
if(chart == null){
chart = c3.generate({
......@@ -125,11 +160,10 @@ function doStuffGraph(){
}
});
}
//$.getJSON("assets/js/blankGraphData.json", updateGraph);
}
var chart = null;
var allData = [];
var tableData = [];
$(document).ready(function(){loadAndDisplay();doStuffGraph();filterInit();});
......@@ -44,14 +44,13 @@
</ul>
<div id="graph"></div>
<table class="table table-striped">
<table class="table table-striped" id="resultsTable">
<thead>
<tr>
<th></th>
<th>p2</th>
<th>p3</th>
<th>p4</th>
<th>p5</th>
<th>Current Agent</th>
<th>Agent 2</th>
<th>Agent 3</th>
</tr>
</thead>
<tbody>
......@@ -60,21 +59,18 @@
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>Moves</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<th>Lives</th>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</tbody>
......@@ -114,7 +110,7 @@
items: "li:not(.message)",
receive: function(event, ui) {
$('li.message', this).hide();
if($('li:not(.message)', ui.sender).length == 0){
$('li.message', ui.sender).show();
$(ui.sender).addClass('empty');
......@@ -140,11 +136,12 @@
ruleList.push(i.innerHTML);
});
var model = ruleList.join(",");
console.log(model);
$.post("http://hammer.vps.livebytes.co.uk:8000/rule-evaluator-1.0-SNAPSHOT/", model, function(data, textStatus, jqXHR){
console.log("Results", textStatus, data);
updateGraph(data);
updateData(data);
updateGraph();
updateTable();
testPending = false;
$("#testBtn .fa-spinner").css("display", "none");
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment