change gitignore and fixes to statistic graphs
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,3 +17,4 @@
|
|||||||
/.idea
|
/.idea
|
||||||
/.vagrant
|
/.vagrant
|
||||||
*.iml
|
*.iml
|
||||||
|
*.DS_Store
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
|
// http://localhost:3333/exercises/38/statistics good for testing
|
||||||
|
// originally at--> localhost:3333/exercises/69/statistics
|
||||||
|
|
||||||
if ($.isController('exercises') && $('.graph-functions').isPresent()) {
|
if ($.isController('exercises') && $('.graph-functions').isPresent()) {
|
||||||
var working_times = $('#data').data('working-time');
|
var working_times = $('#data').data('working-time');
|
||||||
@ -19,23 +21,34 @@ $(function() {
|
|||||||
|
|
||||||
// GET ALL THE DATA ------------------------------------------------------------------------------
|
// GET ALL THE DATA ------------------------------------------------------------------------------
|
||||||
minutes_array = _.map(working_times,function(item){return get_minutes(item)});
|
minutes_array = _.map(working_times,function(item){return get_minutes(item)});
|
||||||
maximum_minutes = _.max(minutes_array);
|
minutes_array_length = minutes_array.length;
|
||||||
var minutes_count = new Array(maximum_minutes + 1);
|
|
||||||
|
|
||||||
for (var i = 0; i < maximum_minutes; i++){
|
maximum_minutes = _.max(minutes_array);
|
||||||
for (var j = 0; j < minutes_array[i]; j++){
|
var minutes_count = new Array(maximum_minutes);
|
||||||
|
|
||||||
|
for (var i = 0; i < minutes_array_length; i++){
|
||||||
|
var studentTime = minutes_array[i];
|
||||||
|
|
||||||
|
for (var j = 0; j < studentTime; j++){
|
||||||
if (minutes_count[j] == undefined){
|
if (minutes_count[j] == undefined){
|
||||||
minutes_count[j] = 1;
|
minutes_count[j] = 0;
|
||||||
} else{
|
} else{
|
||||||
minutes_count[j] += 1;
|
minutes_count[j] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minutes_count[(maximum_minutes + 1)] = 0;
|
// minutes_count[(maximum_minutes + 1)] = 0;
|
||||||
//$('.graph-functions').html("<p></p>")
|
//$('.graph-functions').html("<p></p>")
|
||||||
console.log(minutes_array);
|
|
||||||
|
|
||||||
|
// var minutes_count = new Array(10);
|
||||||
|
// var minutes_array_len = minutes_array.length;
|
||||||
|
// for (var i=0; i< minutes_count; i++){
|
||||||
|
//
|
||||||
|
// for (var j = 0; j < minutes_array_len; j++){
|
||||||
|
// if ()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
function getWidth() {
|
function getWidth() {
|
||||||
if (self.innerHeight) {
|
if (self.innerHeight) {
|
||||||
@ -51,16 +64,11 @@ $(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// DRAW THE LINE GRAPH ------------------------------------------------------------------------------
|
// DRAW THE LINE GRAPH ------------------------------------------------------------------------------
|
||||||
function draw_line_graph() {
|
function draw_line_graph() {
|
||||||
|
|
||||||
// good to test at: localhost:3333/exercises/69/statistics
|
|
||||||
|
|
||||||
var width_ratio = .8;
|
var width_ratio = .8;
|
||||||
var height_ratio = .7; // percent of height
|
var height_ratio = .7; // percent of height
|
||||||
|
|
||||||
|
|
||||||
// currently sets as percentage of window width, however, unfortunately
|
// currently sets as percentage of window width, however, unfortunately
|
||||||
// is not yet responsive
|
// is not yet responsive
|
||||||
|
|
||||||
@ -72,15 +80,12 @@ $(function() {
|
|||||||
|
|
||||||
var x = d3.scale.linear()
|
var x = d3.scale.linear()
|
||||||
.range([0, width]);
|
.range([0, width]);
|
||||||
|
|
||||||
var y = d3.scale.linear()
|
var y = d3.scale.linear()
|
||||||
.range([height, 0]); // - (height/20
|
.range([height, 0]); // - (height/20
|
||||||
|
|
||||||
var xAxis = d3.svg.axis()
|
var xAxis = d3.svg.axis()
|
||||||
.scale(x)
|
.scale(x)
|
||||||
.orient("bottom")
|
.orient("bottom")
|
||||||
.ticks(20);
|
.ticks(20);
|
||||||
|
|
||||||
var yAxis = d3.svg.axis()
|
var yAxis = d3.svg.axis()
|
||||||
.scale(y)
|
.scale(y)
|
||||||
.orient("left")
|
.orient("left")
|
||||||
@ -96,14 +101,12 @@ $(function() {
|
|||||||
return y(d / minutes_count[0] * 100);
|
return y(d / minutes_count[0] * 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var svg = d3.select("#chart_1").append("svg") //PLACEMENT GOES HERE <---------------
|
var svg = d3.select("#chart_1").append("svg") //PLACEMENT GOES HERE <---------------
|
||||||
.attr("width", width + margin.left + margin.right)
|
.attr("width", width + margin.left + margin.right)
|
||||||
.attr("height", height + margin.top + margin.bottom)
|
.attr("height", height + margin.top + margin.bottom)
|
||||||
.append("g")
|
.append("g")
|
||||||
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
||||||
|
|
||||||
|
|
||||||
x.domain(d3.extent(minutes_count, function (d, i) {
|
x.domain(d3.extent(minutes_count, function (d, i) {
|
||||||
return (i);
|
return (i);
|
||||||
}));
|
}));
|
||||||
@ -116,7 +119,6 @@ $(function() {
|
|||||||
.attr("transform", "translate(0," + height + ")")
|
.attr("transform", "translate(0," + height + ")")
|
||||||
.call(xAxis);
|
.call(xAxis);
|
||||||
|
|
||||||
|
|
||||||
svg.append("text")// x axis label
|
svg.append("text")// x axis label
|
||||||
.attr("class", "x axis")
|
.attr("class", "x axis")
|
||||||
.attr("text-anchor", "middle")
|
.attr("text-anchor", "middle")
|
||||||
@ -152,17 +154,17 @@ $(function() {
|
|||||||
.datum(minutes_count)
|
.datum(minutes_count)
|
||||||
.attr("class", "line")
|
.attr("class", "line")
|
||||||
.attr('id', 'myPath')// new
|
.attr('id', 'myPath')// new
|
||||||
.attr("stroke", "black")
|
.attr("stroke", "orange")
|
||||||
.attr("stroke-width", 5)
|
.attr("stroke-width", 5)
|
||||||
.attr("fill", "none")// end new
|
.attr("fill", "none")// end new
|
||||||
.attr("d", line);//---
|
.attr("d", line);//---
|
||||||
//.on("mousemove", mMove)//new again
|
//.on("mousemove", mMove)//new again
|
||||||
//.append("title");
|
//.append("title");
|
||||||
|
|
||||||
function type(d) {
|
// function type(d) {
|
||||||
d.frequency = +d.frequency;
|
// d.frequency = +d.frequency;
|
||||||
return d;
|
// return d;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_line_graph();
|
draw_line_graph();
|
||||||
@ -184,10 +186,7 @@ $(function() {
|
|||||||
// (m[0]*(minutes_count.length/x_width)) +" Minutes");//text(m[1]);
|
// (m[0]*(minutes_count.length/x_width)) +" Minutes");//text(m[1]);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// DRAW THE SECOND GRAPH ------------------------------------------------------------------------------
|
// DRAW THE SECOND GRAPH ------------------------------------------------------------------------------
|
||||||
|
|
||||||
//<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
|
//<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
|
||||||
function draw_bar_graph() {
|
function draw_bar_graph() {
|
||||||
var group_incrament = 5;
|
var group_incrament = 5;
|
||||||
@ -229,7 +228,8 @@ $(function() {
|
|||||||
|
|
||||||
var xAxis = d3.svg.axis()
|
var xAxis = d3.svg.axis()
|
||||||
.scale(x)
|
.scale(x)
|
||||||
.orient("bottom");
|
.orient("bottom")
|
||||||
|
.ticks(10);
|
||||||
|
|
||||||
|
|
||||||
var yAxis = d3.svg.axis()
|
var yAxis = d3.svg.axis()
|
||||||
@ -325,8 +325,7 @@ $(function() {
|
|||||||
.style('text-decoration', 'underline');
|
.style('text-decoration', 'underline');
|
||||||
|
|
||||||
}
|
}
|
||||||
draw_bar_graph()
|
// draw_bar_graph();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -31,8 +31,13 @@ input[type='file'] {
|
|||||||
|
|
||||||
.line {
|
.line {
|
||||||
fill: none;
|
fill: none;
|
||||||
stroke: orange;//steelblue;
|
//stroke: orange;//steelblue;
|
||||||
stroke-width: 4px;
|
stroke-width: 2px;
|
||||||
|
}
|
||||||
|
.line2 {
|
||||||
|
fill: none;
|
||||||
|
//stroke: red;//steelblue;
|
||||||
|
stroke-width: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div#chart_1 {
|
div#chart_1 {
|
||||||
|
@ -32,7 +32,7 @@ h1 = "#{@exercise} (external user #{@external_user})"
|
|||||||
option data-submission=submission
|
option data-submission=submission
|
||||||
=index
|
=index
|
||||||
- index += 1
|
- index += 1
|
||||||
|
- working_times_until = Array.new
|
||||||
#timeline
|
#timeline
|
||||||
.table-responsive
|
.table-responsive
|
||||||
table.table
|
table.table
|
||||||
@ -54,7 +54,11 @@ h1 = "#{@exercise} (external user #{@external_user})"
|
|||||||
- else
|
- else
|
||||||
.unit-test-result.negative-result
|
.unit-test-result.negative-result
|
||||||
td = Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0
|
td = Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0
|
||||||
|
-working_times_until.push((Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0))
|
||||||
p = t('.addendum')
|
p = t('.addendum')
|
||||||
|
.hidden#wtimes data-working_times=ActiveSupport::JSON.encode(working_times_until);
|
||||||
|
div#progress_chart.col-lg-12
|
||||||
|
.graph-functions-2
|
||||||
|
|
||||||
- else
|
- else
|
||||||
p = t('.no_data_available')
|
p = t('.no_data_available')
|
||||||
|
@ -21,11 +21,11 @@ h1 = @exercise
|
|||||||
-working_time_array.push working_time
|
-working_time_array.push working_time
|
||||||
hr
|
hr
|
||||||
.hidden#data data-working-time=ActiveSupport::JSON.encode(working_time_array)
|
.hidden#data data-working-time=ActiveSupport::JSON.encode(working_time_array)
|
||||||
|
.graph-functions
|
||||||
div#chart_1
|
div#chart_1
|
||||||
hr
|
hr
|
||||||
div#chart_2
|
/div#chart_2
|
||||||
hr
|
/hr
|
||||||
.graph-functions
|
|
||||||
.table-responsive
|
.table-responsive
|
||||||
table.table.table-striped.sortable
|
table.table.table-striped.sortable
|
||||||
thead
|
thead
|
||||||
|
Reference in New Issue
Block a user