Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript" language="javascript">
  2. /* Sizing and scales. */
  3. var data = [[6,5.8965517241379],[6,6.625],[4,6.0384615384615],[2,3.7272727272727]],
  4.     cuentos = ['La araña hambrienta y la tortuga','Conociendo a las arañas','Pájaro Cu','Los Aztecas'],
  5.     w = 600,
  6.     h = 250,
  7.     n = 2,
  8.     m = data.length,
  9.     y = pv.Scale.linear(0, 10).range(0, h),
  10.     x = pv.Scale.ordinal(pv.range(m)).splitBanded(0, w, 4/5);
  11.  
  12. /* The root panel. */
  13. var vis = new pv.Panel()
  14.     .width(w)
  15.     .height(h)
  16.     .bottom(100)
  17.     .left(20)
  18.     .right(100)
  19.     .top(60);
  20.  
  21. vis.anchor("center").add(pv.Label)
  22.     .top(-20)
  23.     .font("20px sans-serif")
  24.     .text("How are you in comprehension?");
  25.  
  26. /* The bars. */
  27. var bar = vis.add(pv.Panel)
  28.     .data(data)
  29.     .left(function() x(this.index))
  30.     .width(x.range().band)
  31.   .add(pv.Bar)
  32.     .data(function(d) d)
  33.     .left(function() this.index * x.range().band/n)
  34.     .width(x.range().band / n)
  35.     .bottom(0)
  36.     .height(y)
  37.     .fillStyle(pv.Colors.category20().by(pv.index));
  38.  
  39. /* The value label. */
  40. bar.anchor("top").add(pv.Label)
  41.     .textStyle("white")
  42.     .text(function(d) d.toFixed(1));
  43.  
  44. /* The variable label. */
  45. bar.parent.anchor("bottom").add(pv.Label)
  46.     .textAlign("left")
  47.     //.textMargin(5)
  48.     .textBaseline("top")
  49.     .textAngle(3*Math.PI/2)
  50.     .text(function() cuentos[this.parent.index]);
  51.  
  52. /* X-axis ticks. */
  53. vis.add(pv.Rule)
  54.     .data(y.ticks(10))
  55.     .bottom(y)
  56.     .strokeStyle(function(d) d ? "rgba(127,127,127,0.3)" : "#000")
  57.   .add(pv.Rule)
  58.     .left(0)
  59.     .width(5)
  60.     .strokeStyle("#000")
  61.   .anchor("left").add(pv.Label)
  62.     .text(y.tickFormat);
  63.  
  64. vis.add(pv.Dot)
  65.     .data(["Tu","Tus compañeros"])
  66.     .right(-10)
  67.     .size(8)
  68.     .strokeStyle(null)
  69.     .top(function () 100 + this.index * 20)
  70.     .fillStyle(pv.Colors.category20().by(pv.index))
  71.   .anchor("right").add(pv.Label);
  72.  
  73. var data_voc = [[13,11.793103448276],[11,11.25],[11,9.6153846153846],[3,7.8888888888889]],
  74.     cuentos = ['La araña hambrienta y la tortuga','Conociendo a las arañas','Pájaro Cu','Los Aztecas'],
  75.     w = 600,
  76.     h = 250,
  77.     n = 2,
  78.     m = data_voc.length,
  79.     y = pv.Scale.linear(0, 15).range(0, h),
  80.     x = pv.Scale.ordinal(pv.range(m)).splitBanded(0, w, 4/5);
  81.  
  82. /* The root panel. */
  83. var vis_2 = new pv.Panel()
  84.     .width(w)
  85.     .height(h)
  86.     .bottom(100)
  87.     .left(20)
  88.     .right(100)
  89.     .top(60);
  90.  
  91. vis_2.anchor("center").add(pv.Label)
  92.     .top(-20)
  93.     .font("20px sans-serif")
  94.     .text("How are you in your vocabulary?");
  95.  
  96. /* The bars. */
  97. var bar_2 = vis_2.add(pv.Panel)
  98.     .data(data_voc)
  99.     .left(function() x(this.index))
  100.     .width(x.range().band)
  101.   .add(pv.Bar)
  102.     .data(function(d) d)
  103.     .left(function() this.index * x.range().band/n)
  104.     .width(x.range().band / n)
  105.     .bottom(0)
  106.     .height(y)
  107.     .fillStyle(pv.Colors.category20().by(pv.index));
  108.  
  109. /* The value label. */
  110. bar_2.anchor("top").add(pv.Label)
  111.     .textStyle("white")
  112.     .text(function(d) d.toFixed(1));
  113.  
  114. /* The variable label. */
  115. bar_2.parent.anchor("bottom").add(pv.Label)
  116.     .textAlign("left")
  117.     //.textMargin(5)
  118.     .textBaseline("top")
  119.     .textAngle(3*Math.PI/2)
  120.     .text(function() cuentos[this.parent.index]);
  121.  
  122. /* X-axis ticks. */
  123. vis_2.add(pv.Rule)
  124.     .data(y.ticks(15))
  125.     .bottom(y)
  126.     .strokeStyle(function(d) d ? "rgba(127,127,127,0.3)" : "#000")
  127.   .add(pv.Rule)
  128.     .left(0)
  129.     .width(5)
  130.     .strokeStyle("#000")
  131.   .anchor("left").add(pv.Label)
  132.     .text(y.tickFormat);
  133.  
  134. vis_2.add(pv.Dot)
  135.     .data(["Tu","Tus compañeros"])
  136.     .right(-10)
  137.     .size(8)
  138.     .strokeStyle(null)
  139.     .top(function () 100 + this.index * 20)
  140.     .fillStyle(pv.Colors.category20().by(pv.index))
  141.   .anchor("right").add(pv.Label);
  142.  
  143. vis.canvas("comprehension_vis");
  144. vis.render();
  145. vis_2.canvas("vocabulary_vis");
  146. vis_2.render();
  147.  
  148.  
  149. </script>
  150. <div id="vocabulary_vis"></div><div id="comprehension_vis"></div>
  151.             </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement