diff --git a/Rickshaw.Graph.HoverDetail.js b/Rickshaw.Graph.HoverDetail.js new file mode 100644 index 0000000..30b9678 --- /dev/null +++ b/Rickshaw.Graph.HoverDetail.js @@ -0,0 +1,213 @@ +Rickshaw.namespace('Rickshaw.Graph.HoverDetail'); + +Rickshaw.Graph.HoverDetail = Rickshaw.Class.create({ + + initialize: function(args) { + + var graph = this.graph = args.graph; + + this.xFormatter = args.xFormatter || function(x) { + return new Date( x * 1000 ).toUTCString(); + }; + + this.yFormatter = args.yFormatter || function(y) { + return y === null ? y : y.toFixed(2); + }; + + var element = this.element = document.createElement('div'); + element.className = 'detail'; + + this.visible = true; + graph.element.appendChild(element); + + this.lastEvent = null; + this._addListeners(); + + this.onShow = args.onShow; + this.onHide = args.onHide; + this.onRender = args.onRender; + + this.formatter = args.formatter || this.formatter; + + }, + + formatter: function(series, x, y, formattedX, formattedY, d) { + return /*series.name + ': ' + */formattedY; + }, + + update: function(e) { + + e = e || this.lastEvent; + if (!e) return; + this.lastEvent = e; + + if (!e.target.nodeName.match(/^(path|svg|rect)$/)) return; + + var graph = this.graph; + + var eventX = e.offsetX || e.layerX; + var eventY = e.offsetY || e.layerY; + + var j = 0; + var points = []; + var nearestPoint; + + this.graph.series.active().forEach( function(series) { + + var data = this.graph.stackedData[j++]; + + var domainX = graph.x.invert(eventX); + + var domainIndexScale = d3.scale.linear() + .domain([data[0].x, data.slice(-1)[0].x]) + .range([0, data.length]); + + var approximateIndex = Math.floor(domainIndexScale(domainX)); + var dataIndex = Math.min(approximateIndex || 0, data.length - 1); + + for (var i = approximateIndex; i < data.length - 1;) { + + if (!data[i] || !data[i + 1]) break; + if (data[i].x <= domainX && data[i + 1].x > domainX) { dataIndex = i; break } + + if (data[i + 1].x <= domainX) { i++ } else { i-- } + } + + var value = data[dataIndex]; + + var distance = Math.sqrt( + Math.pow(Math.abs(graph.x(value.x) - eventX), 2) + + Math.pow(Math.abs(graph.y(value.y + value.y0) - eventY), 2) + ); + + var xFormatter = series.xFormatter || this.xFormatter; + var yFormatter = series.yFormatter || this.yFormatter; + + var point = { + formattedXValue: xFormatter(value.x), + formattedYValue: yFormatter(value.y), + series: series, + value: value, + distance: distance, + order: j, + name: series.name + }; + + if (!nearestPoint || distance < nearestPoint.distance) { + nearestPoint = point; + } + + points.push(point); + + }, this ); + + + nearestPoint.active = true; + + var domainX = nearestPoint.value.x; + var formattedXValue = nearestPoint.formattedXValue; + + this.element.innerHTML = ''; + this.element.style.left = graph.x(domainX) + 'px'; + + this.visible && this.render( { + points: points, + detail: points, // for backwards compatibility + mouseX: eventX, + mouseY: eventY, + formattedXValue: formattedXValue, + domainX: domainX + } ); + }, + + hide: function() { + this.visible = false; + this.element.classList.add('inactive'); + + if (typeof this.onHide == 'function') { + this.onHide(); + } + }, + + show: function() { + this.visible = true; + this.element.classList.remove('inactive'); + + if (typeof this.onShow == 'function') { + this.onShow(); + } + }, + + render: function(args) { + + var graph = this.graph; + var points = args.points; + var point = points.filter( function(p) { return p.active } ).shift(); + + if (point.value.y === null) return; + + var formattedXValue = this.xFormatter(point.value.x); + var formattedYValue = this.yFormatter(point.value.y); + + this.element.innerHTML = ''; + this.element.style.left = graph.x(point.value.x) + 'px'; + + var xLabel = document.createElement('div'); + + xLabel.className = 'x_label'; + xLabel.innerHTML = formattedXValue; + this.element.appendChild(xLabel); + + var item = document.createElement('div'); + + item.className = 'item'; + item.innerHTML = this.formatter(point.series, point.value.x, point.value.y, formattedXValue, formattedYValue, point); + item.style.top = this.graph.y(point.value.y0 + point.value.y) + 'px'; + + this.element.appendChild(item); + + var dot = document.createElement('div'); + + dot.className = 'dot'; + dot.style.top = item.style.top; + dot.style.borderColor = point.series.color; + + this.element.appendChild(dot); + + if (point.active) { + item.className = 'item active'; + dot.className = 'dot active'; + } + + this.show(); + + if (typeof this.onRender == 'function') { + this.onRender(args); + } + }, + + _addListeners: function() { + + this.graph.element.addEventListener( + 'mousemove', + function(e) { + this.visible = true; + this.update(e) + }.bind(this), + false + ); + + this.graph.onUpdate( function() { this.update() }.bind(this) ); + + this.graph.element.addEventListener( + 'mouseout', + function(e) { + if (e.relatedTarget && !(e.relatedTarget.compareDocumentPosition(this.graph.element) & Node.DOCUMENT_POSITION_CONTAINS)) { + this.hide(); + } + }.bind(this), + false + ); + } +}); + diff --git a/default.css b/default.css index 2a0c2bd..ab1d1ab 100644 --- a/default.css +++ b/default.css @@ -90,10 +90,6 @@ body { * IMAGES *********************************************/ .reveal section img { - margin: 15px 0px; - background: rgb(255, 255, 255); - border: 4px solid #eeeeee; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); -webkit-transition: all .2s linear; -moz-transition: all .2s linear; -ms-transition: all .2s linear; @@ -102,9 +98,9 @@ body { } .reveal a:hover img { - background: rgba(255, 255, 255, 0.2); + /*background: rgba(255, 255, 255, 0.2); border-color: #13daec; - box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); + box-shadow: 0 0 20px rgba(0, 0, 0, 0.55);*/ } /********************************************* diff --git a/detail.css b/detail.css new file mode 100644 index 0000000..722451b --- /dev/null +++ b/detail.css @@ -0,0 +1,73 @@ +.rickshaw_graph .detail { + pointer-events: none; + position: absolute; + top: 0; + z-index: 2; + background: rgba(0, 0, 0, 0.1); + bottom: 0; + width: 1px; + transition: opacity 0.25s linear; + -moz-transition: opacity 0.25s linear; + -o-transition: opacity 0.25s linear; + -webkit-transition: opacity 0.25s linear; +} +.rickshaw_graph .detail.inactive { + opacity: 0; +} +.rickshaw_graph .detail .item.active { + opacity: 1; +} +.rickshaw_graph .detail .x_label { + font-family: Arial, sans-serif; + border-radius: 3px; + padding: 6px; + opacity: 0.5; + border: 1px solid #e0e0e0; + font-size: 12px; + position: absolute; + background: white; + white-space: nowrap; +} +.rickshaw_graph .detail .item { + position: absolute; + z-index: 2; + border-radius: 3px; + padding: 0.25em; + font-size: 12px; + font-family: Arial, sans-serif; + opacity: 0; + background: rgba(0, 0, 0, 0.4); + color: white; + border: 1px solid rgba(0, 0, 0, 0.4); + margin-left: 1em; + margin-top: -1em; + white-space: nowrap; +} +.rickshaw_graph .detail .item.active { + opacity: 1; + background: rgba(0, 0, 0, 0.8); +} +.rickshaw_graph .detail .item:before { + content: "\25c2"; + position: absolute; + left: -0.5em; + color: rgba(0, 0, 0, 0.7); + width: 0; +} +.rickshaw_graph .detail .dot { + width: 4px; + height: 4px; + margin-left: -4px; + margin-top: -3px; + border-radius: 5px; + position: absolute; + box-shadow: 0 0 2px rgba(0, 0, 0, 0.6); + background: white; + border-width: 2px; + border-style: solid; + display: none; + background-clip: padding-box; +} +.rickshaw_graph .detail .dot.active { + display: block; +} diff --git a/index.css b/index.css index edeaff7..22697a3 100644 --- a/index.css +++ b/index.css @@ -18,16 +18,250 @@ background-color: #4B7865; } -#intro-btn { - background-color: #9C646B; +.small-text { + font-size: 0.6em !important; +} + +.dark { + color: #222; +} + +.btn { + box-shadow: 1px 1px 5px black; border: 0; border-radius: 4px; color: #fff; - font-size: 1.5em; padding: 12px; } +#intro-btn { + background-color: #9C646B; + font-size: 1.5em; +} + #intro-btn:hover { background-color: #a66c74; cursor: pointer; } + +.graph-wrapper { + width: 550px; + margin: 0 auto; + text-align:center; +} + +.graph-pictures-xaxis { + width: 100%; +} +.graph-pictures-xaxis div { + width: 104.5px; + margin-right: 5.5px; + margin-top: -7px; + float:left; + background-color: rgba(0,0,0,0.7); + padding-top:6px; + display: inline-block; +} +.graph-pictures-xaxis img { + outline: 2px solid #000; + height: 55px; +} + +.detail { /*styles the on-hover stuff*/ + width: 104.5px; + text-align:center; + padding: 0; + font-size: 0.5em; + position: fixed; + top: 325px; + margin-left: 205px +} + +/*card flip attempt:*/ +.thumb { + display:block; + width:880px; + height:100px; + position:relative; + margin-top: 10px; + margin-bottom:10px; + float:left; +} + +.thumb-wrapper { + display:block; + width:100%; + height:100%; +} + +.thumb .thumb-front { + width:100%; + height:100%; + position:absolute; + display:block; +} + +.thumb .thumb-detail { + display:block; + width:100%; + height:100%; + position:absolute; + background-color: #D1C181; + outline 3px solid black; +} + +.thumb.scroll { + overflow: hidden; +} + +.thumb.scroll .thumb-detail { + bottom: -280px; +} + +.thumb.flip { + perspective:800px; +} + +.thumb.flip .thumb-wrapper { + transition: transform 1s; + transform-style: preserve-3d; +} + +.thumb.flip .thumb-detail { + transform: rotateY(-180deg); +} + +.thumb.flip .thumb-front, .thumb.flip .thumb-detail { + backface-visibility: hidden; +} + +.thumb.flip .flipIt { + transform: rotateY(-180deg); +} + +#user-graph-next-btn { + background-color: #4B7865; + font-size: .7em; +} +#user-graph-next-btn:hover { + background-color: #9CB06C; + cursor: pointer; +} + +#generated-graph-large { + display: inline-block; + /*background:white; + border-left:6px solid white; + border-right: 6px solid white; + border-top: 3px solid white;*/ +} +#generated-graph-large-yaxis { + position:absolute; + top: 0; + bottom: 0; + width: 50px; +} +#generated-graph-label { + position: relative; + top: -15px; + font-size: .6em; +} + +#middle-bar{ + margin-top:30px; + font-size: .8em; + width: 100% +} + +#what-happens-btn { + font-size: .8em; +} + +#what-happens-btn:hover{ + background-color: #9CB06C; + cursor: pointer; +} + +#bottom-graphs-wrapper { + margin-top: 50px; +} +.generated-graph { + display: inline-block; + width: 210px; + height: 120px; + background: rgba(0,0,0,0.8); + line-height:120px; + font-size: 50px; + color: white; +} + +.clear-graph { + background: none; +} + +#final-graph-header { + height: 55px; + font-size: .7em; +} + +#final-graph-header .btn { + margin: 4px; +} + +#final-graph-header input { + font-size: .7em; + margin: 8px; +} + +#value-plot-y { + width: 450px; + position: absolute; + left:-160px; + top: 320px; + font-size: .5em; + -webkit-transform: rotate(-90deg); + -moz-transform: rotate(-90deg); +} +#value-plot { + background: white; + height: 450px; + width: 800px; + margin: 0 auto; + font-size: 400px; + line-height: 450px; + color:black; +} +#loading-gif { + position: absolute; + top: 300px; + left: 450px; + display:none; +} +#value-plot-x { + width:800px; + text-align:center; + margin: 0 auto; + font-size: .6em; +} +.left { + float: left; +} +.right { + float: right; +} + +#people-select-wrapper { + display: inline-block; +} + +#people-select-wrapper select { + display: inline-block; + padding: 3px; + font-size: .8em; + width: 120px; + outline: none; + color: black; + border: none; + border-radius: 5px; + background-color: #fff; +} diff --git a/index.html b/index.html index 3bf146a..3488670 100644 --- a/index.html +++ b/index.html @@ -4,10 +4,13 @@ Central Limit Theorem + + + @@ -26,7 +29,7 @@

Central Limit Theorem


- + @@ -80,10 +83,6 @@

foundational knowledge

-<<<<<<< HEAD -
- Single Horizontal Slide -=======

Central Limit Theorem

@@ -110,34 +109,67 @@

Central Limit Theorem

->>>>>>> 0c69a5b2018f0710d906d9d8ea0e5683acfdec9d
-

What do those ratings mean?

+
What do those ratings mean?
- -
-
- -
-
- + +
+ +
+ +
+ +
+
-
- +
+
+
+
+
+
+

These ratings follow a random distribution - every person who rates the cats will have different opinions, but some cats are more likely to get a higher rating than others. These factors mean the adoption times will not conform to a normal distribution

-
- +
+

If we have way more people rate way more cats, the average adoption times will conform to a normal distribution!

+
+
+ +
+
+
+
+
+
+
+
This dude rated 50 cats - check out the results. They are just as random as yours.
-

These ratings follow a random distribution - every person who rates the cats will have different opinions. Even so, the probability of getting a 10 for each cat is not equal; some cats are more likely to get a higher rating than others. The ratings will not conform to a normal distribution

- +
What Happens
+
+
?
+
?
+
?
+
?
+
+
+
+
+
+
+ Plot the average for
people rating: +
+
Number of Times An Average Occurs
+
?
+ +
0Average Time Until Adoption5
diff --git a/index.js b/index.js index 284556e..2ae530b 100644 --- a/index.js +++ b/index.js @@ -1,28 +1,3 @@ -(function() { - var lastTime = 0; - var vendors = ['webkit', 'moz']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = - window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if (!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; -}()); - $(function() { Reveal.initialize({ width: 960, @@ -41,6 +16,13 @@ $(function() { transition: 'default' // default/cube/page/concave/zoom/linear/fade/none }); + function getNumbers(l){ + var array = []; + while(l--){ + array.push( { x: l, y: Math.floor((Math.random()*5)+1)} ); + } + return(array); + } $('#intro-btn').click(function() { var currentStep = $(this).data('step'); if(currentStep === 1) { @@ -54,145 +36,171 @@ $(function() { $(this).data('step', 1); } }); - var data = [ { x: 0, y: 3 },{ x: 1, y: 9 },{ x: 2, y: 7 },{ x: 3, y: 1 },{ x: 4, y: 6 }]; - - // Setup the Dice canvas - (function() { - var diceCanvas = document.getElementById('dice-canvas'); - var g = diceCanvas.getContext('2d'); - var graph = [0, 0, 0, 0, 0, 0]; - var diceRolling = false; - var diceAlpha = 0; - var diceValue = 0; - - var sampleSum = 0; - var sampleSize = 0; - - var BARWIDTH = 45; - var CANVAS_WIDTH = 274; - var CANVAS_HEIGHT = 197; - var DICE_WIDTH = 64; - var DICE_HEIGHT = 64; - var DICE_SWITCH_TIME = 2000; - var DICE_SWITCH_TIME_MAX = 1000; - - var updateDiceStat = function() { - var text = 'Your sample mean is ' + Math.round((sampleSum / sampleSize) * 100) / 100 + ' and your sample size is ' + sampleSize + '.'; - $('#dice-stat').text(text); - } - var drawDice = function(num) { - var centerX = Math.floor( CANVAS_WIDTH / 2 ) - Math.floor( DICE_WIDTH / 2 ); - var centerY = Math.floor( CANVAS_HEIGHT / 2 ) - Math.floor( DICE_HEIGHT / 2 ); - var HOLESIZE = 14; - var PADDING = 2; + if ($('html').hasClass('csstransforms3d')) { + // if it's supported, remove the scroll effect add the cool card flipping instead + $('.thumb').removeClass('scroll').addClass('flip'); - g.strokeStyle = 'black'; - g.fillStyle = '#fff'; - - g.fillRect(centerX, centerY, DICE_WIDTH, DICE_HEIGHT); - g.strokeRect(centerX, centerY, DICE_WIDTH, DICE_HEIGHT); - - centerX = centerX + Math.floor(DICE_WIDTH/2) - Math.floor(HOLESIZE/2); - centerY = centerY + Math.floor(DICE_HEIGHT/2) - Math.floor(HOLESIZE/2); - - g.fillStyle = 'rgba(0, 0, 0, ' + diceAlpha + ')' - if(num === 1) { - g.fillRect(centerX, centerY, HOLESIZE, HOLESIZE); - } - else if(num === 2) { - g.fillRect(centerX - HOLESIZE - PADDING, centerY - HOLESIZE - PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX + HOLESIZE + PADDING, centerY + HOLESIZE + PADDING, HOLESIZE, HOLESIZE); - } - else if(num === 3) { - g.fillRect(centerX, centerY, HOLESIZE, HOLESIZE); - g.fillRect(centerX - HOLESIZE - PADDING, centerY - HOLESIZE - PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX + HOLESIZE + PADDING, centerY + HOLESIZE + PADDING, HOLESIZE, HOLESIZE); + // add/remove flip class that make the transition effect + $('#user-graph-next-btn').click( + function () { + $('.thumb-wrapper').addClass('flipIt'); } - else if(num === 4) { - g.fillRect(centerX - HOLESIZE - PADDING, centerY - HOLESIZE - PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX - HOLESIZE - PADDING, centerY + HOLESIZE + PADDING, HOLESIZE, HOLESIZE); + ); - g.fillRect(centerX + HOLESIZE + PADDING, centerY - HOLESIZE - PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX + HOLESIZE + PADDING, centerY + HOLESIZE + PADDING, HOLESIZE, HOLESIZE); + } else { + // CSS 3D is not supported, use the scroll up effect instead + $('#user-graph-next-btn').click( function () { + $('.thumb-detail').stop().animate({bottom:0}, 500); + $(this).val("Show me"); + $(this).off('click').click( function() { + Reveal.next(); + }); + }); + } + $("#what-happens-btn").click( function(){ + var graphs = []; + $('.generated-graph').addClass('clear-graph').html(''); + graphs = rollGraphs(); + $(this).val('with a different 5?').off('click').click(function() { + graphs = rollGraphs(); + $('#middle-bar-text').html("See how random the results are? "); + $(this).val('Try one last time').off('click').click(function(){ + graphs = rollGraphs(); + $('#middle-bar-text').html("What happens "); + $(this).val('if we average the ratings?').off('click').click(function(){ + $(this).val('if a lot of people rate the cats?').off('click').click(function(){ + Reveal.next(); + }); + $('.generated-graph').removeClass('clear-graph').html(''); + var l = graphs.length; + for (var i = 1; i <= l; i++){ + var data = graphs[i-1].series[0].data; + var sum = 0; + for (var j = 0; j < data.length; j++){ + sum += data[j].y; + } + $("#generated-graph-" + i).html(sum/data.length); + } + }); + }); + }); + }); + function rollGraphs(){ + var graphs = []; + graphs.push(generateSmallGraph(1)); + graphs.push(generateSmallGraph(2)); + graphs.push(generateSmallGraph(3)); + graphs.push(generateSmallGraph(4)); + return graphs; + /* + setTimeout(function() { generateSmallGraph(2); }, 200); + setTimeout(function() { generateSmallGraph(3); }, 400); + setTimeout(function() { generateSmallGraph(4); }, 600); + */ + } + $("#five-cats").click( function() { $("#value-plot").html(''); $('#loading-gif').show(); setTimeout(function(){ generateNormalGraph(5)}, 0) }); + $("#ten-cats").click( function() { $("#value-plot").html(''); $('#loading-gif').show(); setTimeout(function(){ generateNormalGraph(10)}, 0) }); + $("#fifteen-cats").click( function() { $("#value-plot").html(''); $('#loading-gif').show(); setTimeout(function(){ generateNormalGraph(15)}, 0) }); + $("#thirty-cats").click( function() { $("#value-plot").html(''); $('#loading-gif').show(); setTimeout(function(){ generateNormalGraph(30)}, 0) }); + function generateNormalGraph(cats){ + var averageOccurences = []; + for (var i = 0; i < $("#number-of-people").val(); i++){ + var sum = 0; + for (var j = 0; j < cats; j++){ + sum += Math.floor((Math.random()*5)+1); } - else if(num === 5) { - g.fillRect(centerX, centerY, HOLESIZE, HOLESIZE); - g.fillRect(centerX - HOLESIZE - PADDING, centerY - HOLESIZE - PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX + HOLESIZE + PADDING, centerY + HOLESIZE + PADDING, HOLESIZE, HOLESIZE); - - g.fillRect(centerX - HOLESIZE - PADDING, centerY + HOLESIZE + PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX + HOLESIZE + PADDING, centerY - HOLESIZE - PADDING, HOLESIZE, HOLESIZE); + sum /= cats; + sum = sum.toFixed(5); + if (averageOccurences[sum]){ + averageOccurences[sum] += 1; } - else if(num === 6) { - g.fillRect(centerX - HOLESIZE - PADDING, centerY - HOLESIZE - PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX - HOLESIZE - PADDING, centerY + HOLESIZE + PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX + HOLESIZE + PADDING, centerY - HOLESIZE - PADDING, HOLESIZE, HOLESIZE); - g.fillRect(centerX + HOLESIZE + PADDING, centerY + HOLESIZE + PADDING, HOLESIZE, HOLESIZE); - - g.fillRect(centerX + HOLESIZE + PADDING, centerY, HOLESIZE, HOLESIZE); - g.fillRect(centerX - HOLESIZE - PADDING, centerY, HOLESIZE, HOLESIZE); + else{ + averageOccurences[sum] = 1; } } - - var render = function() { - g.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); - g.fillStyle = 'black'; - // Draw the X-axis graph - for(var i = 0; i < 6; i++) { - g.strokeStyle = 'white' - g.fillRect(i * BARWIDTH, (CANVAS_HEIGHT - graph[i] * 10) - 22, BARWIDTH, graph[i] * 10); - g.strokeRect(i * BARWIDTH, (CANVAS_HEIGHT - graph[i] * 10) - 22, BARWIDTH, graph[i] * 10); - g.font = '11px Arial'; - g.strokeStyle = 'black'; - g.strokeText((i + 1).toString(), 22 + i * BARWIDTH, CANVAS_HEIGHT - 11); - } - - if(diceRolling) { - diceAlpha -= 0.05; - drawDice(diceValue); - - if(diceAlpha < 0) { - diceRolling = false; - graph[diceValue-1]++; - sampleSize++; - sampleSum += diceValue; - updateDiceStat(); - } - } + var newarray = []; //HACKISH AS FUCK I HATE THIS CODE + for(var key in averageOccurences){ + newarray.push({'x': parseFloat(key), 'y': averageOccurences[key]}); } + var normalGraph = new Rickshaw.Graph( { + element: document.querySelector('#value-plot'), + renderer: 'bar', + series: [ + { + color: "#000", + data: newarray.sort(function(a, b){ + if (a.x < b.x) return -1; + if (a.x > b.x) return 1; + return 0; + }) + }] + }); + $("#loading-gif").hide(); + normalGraph.render(); + } - var animate = function() { - requestAnimationFrame(animate); - render(); - } + function swag (a) { + return a; + } - $('#roll-dice').click(function() { - if( diceRolling === false ) { - diceRolling = true; - diceAlpha = 1; - diceValue = Math.floor(Math.random() * 6) + 1; + + function generateSmallGraph(x) { + $('#generated-graph-' + x).html(''); + var generated = new Rickshaw.Graph( { + element: document.querySelector("#generated-graph-" + x), + renderer: 'bar', + series: [ + { + color: "#000", + data: getNumbers(50), + name: 'Time' } + ] }); + generated.render(); + return generated; + } + var generatedGraphLarge = new Rickshaw.Graph( { + element: document.querySelector('#generated-graph-large'), + width: 800, + height: 200, + renderer: 'bar', + series: [ + { + color: '#4b7865', + data: getNumbers(50), + name: 'Time' + } + ] + }); + //TODO: implement the fuckin axis marker` + /*var generatedGraphLargeYaxis = new Rickshaw.Graph.Axis.Y( { + element: document.getElementById('#generated-graph-large-yaxis'), + graph: generatedGraphLarge, + orientation: 'left', + tickFormat: Rickshaw.Fixtures.Number.formatKBMT, + });*/ + generatedGraphLarge.render(); + $('#roll-dice').click(function() { - // Start the canvas code - animate(); - })(); + }); $('#formula-box').keyup(function() { var content = $(this).val(); var splitNum = content.split(' '); - if($.trim(content) === '') { - content = '0'; - splitNum = content.split(' '); - } + + console.log(content); var numberArray = []; for(var i = 0; i < splitNum.length; i++) { if( splitNum[i] !== '' ) { try { numberArray.push( parseInt(splitNum[i], 10) ); - } catch(err) {} + + } + catch(err) { + } } } @@ -222,13 +230,31 @@ $(function() { $('.panel-two').hide(); // Hide this at the start $('.rate-button').click(function() { var rating = $(this).val(); - catGameArray.push(rating); + catGameArray.push({ x: catGameCounter - 1, y: parseFloat(rating) }); catGameCounter++; - $('.cat-image-container img').attr('src', './cats/cat' + catGameCounter + '.jpg'); - $('.cat-image-container img').hide().fadeIn(); if(catGameArray.length === 5) { Reveal.next(); + var userDataGraph = new Rickshaw.Graph( { + element: document.querySelector('#user-ratings-graph'), + renderer: 'bar', + series: [ + { + color: "#9c646b", + data: catGameArray, + name: 'Time' + } + ] + } ); + var hoverDetail = new Rickshaw.Graph.HoverDetail( { + graph: userDataGraph, + xFormatter: function(x) { return null }, + yFormatter: function(y) { return Math.floor(y) + " months" } + } ); + userDataGraph.render(); + return; } + $('.cat-image-container img').attr('src', './cats/cat' + catGameCounter + '.jpg'); + $('.cat-image-container img').hide().fadeIn(); }); }); diff --git a/loadingspinner.gif b/loadingspinner.gif new file mode 100644 index 0000000..031c908 Binary files /dev/null and b/loadingspinner.gif differ