<!DOCTYPE html>
<html>

  <head>
  <title>d3-cloud</title>
  <link type="text/css" rel="stylesheet" href="style.css" />
  </head>

  <body>
  <h3>Hecho por David Rivera</h3>
  <h4><a title="jherax" href="https://jherax.wordpress.com" target="_blank">
  jherax.wordpress.com</a></h4>
  <section id="tag-cloud-wrapper">
  </section>
  
  <!--<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>-->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js" charset="utf-8"></script>
  <script src="d3.layout.cloud.js"></script>
  <script src="sort-by.js"></script>
  <script src="main.js"></script>
  </body>

</html>
//----------------------
// See documentation at:
// http://www.jasondavies.com/wordcloud/about/
//----------------------
// See basic example at:
// https://github.com/jasondavies/d3-cloud/blob/master/examples/simple.html
//----------------------

// Get the content of data.csv
d3.csv("data.csv", function(data) {
  
  data.forEach(function(d) {
    d.size = +d.size;
  });

  //sorts the array by the most repeated word
  jsu.sortBy(data, { prop: "size", desc: true });
  var w = 1024, h = 512,
    maxFont = 96,
    maxSize = data[0].size || 1,
    sizeOffset = maxFont / maxSize;

  var fill = d3.scale.category20b(),
    layout = d3.layout.cloud()
    .size([w, h])
    .words(data)
    .spiral("rectangular")
    .rotate(function () { return (~~(Math.random() * 2) * -30) || 60; })
    //.text(function (d) { return d.text; })
    .font("Impact")
    .fontSize(function (d) {
        return Math.max(20, Math.min(d.size * sizeOffset, maxFont));
    })
    .on("end", onDraw);
  layout.start();

  //callback fired when all words have been placed
  function onDraw() {
      var svg = d3.select("#tag-cloud-wrapper").append("svg").attr({ width: w, height: h, "id": "svg-node" }),
          vis = svg.append("g").attr("transform", "translate(" + [w >> 1, (h >> 1) - 10] + ")scale(2)");
      var text = vis.selectAll("text").data(data);
      text.enter().append("text")
          .style("font-family", function (d) { return d.font; })
          .style("font-size", function (d) { return d.size + "px"; })
          .style("fill", function (d, i) { return fill(i); })
          .style({ cursor: "pointer", opacity: 1e-6 })
          .attr("text-anchor", "middle")
          .attr("transform", function (d) {
              return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
          })
          .text(function (d) { return d.text; })
          .on("click", function (d) {
              //[this] is the <text> element of svg
              var show = !this.classList.contains("current");
              toogleFade.apply(this, [show, d]);
          })
          .transition()
              .duration(1000)
              .style("opacity", 1);
      vis.transition()
          .delay(450)
          .duration(750)
          .attr("transform", "translate(" + [w >> 1, (h >> 1) + 10] + ")scale(1)");
  }//end onDraw
  
  //determines wheter to show or hide the elements in svg
  function toogleFade(show, d) {
    var element = d3.select(this),
        svg = d3.select("#svg-node"),
        time1 = 700,
        time2 = 1000;
    show = !!show;
    element.attr({ "class": show ? "current" : null, "data-role": "animation" })
      .transition()
      .duration(time1)
      .attr("transform", "translate(" + [d.x, d.y] + ")rotate(" + (show ? 0 : d.rotate) + ")scale(" + (+!show || 3) + ")")
      .each("end", function() { 
        show && setTimeout(function() { 
          alert("tag: " + d.text);
        }, time2 - time1);
      });
    svg.selectAll("text:not([data-role='animation'])")
      .transition()
      .duration(time2)
      .style("opacity", +!show)
      .style("visibility", show ? "hidden" : "visible")
      .each("end", function() { element.attr("data-role", null); });
  }//end toogleFade
  
});
/* Styles go here */
body {
    font-family:"Lucida Grande","Droid Sans",Arial,Helvetica,sans-serif;
    background: #e5e5e5 url(https://dl.dropboxusercontent.com/u/91579606/bg.gif) repeat;
}
h4 {
  margin-top: -8px;
}
.legend {
    border: 1px solid #555555;
    border-radius: 5px 5px 5px 5px;
    font-size: 0.8em;
    margin: 10px;
    padding: 8px;
}
.bld {
    font-weight: bold;
}
#tag-cloud-wrapper {
    margin-top: 22px;
}
#tag-cloud-wrapper > * {
    border-radius: 13px;
    background: -moz-radial-gradient(center, ellipse cover,  rgba(82,84,163,0.2) 0%, rgba(0,0,0,0) 100%); /* FF3.6+ */
    background: -webkit-radial-gradient(center, ellipse cover,  rgba(82,84,163,0.2) 0%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-radial-gradient(center, ellipse cover,  rgba(82,84,163,0.2) 0%,rgba(0,0,0,0) 100%); /* Opera 12+ */
    background: -ms-radial-gradient(center, ellipse cover,  rgba(82,84,163,0.2) 0%,rgba(0,0,0,0) 100%); /* IE10+ */
    background: radial-gradient(ellipse at center,  rgba(82,84,163,0.2) 0%,rgba(0,0,0,0) 100%); /* W3C */
}
text,size
cloud,	18
vmware,	9
windows,	8
storage,	8
vsphere,	7
vcenter,	7
powercli,	6
esxi,	6
vdi,	5
veeam,	5
vm,	4
backup,	4
linux,	4
lync,	4
powershell,	4
hp,	3
centos,	3
exchange,	3
fotografia,	3
vcloud,	3
esxcli,	3
visualstudio,	2
supermicro,	2
vshield,	2
esx,	2
dag,	2
db,	2
disco,	2
dns,	2
certificados,	2
comandos,	2
actualizacion,	2
ad,	2
apache,	2
bios,	2
ise,	2
monitoreo,	2
orion,	2
script,	2
raid,	2
sql,	2
ssd,	2
server,	2
sysprep,	2
tfs,	2
tools,	1
trend,	1
trucos,	1
udp,	1
usb,	1
usuarios,	1
tarea,	1
tarea-programada,	1
target,	1
service,	1
servidores,	1
single-sign-on,	1
sip,	1
snmp,	1
ssl,	1
storage-profile,	1
storcli,	1
rds,	1
recursos,	1
reflective,	1
rehabilitacion,	1
remota,	1
rendimiento,	1
replica,	1
replicacion,	1
resource,	1
restauracion,	1
scrum,	1
scrummaster,	1
scsi,	1
security,	1
seguridad,	1
selinux,	1
profile,	1
profile-driven,	1
psod,	1
pst,	1
qlogic,	1
osx,	1
owncloud,	1
packet,	1
pantalla,	1
pcoip,	1
perfiles,	1
phoenix,	1
php,	1
policies,	1
mysql,	1
network,	1
nic,	1
openssl,	1
ldap,	1
limpieza,	1
powershel,	1
html5,	1
httpd,	1
iis,	1
intel,	1
interface,	1
ip_conntrack,	1
ipmi,	1
iptables,	1
mac,	1
matricular,	1
microsoft,	1
migrar,	1
migration,	1
mod_rewrite,	1
llamadas,	1
logs,	1
lsi,	1
buzon,	1
caida,	1
carga,	1
cbt,	1
archivos,	1
audio,	1
autenticacion,	1
address,	1
administracion,	1
agil,	1
alarma,	1
almacenamiento,	1
analoga,	1
animacion,	1
concurrencia,	1
conexion,	1
configuracion,	1
controladoras,	1
creatividad,	1
css3,	1
daas,	1
cgi,	1
cisco,	1
cli,	1
certificado,	1
bd,	1
dominio,	1
drop,	1
dropping,	1
ebackups,	1
edge,	1
encripcion,	1
estilos,	1
dd,	1
digital,	1
datos,	1
cluster,	1
cna,	1
color,	1
acronis,	1
eth0,	1
excel,	1
exportar,	1
extend,	1
extender,	1
filtros,	1
firmware,	1
flap,	1
fsutil,	1
ftpsupermicrocomcdr-x9-up,	1
gestor,	1
godaddy,	1
gpg,	1
gpg4win,	1
hdd,	1
host,	1
vspher,	1
vmotion,	1
winrs,	1
workflow,	1
workspace,	1
web,	1
svmotion,	1
vcli,	1
ventana,	1
visual-studio,	1
vcops,	1
vdc,	1
vmxnet3,	1
voip,	1
volumen,	1
// Word cloud layout by Jason Davies, http://www.jasondavies.com/word-cloud/
// Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf
(function() {
  function cloud() {
    var size = [256, 256],
        text = cloudText,
        font = cloudFont,
        fontSize = cloudFontSize,
        fontStyle = cloudFontNormal,
        fontWeight = cloudFontNormal,
        rotate = cloudRotate,
        padding = cloudPadding,
        spiral = archimedeanSpiral,
        words = [],
        timeInterval = Infinity,
        event = d3.dispatch("word", "end"),
        timer = null,
        cloud = {};

    cloud.start = function() {
      var board = zeroArray((size[0] >> 5) * size[1]),
          bounds = null,
          n = words.length,
          i = -1,
          tags = [],
          data = words.map(function(d, i) {
            d.text = text.call(this, d, i);
            d.font = font.call(this, d, i);
            d.style = fontStyle.call(this, d, i);
            d.weight = fontWeight.call(this, d, i);
            d.rotate = rotate.call(this, d, i);
            d.size = ~~fontSize.call(this, d, i);
            d.padding = padding.call(this, d, i);
            return d;
          }).sort(function(a, b) { return b.size - a.size; });

      if (timer) clearInterval(timer);
      timer = setInterval(step, 0);
      step();

      return cloud;

      function step() {
        var start = +new Date,
            d;
        while (+new Date - start < timeInterval && ++i < n && timer) {
          d = data[i];
          d.x = (size[0] * (Math.random() + .5)) >> 1;
          d.y = (size[1] * (Math.random() + .5)) >> 1;
          cloudSprite(d, data, i);
          if (d.hasText && place(board, d, bounds)) {
            tags.push(d);
            event.word(d);
            if (bounds) cloudBounds(bounds, d);
            else bounds = [{x: d.x + d.x0, y: d.y + d.y0}, {x: d.x + d.x1, y: d.y + d.y1}];
            // Temporary hack
            d.x -= size[0] >> 1;
            d.y -= size[1] >> 1;
          }
        }
        if (i >= n) {
          cloud.stop();
          event.end(tags, bounds);
        }
      }
    }

    cloud.stop = function() {
      if (timer) {
        clearInterval(timer);
        timer = null;
      }
      return cloud;
    };

    cloud.timeInterval = function(x) {
      if (!arguments.length) return timeInterval;
      timeInterval = x == null ? Infinity : x;
      return cloud;
    };

    function place(board, tag, bounds) {
      var perimeter = [{x: 0, y: 0}, {x: size[0], y: size[1]}],
          startX = tag.x,
          startY = tag.y,
          maxDelta = Math.sqrt(size[0] * size[0] + size[1] * size[1]),
          s = spiral(size),
          dt = Math.random() < .5 ? 1 : -1,
          t = -dt,
          dxdy,
          dx,
          dy;

      while (dxdy = s(t += dt)) {
        dx = ~~dxdy[0];
        dy = ~~dxdy[1];

        if (Math.min(dx, dy) > maxDelta) break;

        tag.x = startX + dx;
        tag.y = startY + dy;

        if (tag.x + tag.x0 < 0 || tag.y + tag.y0 < 0 ||
            tag.x + tag.x1 > size[0] || tag.y + tag.y1 > size[1]) continue;
        // TODO only check for collisions within current bounds.
        if (!bounds || !cloudCollide(tag, board, size[0])) {
          if (!bounds || collideRects(tag, bounds)) {
            var sprite = tag.sprite,
                w = tag.width >> 5,
                sw = size[0] >> 5,
                lx = tag.x - (w << 4),
                sx = lx & 0x7f,
                msx = 32 - sx,
                h = tag.y1 - tag.y0,
                x = (tag.y + tag.y0) * sw + (lx >> 5),
                last;
            for (var j = 0; j < h; j++) {
              last = 0;
              for (var i = 0; i <= w; i++) {
                board[x + i] |= (last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0);
              }
              x += sw;
            }
            delete tag.sprite;
            return true;
          }
        }
      }
      return false;
    }

    cloud.words = function(x) {
      if (!arguments.length) return words;
      words = x;
      return cloud;
    };

    cloud.size = function(x) {
      if (!arguments.length) return size;
      size = [+x[0], +x[1]];
      return cloud;
    };

    cloud.font = function(x) {
      if (!arguments.length) return font;
      font = d3.functor(x);
      return cloud;
    };

    cloud.fontStyle = function(x) {
      if (!arguments.length) return fontStyle;
      fontStyle = d3.functor(x);
      return cloud;
    };

    cloud.fontWeight = function(x) {
      if (!arguments.length) return fontWeight;
      fontWeight = d3.functor(x);
      return cloud;
    };

    cloud.rotate = function(x) {
      if (!arguments.length) return rotate;
      rotate = d3.functor(x);
      return cloud;
    };

    cloud.text = function(x) {
      if (!arguments.length) return text;
      text = d3.functor(x);
      return cloud;
    };

    cloud.spiral = function(x) {
      if (!arguments.length) return spiral;
      spiral = spirals[x + ""] || x;
      return cloud;
    };

    cloud.fontSize = function(x) {
      if (!arguments.length) return fontSize;
      fontSize = d3.functor(x);
      return cloud;
    };

    cloud.padding = function(x) {
      if (!arguments.length) return padding;
      padding = d3.functor(x);
      return cloud;
    };

    return d3.rebind(cloud, event, "on");
  }

  function cloudText(d) {
    return d.text;
  }

  function cloudFont() {
    return "serif";
  }

  function cloudFontNormal() {
    return "normal";
  }

  function cloudFontSize(d) {
    return Math.sqrt(d.value);
  }

  function cloudRotate() {
    return (~~(Math.random() * 6) - 3) * 30;
  }

  function cloudPadding() {
    return 1;
  }

  // Fetches a monochrome sprite bitmap for the specified text.
  // Load in batches for speed.
  function cloudSprite(d, data, di) {
    if (d.sprite) return;
    c.clearRect(0, 0, (cw << 5) / ratio, ch / ratio);
    var x = 0,
        y = 0,
        maxh = 0,
        n = data.length;
    --di;
    while (++di < n) {
      d = data[di];
      c.save();
      c.font = d.style + " " + d.weight + " " + ~~((d.size + 1) / ratio) + "px " + d.font;
      var w = c.measureText(d.text + "m").width * ratio,
          h = d.size << 1;
      if (d.rotate) {
        var sr = Math.sin(d.rotate * cloudRadians),
            cr = Math.cos(d.rotate * cloudRadians),
            wcr = w * cr,
            wsr = w * sr,
            hcr = h * cr,
            hsr = h * sr;
        w = (Math.max(Math.abs(wcr + hsr), Math.abs(wcr - hsr)) + 0x1f) >> 5 << 5;
        h = ~~Math.max(Math.abs(wsr + hcr), Math.abs(wsr - hcr));
      } else {
        w = (w + 0x1f) >> 5 << 5;
      }
      if (h > maxh) maxh = h;
      if (x + w >= (cw << 5)) {
        x = 0;
        y += maxh;
        maxh = 0;
      }
      if (y + h >= ch) break;
      c.translate((x + (w >> 1)) / ratio, (y + (h >> 1)) / ratio);
      if (d.rotate) c.rotate(d.rotate * cloudRadians);
      c.fillText(d.text, 0, 0);
      if (d.padding) c.lineWidth = 2 * d.padding, c.strokeText(d.text, 0, 0);
      c.restore();
      d.width = w;
      d.height = h;
      d.xoff = x;
      d.yoff = y;
      d.x1 = w >> 1;
      d.y1 = h >> 1;
      d.x0 = -d.x1;
      d.y0 = -d.y1;
      d.hasText = true;
      x += w;
    }
    var pixels = c.getImageData(0, 0, (cw << 5) / ratio, ch / ratio).data,
        sprite = [];
    while (--di >= 0) {
      d = data[di];
      if (!d.hasText) continue;
      var w = d.width,
          w32 = w >> 5,
          h = d.y1 - d.y0;
      // Zero the buffer
      for (var i = 0; i < h * w32; i++) sprite[i] = 0;
      x = d.xoff;
      if (x == null) return;
      y = d.yoff;
      var seen = 0,
          seenRow = -1;
      for (var j = 0; j < h; j++) {
        for (var i = 0; i < w; i++) {
          var k = w32 * j + (i >> 5),
              m = pixels[((y + j) * (cw << 5) + (x + i)) << 2] ? 1 << (31 - (i % 32)) : 0;
          sprite[k] |= m;
          seen |= m;
        }
        if (seen) seenRow = j;
        else {
          d.y0++;
          h--;
          j--;
          y++;
        }
      }
      d.y1 = d.y0 + seenRow;
      d.sprite = sprite.slice(0, (d.y1 - d.y0) * w32);
    }
  }

  // Use mask-based collision detection.
  function cloudCollide(tag, board, sw) {
    sw >>= 5;
    var sprite = tag.sprite,
        w = tag.width >> 5,
        lx = tag.x - (w << 4),
        sx = lx & 0x7f,
        msx = 32 - sx,
        h = tag.y1 - tag.y0,
        x = (tag.y + tag.y0) * sw + (lx >> 5),
        last;
    for (var j = 0; j < h; j++) {
      last = 0;
      for (var i = 0; i <= w; i++) {
        if (((last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0))
            & board[x + i]) return true;
      }
      x += sw;
    }
    return false;
  }

  function cloudBounds(bounds, d) {
    var b0 = bounds[0],
        b1 = bounds[1];
    if (d.x + d.x0 < b0.x) b0.x = d.x + d.x0;
    if (d.y + d.y0 < b0.y) b0.y = d.y + d.y0;
    if (d.x + d.x1 > b1.x) b1.x = d.x + d.x1;
    if (d.y + d.y1 > b1.y) b1.y = d.y + d.y1;
  }

  function collideRects(a, b) {
    return a.x + a.x1 > b[0].x && a.x + a.x0 < b[1].x && a.y + a.y1 > b[0].y && a.y + a.y0 < b[1].y;
  }

  function archimedeanSpiral(size) {
    var e = size[0] / size[1];
    return function(t) {
      return [e * (t *= .1) * Math.cos(t), t * Math.sin(t)];
    };
  }

  function rectangularSpiral(size) {
    var dy = 4,
        dx = dy * size[0] / size[1],
        x = 0,
        y = 0;
    return function(t) {
      var sign = t < 0 ? -1 : 1;
      // See triangular numbers: T_n = n * (n + 1) / 2.
      switch ((Math.sqrt(1 + 4 * sign * t) - sign) & 3) {
        case 0:  x += dx; break;
        case 1:  y += dy; break;
        case 2:  x -= dx; break;
        default: y -= dy; break;
      }
      return [x, y];
    };
  }

  // TODO reuse arrays?
  function zeroArray(n) {
    var a = [],
        i = -1;
    while (++i < n) a[i] = 0;
    return a;
  }

  var cloudRadians = Math.PI / 180,
      cw = 1 << 11 >> 5,
      ch = 1 << 11,
      canvas,
      ratio = 1;

  if (typeof document !== "undefined") {
    canvas = document.createElement("canvas");
    canvas.width = 1;
    canvas.height = 1;
    ratio = Math.sqrt(canvas.getContext("2d").getImageData(0, 0, 1, 1).data.length >> 2);
    canvas.width = (cw << 5) / ratio;
    canvas.height = ch / ratio;
  } else {
    // Attempt to use node-canvas.
    canvas = new Canvas(cw << 5, ch);
  }

  var c = canvas.getContext("2d"),
      spirals = {
        archimedean: archimedeanSpiral,
        rectangular: rectangularSpiral
      };
  c.fillStyle = c.strokeStyle = "red";
  c.textAlign = "center";

  if (typeof module === "object" && module.exports) module.exports = cloud;
  else (d3.layout || (d3.layout = {})).cloud = cloud;
})();
// See an example of usage:
// https://gist.github.com/jherax/8781f45dcd068a9e3e37

//BEGIN MODULE
var jsu = (function (undefined) {
  
    var _toString = Object.prototype.toString,
        //the default parser function
        _parser = function (x) { return x; },
        //gets the item to be sorted
        _getItem = function (x) {
            return this.parser((_toString.call(x) == "[object Object]" && x[this.prop]) || x);
        };

    // Creates a method for sorting the Array
    // @array: the Array of elements
    // @o.prop: property name (if it is an Array of objects)
    // @o.desc: determines whether the sort is descending
    // @o.parser: function to parse the items to expected type
    function _sortBy (array, o) {
        if (_toString.call(array) != "[object Array]" || !array.length)
            return [];
        if (_toString.call(o) != "[object Object]")
            o = {};
        if (_toString.call(o.parser) != "[object Function]")
            o.parser = _parser;
        //if @o.desc is false: set 1, else -1
        o.desc = [1, -1][+!!o.desc];
        return array.sort(function (a, b) {
            a = _getItem.call(o, a);
            b = _getItem.call(o, b);
            return ((a > b) - (b > a)) * o.desc;
        });
    }
    
    //export the public API
    return {
      sortBy: _sortBy
    };
})();
//END MODULE