Commit cfacbe43 authored by Eduardo L. Buratti's avatar Eduardo L. Buratti

web: Fix data ordering to match db result order

Signed-off-by: Eduardo L. Buratti's avatarEduardo L. Buratti <elb09@c3sl.ufpr.br>
parent 38b9bd0b
package models;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.sql.*;
import play.db.*;
......@@ -14,21 +12,31 @@ import org.codehaus.jackson.*;
public class OS implements java.io.Serializable {
private static final long serialVersionUID = -79175334936007860L;
private Map<String,ArrayList<String[]>> items;
private List<Map<String,Object>> items;
public OS() {
this.items = new HashMap<String,ArrayList<String[]>>();
this.items = new ArrayList<Map<String,Object>>();
}
public void addRow(String os, String date, Long count) {
ArrayList<String[]> list = this.items.get(os);
Map<String, Object> row = null;
if (list == null)
list = new ArrayList<String[]>();
for (Map<String, Object> r : this.items) {
if (r.get("name").equals(os)) {
row = r;
break;
}
}
list.add(new String[] {date, count.toString()});
if (row == null) {
row = new HashMap<String, Object>();
row.put("name", os);
row.put("data", new ArrayList<String[]>());
this.items.add(row);
}
this.items.put(os, list);
List<String[]> list = (List) row.get("data");
list.add(new String[] {date, count.toString()});
}
public JsonNode toJson() {
......
......@@ -185,9 +185,9 @@ var Charts = {
}
var distrosArray = [];
$.each(data, function (key, value) {
var val = parseInt(value[0][1]);
var distro = distros[key];
for (var i = 0; i < data.length; i++) {
var val = parseInt(data[i].data[0][1]);
var distro = distros[data[i].name];
/*if (key === "Linux Educacional 4.0") {
val = 1;
......@@ -198,10 +198,10 @@ var Charts = {
}
distro.category.y += val;
distro.name = key;
distro.name = data[i].name;
distro.y += val;
total += val;
});
};
var les = [],
windows = [],
......@@ -259,23 +259,25 @@ var Charts = {
contentType: "application/json",
data: '{"type": "historical", "project": "'+project+'"}',
success: function(data) {
$.each(data, function (key, value) {
var distro = distros[key];
for (var i = 0; i < data.length; i++) {
var serie = data[i];
var distro = distros[serie.name];
if (typeof distro === 'undefined') {
distro = DEFAULT_DISTRO;
}
for (var i=0; i<value.length; i++) {
value[i][0] = parseInt(value[i][0]);
value[i][1] = parseInt(value[i][1]);
for (var j=0; j < serie.data.length; j++) {
serie.data[j][0] = parseInt(serie.data[j][0]);
serie.data[j][1] = parseInt(serie.data[j][1]);
};
Charts.histChart.addSeries({
name: key,
data: value,
name: serie.name,
data: serie.data,
color: distro.color
}, false);
});
};
Charts.histChart.redraw();
......
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