-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
163 lines (141 loc) · 4.11 KB
/
index.html
File metadata and controls
163 lines (141 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!doctype html>
<title>Linking to SlickGrid</title>
<!-- SlickGrid -->
<link rel="stylesheet" href="lib/slickgrid/slick.grid.css" type="text/css"/>
<link rel="stylesheet" href="lib/slickgrid/jquery-ui-1.8.16.custom.css" type="text/css"/>
<link rel="stylesheet" href="lib/slickgrid/examples.css" type="text/css"/>
<link rel="stylesheet" href="lib/slickgrid/slick.pager.css" type="text/css"/>
<script src="lib/slickgrid/jquery-1.7.min.js"></script>
<script src="lib/slickgrid/jquery.event.drag-2.0.min.js"></script>
<script src="lib/slickgrid/slick.core.js"></script>
<script src="lib/slickgrid/slick.grid.js"></script>
<script src="lib/slickgrid/slick.pager.js"></script>
<script src="lib/slickgrid/slick.dataview.js"></script>
<!-- End SlickGrid -->
<link rel="stylesheet" type="text/css" href="d3.parcoords.css">
<link rel="stylesheet" type="text/css" href="style.css">
<style>
body, html {
margin: 0;
height: 100%;
width: 100%;
overflow: hidden;
font-size: 12px;
}
#grid, #pager {
position: fixed;
width: 100%;
}
#grid {
bottom: 0;
height: 300px;
}
#pager {
bottom: 306px;
height: 20px;
}
.slick-row:hover {
font-weight: bold;
color: #069;
}
</style>
<script src="lib/d3.min.js"></script>
<script src="d3.parcoords.js"></script>
<script src="lib/divgrid.js"></script>
<div id="example" class="parcoords" style="height:240px;"></div>
<div id="grid"></div>
<div id="pager"></div>
<script id="brushing">
var parcoords = d3.parcoords()("#example")
.alpha(0.4)
.mode("queue") // progressive rendering
.height(d3.max([document.body.clientHeight-326, 220]))
.margin({
top: 36,
left: 0,
right: 0,
bottom: 16
});
// load csv file and create the chart
d3.csv('data/df_with_bounds.csv', function(data) {
// slickgrid needs each data element to have an id
data.forEach(function(d,i) { d.id = d.id || i; });
parcoords
.data(data)
// .hideAxis(["name"])
.hideAxis(["id"])
.render()
.reorderable()
.brushMode("1D-axes");
// setting up grid
var column_keys = d3.keys(data[0]);
var columns = column_keys.map(function(key,i) {
return {
id: key,
name: key,
field: key,
sortable: true
}
});
var options = {
enableCellNavigation: true,
enableColumnReorder: false,
multiColumnSort: false
};
var dataView = new Slick.Data.DataView();
var grid = new Slick.Grid("#grid", dataView, columns, options);
var pager = new Slick.Controls.Pager(dataView, grid, $("#pager"));
// wire up model events to drive the grid
dataView.onRowCountChanged.subscribe(function (e, args) {
grid.updateRowCount();
grid.render();
});
dataView.onRowsChanged.subscribe(function (e, args) {
grid.invalidateRows(args.rows);
grid.render();
});
// column sorting
var sortcol = column_keys[0];
var sortdir = 1;
function comparer(a, b) {
var x = a[sortcol], y = b[sortcol];
return (x == y ? 0 : (x > y ? 1 : -1));
}
// click header to sort grid column
grid.onSort.subscribe(function (e, args) {
sortdir = args.sortAsc ? 1 : -1;
sortcol = args.sortCol.field;
if ($.browser.msie && $.browser.version <= 8) {
dataView.fastSort(sortcol, args.sortAsc);
} else {
dataView.sort(comparer, args.sortAsc);
}
});
// highlight row in chart
grid.onMouseEnter.subscribe(function(e,args) {
// Get row number from grid
var grid_row = grid.getCellFromEvent(e).row;
// Get the id of the item referenced in grid_row
var item_id = grid.getDataItem(grid_row).id;
var d = parcoords.brushed() || data;
// Get the element position of the id in the data object
elementPos = d.map(function(x) {return x.id; }).indexOf(item_id);
// Highlight that element in the parallel coordinates graph
parcoords.highlight([d[elementPos]]);
});
grid.onMouseLeave.subscribe(function(e,args) {
parcoords.unhighlight();
});
// fill grid with data
gridUpdate(data);
// update grid on brush
parcoords.on("brush", function(d) {
gridUpdate(d);
});
function gridUpdate(data) {
dataView.beginUpdate();
dataView.setItems(data);
dataView.endUpdate();
};
});
</script>