css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h2>Les tendances de 2014</h2>
<div class="timchart"></div>


            
          
!
            
              html{
  color:white;
  background: #363f48;
  text-align:center;
}
.background path {
  fill: none;
  stroke: #363f48;
  stroke-opacity: .4;
  shape-rendering: crispEdges;
}

.foreground path {
  fill: none;
  stroke: steelblue;
  stroke-opacity: .7;
}

.brush .extent {
  fill-opacity: .3;
  stroke: #fff;
  shape-rendering: crispEdges;
}

.axis line,
.axis path {
  fill: none;
  stroke: #fff;
  shape-rendering: crispEdges;
}

.axis text {
 
  fill: white;
  cursor: move;

}

.timchart svg {
  font: 0.667em sans-serif;
  width: 100%;
  margin: 0 auto;
}
            
          
!
            
              var m_tim = [30, 10, 10, 10],
    w_tim = 1200 - m_tim[1] - m_tim[3],
    h_tim = 400 - m_tim[0] - m_tim[2];
var x_tim = d3.scale.ordinal().rangePoints([0, w_tim], 1),
    y_tim = {},
    dragging_tim = {};

var line_tim = d3.svg.line().interpolate("monotone"),
    axis_tim = d3.svg.axis().orient("left"),
    background,
    foreground;

var svg_tim = d3.select(".timchart").append("svg")
    .attr("width", w_tim + m_tim[1] + m_tim[3])
    .attr("height", h_tim + m_tim[0] + m_tim[2])
  .append("g")
    .attr("transform", "translate(" + m_tim[3] + "," + m_tim[0] + ")");

d3.csv("https://dl.dropboxusercontent.com/u/74265881/dataok.csv", function(error, cars) {

  // Extract the list of dimensions and create a scale for each.
  x_tim.domain(dimensions = d3.keys(cars[0]).filter(function(d) {
    return d != "name" && (y_tim[d] = d3.scale.linear()
        .domain(d3.extent(cars, function(p) { return +p[d]; }))
        .range([h_tim, 0]));
  }));

  // Add grey background lines for context.
  background_tim = svg_tim.append("g")
      .attr("class", "background")
    .selectAll("path")
      .data(cars)
    .enter().append("path")
      .attr("d", path);


  // Add blue foreground lines for focus.
  foreground = svg_tim.append("g")
      .attr("class", "foreground")
    .selectAll("path")
      .data(cars)
    .enter().append("path")
      .attr("d", path);

  // Add a group element for each dimension.
  var g_tim = svg_tim.selectAll(".dimension")
      .data(dimensions)
    .enter().append("g")
      .attr("class", "dimension")
      .attr("transform", function(d) { return "translate(" + x_tim(d) + ")"; })
      .call(d3.behavior.drag()
        .on("dragstart", function(d) {
          dragging_tim[d] = this.__origin__ = x_tim(d);
          background_tim.attr("visibility", "hidden");
        })
        .on("drag", function(d) {
          dragging_tim[d] = Math.min(w, Math.max(0, this.__origin__ += d3.event.dx));
          foreground.attr("d", path);
          dimensions.sort(function(a, b) { return position(a) - position(b); });
          x_tim.domain(dimensions);
          g_tim.attr("transform", function(d) { return "translate(" + position(d) + ")"; })
        })
        .on("dragend", function(d) {
          delete this.__origin__;
          delete dragging_tim[d];
          transition(d3.select(this)).attr("transform", "translate(" + x_tim(d) + ")");
          transition(foreground)
              .attr("d", path);
          background_tim
              .attr("d", path)
              .transition()
              .delay(500)
              .duration(0)
              .attr("visibility", null);
        }));

  // Add an axis and title.
  var axesTicks={"numéro":{"nb":42,"lbls":null},
  "genre":{"nb":1,"lbls":["femme","homme"]},
  "qualification":{"nb":2,"lbls":["code","mix","design","code"]},
  "age":{"nb":5,"lbls":null},
  "type":{"nb":1,"lbls":["2.0","2.5"] },
  "skype":{"nb":1,"lbls":["oui","non"] },
  "dropbox":{"nb":1,"lbls":["oui","non"] },
  "google drive":{"nb":1,"lbls":["oui","non"] },
  "trello":{"nb":1,"lbls":["oui","non"] },
  "slack":{"nb":1,"lbls":["oui","non"] },
  "twitter":{"nb":1,"lbls":["oui","non"]},
  "facebook":{"nb":1,"lbls":["oui","non"] },
  "évolution début":{"nb":2,"lbls":["un peu","bcp", "moyen", "un peu"]},
   "évolution milieu":{"nb":2,"lbls":["un peu","bcp", "moyen", "un peu"]},
   "évolution fin":{"nb":2,"lbls":["un peu","bcp", "moyen", "un peu"]},
   "implication":{"nb":2,"lbls":["un peu","bcp", "moyen", "un peu"]},
   "réussite":{"nb":1,"lbls":["oui","non"] }};
  g_tim.append("g")
      .attr("class", "axis")
      .each(function(d) { 
        d3.select(this)
          .call(
               axis_tim
               .scale(y_tim[d])
               .ticks(axesTicks[d].nb)
               .tickFormat(function(e){return axesTicks[d].lbls?axesTicks[d].lbls[e]:e;})
        ); })
    .append("text")
      .attr("text-anchor", "middle")
      .attr("y", -20)
      .text(String);

  // Add and store a brush for each axis.
  g_tim.append("g")
      .attr("class", "brush")
      .each(function(d) { d3.select(this).call(y_tim[d].brush = d3.svg.brush().y(y_tim[d]).on("brushstart", brushstart).on("brush", brush)); })
    .selectAll("rect")
      .attr("x", -8)
      .attr("width", 16);
});


function position(d) {
  var v_tim = dragging_tim[d];
  return v_tim == null ? x_tim(d) : v_tim;
}

function transition(g) {
  return g.transition().duration(500);
}

// Returns the path for a given data point.
function path(d) {
  return line_tim(dimensions.map(function(p) { return [position(p), y_tim[p](d[p])]; }))
  ;
}

// When brushing, don’t trigger axis dragging.
function brushstart() {
  d3.event.sourceEvent.stopPropagation();
}

// Handles a brush event, toggling the display of foreground lines.
function brush() {
  var actives = dimensions.filter(function(p) { return !y_tim[p].brush.empty(); }),
      extents = actives.map(function(p) { return y_tim[p].brush.extent(); });
  foreground.style("display", function(d) {
    return actives.every(function(p, i) {
      return extents[i][0] <= d[p] && d[p] <= extents[i][1];
    }) ? null : "none";
  });
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console