Download this file

compare.html    349 lines (292 with data), 11.8 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<!DOCTYPE html>
<html>
<head>
<title>OSSMETER</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,300italic|Open+Sans:300italic,400italic,400,300' rel='stylesheet' type='text/css'>
<link href="http://fonts.googleapis.com/css?family=Bree+Serif" rel="stylesheet" type="text/css">
<link href="stylesheets/bootstrap.min.css" type="text/css" rel="stylesheet"/>
<link href="stylesheets/nav.css" type="text/css" rel="stylesheet"/>
<link href="stylesheets/styles.css" type="text/css" rel="stylesheet"/>
<link href="stylesheets/plots.css" type="text/css" rel="stylesheet"/>
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" media="screen">
<link rel="icon" type="image/png" href="images/favicon.png">
<script src="javascripts/jquery-1.9.1.js"></script>
<script src="javascripts/bootstrap.min.js"></script>
<script src="javascripts/knockout-2.3.0.js"></script>
<script src="javascripts/d3.v3.min.js"></script>
<script src="javascripts/dimple.v1.1.1.min.js"></script>
<script type="text/javascript">
$(function(){
$("#nav").load("nav.html");
$("#footer").load("footer.html");
$.ajaxSetup({
async: true
});
$("a").tooltip({
'selector': '',
'placement': 'bottom'
});
});
</script>
</head>
<body>
<nav id="nav"></nav>
<div class="inner">
<section class="row">
<div class="span12">
<h1>Compare Projects</h1>
<p>The OSSMETER platform will allow you to discover projects that meet your desired goals, and then compare them on the metrics that are most important to you. Perhaps one potential project that you might adopt is slow at fixing bugs, whereas an alternative project has an active community, who respond quickly to forum questions and fix bugs fast.</p>
<p>The table and plots below illustrate the kind of comparison that will be possible with the OSSMETER platform. Click on the metric names to display the metric for each project in the large plot.</p>
<p class="text-warning"><strong>Please note:</strong> This is a demo web application. The page may load slowly and you may encounter some unexpected bugs. Please report them to us at <a href="mailto:ossmeter@gmail.com">ossmeter@gmail.com</a> or <a href="https://www.twitter.com/ossmeter">@ossmeter</a>. </p>
</div>
</section>
<section>
<div class="row well">
<h4 id="plotTitle"></h4>
<p id="metricDescription"></p>
<div class="span12 lplot">
<div id="compPlot">
<p>Select two projects using the drop-down menus</p>
<p>Click the Compare button</p>
<p>Click the name of a metric to display the data here</p>
</div>
</div>
</div>
<div class="row">
<div class="span5">
<select id="p-select-1"></select>
</div>
<div class="span2">
<button id="compare-button" type="button" class="btn btn-default">Compare</button>
</div>
<div class="span5">
<select id="p-select-2"></select>
</div>
</div>
<table id="comp" class="table">
<tbody data-bind="foreach: metrics">
<tr>
<td><p data-bind="text: $data.niceName" style="cursor:pointer"></p></td>
<!-- ko foreach: $parent.projects --> <!-- vm.projects -->
<td >
<span data-bind="sparkplot: { project: $data, metric: $parent} " class="spark"></span>
</td>
<!-- /ko -->
</tr>
</tbody>
</table>
</section>
<script src="javascripts/ossplots.js"></script>
<script src="javascripts/eclipse-projects.js"></script>
<script type="text/javascript">
$.each(Projects, function (key, value) {
$("#p-select-1").append($("<option></option>")
.attr("value",value.shortName)
.text(value.name));
$("#p-select-2").append($("<option></option>")
.attr("value",value.shortName)
.text(value.name));
$("#p-select-1 option:eq(7)").prop("selected", true);
$("#p-select-2 option:eq(4)").prop("selected", true);
});
$("#compare-button").click(function() {
if (vm.metrics().length === 0) {
for (m in Metrics) {
vm.addMetric(Metrics[m]);
}
}
vm.clearProjects();
vm.addProject({"id" : $("#p-select-1 :selected").val(), "name" : $("#p-select-1 :selected").text()});
vm.addProject({"id" : $("#p-select-2 :selected").val(), "name" : $("#p-select-2 :selected").text()});
// vm.addProject({"id" : "emf", "name" : "EMF"}); // Easy to add more projects
});
/*
Script to add column/row highlighting
*/
function addInteractivityToCompTable() {
$('table#comp td:first-child').off('click'); // Remove any existing events
$('table#comp td:first-child').click(function() {
$('table#comp tr').removeClass("selected");
var t = parseInt($(this).closest("tr").index()) + 1;
$(this).closest("t").addClass("selected");
$('table#comp tr:nth-child('+t+')').addClass("selected");
plotMetric(t);
});
}
// Column index starts from 1
function plotMetric(index){
var metricId = vm.metrics()[index-1].id;
var toPlot = {};
toPlot.metricName = vm.metrics()[index-1].niceName;
toPlot.metricDescription = vm.metrics()[index-1].desc;
toPlot.metricGuide = vm.metrics()[index-1].guide;
toPlot["data"] = new Array();
$.each(vm.projects(), function(i, project) {
$.each(project.metricsData, function(j, metric) {
if (metric.id === metricId) {
$.map(metric.datatable, function(m, k) {
m["Project"] = project.name;
});
toPlot.vertical = metric.vertical;
toPlot.xtext = metric.xtext;
toPlot.ytext = metric.ytext;
toPlot.type = metric.type;
toPlot.orderRule = metric.orderRule;
toPlot.isTimeSeries = metric.isTimeSeries;
toPlot.containsSeries = false;
if (metric.datatable[0]["Series"] != undefined) {
toPlot.containsSeries = true;
}
toPlot.data = toPlot.data.concat(metric.datatable);
}
});
});
plot(toPlot);
}
function plot(data) {
$("#compPlot").html("");
var svg = dimple.newSvg("#compPlot", "100%", "100%");
var chart = new dimple.chart(svg, data.data);
chart.setBounds(60,20,800,230);
if (data.vertical) {
var x = chart.addMeasureAxis("x", data.xtext);
var y = chart.addCategoryAxis("y", [data.ytext,"Project", "Series"]);
if (data.isTimeSeries) {
y.timeField = data.ytext;
y.dateParseFormat = "%Y%m%d";
y.tickFormat = "%b %Y"
}
y.addOrderRule(data.orderRule);
} else {
var x = chart.addCategoryAxis("x", [data.xtext,"Project", "Series"]);
if (data.isTimeSeries) {
x.timeField = data.xtext;
x.dateParseFormat = "%Y%m%d";
x.tickFormat = "%b %Y"
}
x.addOrderRule(data.orderRule);
var y = chart.addMeasureAxis("y", data.ytext);
}
var series = ["Project"];
if (data.containsSeries) {
series.unshift("Series");
}
var ser = chart.addSeries(series, dimple.plot[data.type]);
// chart.defaultColors = [
// new dimple.color("#d53e4f"),
// new dimple.color("#f46d43"),
// new dimple.color("#fdae61"),
// new dimple.color("#fee08b"),
// new dimple.color("#ffffbf"),
// new dimple.color("#e6f598"),
// new dimple.color("#abdda4"),
// new dimple.color("#66c2a5"),
// new dimple.color("#3288bd")
// ];
chart.addLegend(60, 5, 680, 10, "right");
chart.draw(500);
x.shapes.selectAll("path, line").style("stroke", "#A0A0A0");
x.shapes.selectAll("text").style("fill", "#A0A0A0");
y.shapes.selectAll("path, line").style("stroke", "#A0A0A0");
y.shapes.selectAll("text").style("fill", "#A0A0A0");
y.titleShape.style("fill", "#A0A0A0");
x.titleShape.style("fill", "#A0A0A0");
$("#plotTitle").text(data.metricName);
$("#metricDescription").text(data.metricDescription);
$('html, body').animate({
scrollTop: $("#plotTitle").offset().top - 50
}, 200);
}
</script>
<script type="text/javascript">
function load() {
ko.bindingHandlers.sparkplot = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
$(element).html("<img src=\"images/loading.gif\"/>");
},
update: function(element, valueAccessor, allBindingsAccessor) {
$(element).html("<img src=\"images/loading.gif\"/>");
// First get the latest data that we're bound to
var value = valueAccessor(), allBindings = allBindingsAccessor();
// Extract info
var project = value.project;
var metric = value.metric;
var url = "data/" + project.id + "/" + metric.id + ".json";
$.get(url, function(data) {
$(element).html("");// Clear
if (!('metricsData' in project)) {
project.metricsData = new Array();
project.findMetricById = function(metricId) {
var self = this;
for (m in self.metricsData){
if (self.metricsData[m].id === metricId) {
return self.metricsData[m];
}
}
return -1;
};
}
if(typeof data != 'object') {
data = JSON.parse(data);
}
// console.log("data ("+project.id+","+metric.id+"): " + data.datatable.length);
if (project.findMetricById(metric.id) === -1) {
project.metricsData.push(data);
}
var svg = dimple.newSvg(element, 200, 30);
var chart = new dimple.chart(svg, data.datatable);
if (data.vertical) {
var x = chart.addMeasureAxis("x", data.xtext);
x.hidden=true;
var y = chart.addCategoryAxis("y", data.ytext);
y.addOrderRule(data.orderRule);
if (data.type === "line") { // hide for line charts
y.hidden = true;
}
} else {
var x = chart.addAxis("x", data.xtext);
x.addOrderRule(data.orderRule);
if (data.type === "line") { // hide for line charts
x.hidden = true;
}
chart.addMeasureAxis("y", data.ytext).hidden=true;
}
var ser = chart.addSeries(data.series, dimple.plot[data.type]);
chart.draw();
if (data.type === "bar") { // color for bars
x.shapes.selectAll("path, line").style("stroke", "#A0A0A0");
}
}).fail(function(jqXHR, textStatus, errorThrown ){
console.log("Failed to retrieve " + project.shortName + ":" + metric.id);
console.log("\t" + textStatus);
console.log("\t" + errorThrown);
});
}
};
var ComparisonViewModel = function() {
var self = this;
self.projects = ko.observableArray();
self.metrics = ko.observableArray();
self.plotMetrics = ko.observableArray();
self.addProject = function(project) {
self.projects.push(project);
addInteractivityToCompTable();
};
self.addMetric = function(metric) {
self.metrics.push(metric);
addInteractivityToCompTable();
};
self.clearProjects = function() {
self.projects([]);
}
}
vm = new ComparisonViewModel();
ko.applyBindings(vm);
}
load();
addInteractivityToCompTable();
</script>
</div>
<footer id="footer"></footer>
</body>
</html>