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