Skip to content

Commit 3d7fcc6

Browse files
committed
Fixed cell background color generation in table view.
Signed-off-by: Mark Nelson <[email protected]>
1 parent 537bac6 commit 3d7fcc6

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

include/css/table.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#view > tbody div {
2-
height:50;
2+
/* height:50; */
33
}
44

55
th {
6-
background-color:black;
6+
background-color:blue;
77
color:white
88
}
99

1010
td {
11-
border: 1px solid black;
11+
border: 1px solid lightgrey;
1212
background-color:#ccc;
1313
width:200px;
1414
}

include/js/table.js

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
var keys = d3.keys(dataSet[0]);
22

3+
var mins = {}
4+
var maxes = {}
5+
dataSet.forEach(function(item) {
6+
var mean = d3.mean(d3.values(item).slice(3));
7+
var deviation = d3.deviation(d3.values(item).slice(3));
8+
var minmax_key = d3.values(item).slice(0,3).join("");
9+
// console.log(minmax_key);
10+
mins[minmax_key] = mean-deviation;
11+
maxes[minmax_key] = mean+deviation;
12+
});
13+
//console.log(mins);
14+
//console.log(maxes);
15+
316
var thead = d3.select("#view > thead")
417
var th = thead.selectAll("th")
518
.data(keys)
@@ -15,15 +28,27 @@ var tr = tbody.selectAll("tr")
1528
.append('tr')
1629
.selectAll('td')
1730
.data(function (row) {
18-
return d3.entries(row);
19-
})
31+
key = d3.values(row).slice(0,3).join("")
32+
dataArray = d3.entries(row);
33+
dataArray.forEach(function(data) {
34+
data["min"] = mins[key];
35+
data["max"] = maxes[key];
36+
});
37+
// console.log(dataArray);
38+
return dataArray;
39+
40+
})
2041
.enter()
2142
.append('td')
2243
.append('div')
2344
.style({
2445
"background-color": function(d, i){
2546
if(i < 3) return "lightblue";
26-
return makecolor(d.value, 20, 181);
47+
console.log(d);
48+
if (d.min === 0 && d.max === 0) {
49+
return "lightgrey";
50+
}
51+
return makecolor(d.value, d.min, d.max);
2752
},
2853
})
2954
.text(function(d){

parsing/test.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ def getbw(s):
7979
html.add_html(html.read_file('/home/nhm/src/ceph-tools/cbt/include/html/table.html'))
8080
html.add_style(html.read_file('/home/nhm/src/ceph-tools/cbt/include/css/table.css'))
8181
html.add_script(html.read_file('/home/nhm/src/ceph-tools/cbt/include/js/jsxcompressor.min.js'))
82-
html.add_encoded_script(html.read_file('/home/nhm/src/ceph-tools/cbt/include/js/d3.ugly.js'))
83-
html.add_encoded_script(html.format_data(database.fetch_table(['opsize', 'testtype'])))
84-
html.add_encoded_script(html.read_file('/home/nhm/src/ceph-tools/cbt/include/js/table.js'))
82+
html.add_script(html.read_file('/home/nhm/src/ceph-tools/cbt/include/js/d3.js'))
83+
html.add_script(html.read_file('/home/nhm/src/ceph-tools/cbt/include/js/d3var.js'))
84+
html.add_script(html.format_data(database.fetch_table(['opsize', 'testtype'])))
85+
html.add_script(html.read_file('/home/nhm/src/ceph-tools/cbt/include/js/table.js'))
8586

8687
print '<meta charset="utf-8">'
8788
print '<title>D3 Table Test </title>'

0 commit comments

Comments
 (0)