NVD3 TEST

upside down

by Marei

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css">
<div id="chart">
  <svg></svg>
</div>

CSS

@import url(http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans+Mono);

#chart svg {
  height: 500px;
  width:700px;
}

.nv-label text{
    font-family: Droid Sans;
}

JavaScript

var data = [
  {
    "key": "Website A",
    "values": [ [ 20150601, 3], [ 20150602, 4], [ 20150603, 2], [ 20150604, 1], [ 20150605, 2], [20150606,2] ]
  },
               
  {
    "key": "Website B",
    "values": [ [ 20150601, 1], [ 20150602, 3], [ 20150603, 4], [ 20150604, 2], [ 20150605, 1], [20150606,3] ]
  },
  
    {
    "key": "Website C",
    "values": [ [ 20150601, 2], [ 20150602, 5], [ 20150603, 1], [ 20150604, 3], [ 20150605, 4], [20150606,5] ]
  }
]

nv.addGraph(function() {
  

  var chart = nv.models.lineChart()

  .x(function(d) {return d[0]})
  .y(function(d) {return d[1]})
  .yDomain([6, 1])  
  .color(d3.scale.category10().range())
   .useInteractiveGuideline(true)
   .margin({left: 100})  //Adjust chart margins to give the x-axis some breathing room.
.margin({right: 50})  //Adjust chart margins to give the x-axis some breathing room.
    ;

 
  chart.xAxis  
    .showMaxMin(false)
    .tickFormat(d3.format('d'))
    ;

  chart.yAxis
    .axisLabel('Rank')
    .tickFormat(d3.format('d'))
  ;
  
  
  d3.select('#chart svg')
    .datum(data)
    .transition().duration(500)
    .call(chart)
    ;

 nv.utils.windowResize(chart.update);

  return chart;
});