From 9c5cfdf4df108fcf66d1e1a9bacbb6ef379d6132 Mon Sep 17 00:00:00 2001 From: Nathan Carter Date: Thu, 10 Oct 2019 11:24:30 -0400 Subject: [PATCH] Fixing to obey test file --- anim.js | 47 +++++++++++++++++++------ melt.html | 92 +++++++++++++++++++++++++++--------------------- pivot-table.html | 71 ++++++++++++++++++++++--------------- pivot.html | 52 ++++++++++++++++----------- stack-0.html | 71 ++++++++++++++++++++----------------- stack-1.html | 71 +++++++++++++++++++++---------------- 6 files changed, 239 insertions(+), 165 deletions(-) diff --git a/anim.js b/anim.js index 901597b..48957a0 100644 --- a/anim.js +++ b/anim.js @@ -5,35 +5,60 @@ const w = 75, h = 75; function setColor ( c ) { color = c; } function setReverse ( r ) { reverse = r; update(); } -function addBox ( text, x1, y1, x2, y2 ) { +function addBox ( text, x1, y1, x2, y2, opt ) { + if ( !opt ) opt = { }; + if ( !opt.w1 ) opt.w1 = 1; + if ( !opt.h1 ) opt.h1 = 1; + if ( !opt.w2 ) opt.w2 = 1; + if ( !opt.h2 ) opt.h2 = 1; + if ( !opt.color ) opt.color = color; var box = document.createElement( 'div' ); box.innerHTML = '

' + text + '

'; box.style.display = 'flex'; box.style.border = '1px solid black'; - box.style.width = w; - box.style.height = h; - box.style.background = color; + box.style.width = opt.w1 * w; + box.style.height = opt.h1 * h; + box.style.background = opt.color; main.appendChild( box ); box.style.position = 'absolute'; box.style.left = x1 * w; box.style.top = y1 * h; - box.limits = { x1 : x1 * w, y1 : y1 * h, - x2 : x2 * w, y2 : y2 * h }; + box.limits = { + x1 : x1 * w, + y1 : y1 * h, + x2 : x2 * w, + y2 : y2 * h, + w1 : opt.w1 * w, + h1 : opt.h1 * h, + w2 : opt.w2 * w, + h2 : opt.h2 * h, + }; boxes.push( box ); } function addBoxes () { - for ( var i = 0 ; i < arguments.length ; i += 5 ) - addBox( arguments[i], arguments[i+1], - arguments[i+2], arguments[i+3], arguments[i+4] ); + for ( var i = 0 ; i < arguments.length ; i += 5 ) { + if ( ( i+5 < arguments.length ) + && ( arguments[i+5] instanceof Object ) ) { + addBox( arguments[i], arguments[i+1], + arguments[i+2], arguments[i+3], arguments[i+4], + arguments[i+5] ); + i++; + } else { + addBox( arguments[i], arguments[i+1], + arguments[i+2], arguments[i+3], arguments[i+4] ); + } + } } function update () { boxes.map( box => { var t = slider.value / 100; if ( reverse ) t = 1 - t; - box.style.left = ( 1 - t ) * box.limits.x1 + t * box.limits.x2; - box.style.top = ( 1 - t ) * box.limits.y1 + t * box.limits.y2; + box.style.left = ( 1 - t ) * box.limits.x1 + t * box.limits.x2; + box.style.top = ( 1 - t ) * box.limits.y1 + t * box.limits.y2; + box.style.width = ( 1 - t ) * box.limits.w1 + t * box.limits.w2; + box.style.height = ( 1 - t ) * box.limits.h1 + t * box.limits.h2; } ); } diff --git a/melt.html b/melt.html index 0b202f2..b602b63 100644 --- a/melt.html +++ b/melt.html @@ -4,71 +4,81 @@

Melt

-
pd.melt( df, id_vars=["Last","First"], value_vars=["SAT","ACT","GPA"] )
+
df.melt( id_vars=["First","Last"], value_vars=["SAT","ACT","GPA"] )

diff --git a/pivot-table.html b/pivot-table.html index 78f29b3..2bc4886 100644 --- a/pivot-table.html +++ b/pivot-table.html @@ -4,49 +4,64 @@

Pivot Table

-
df.pivot_table( index="Name", columns="Day", values="Sales", aggfunc="?" )
+
df.pivot_table( index=["First","Last"], columns="Sale", aggfunc="sum" )

diff --git a/pivot.html b/pivot.html index 243f3e1..db3feb8 100644 --- a/pivot.html +++ b/pivot.html @@ -4,36 +4,46 @@ diff --git a/stack-0.html b/stack-0.html index 1342370..e2f7d5e 100644 --- a/stack-0.html +++ b/stack-0.html @@ -4,52 +4,57 @@ diff --git a/stack-1.html b/stack-1.html index 469d381..a49db44 100644 --- a/stack-1.html +++ b/stack-1.html @@ -4,50 +4,59 @@