histogram

HTML

<script src="//d3js.org/d3.v4.min.js"></script>

JavaScript

var data = [
				{label: 'Янв', val: 20, popup:{label: 'Январь, 2015', val: '19 459,39 ₽'}},
			    
			]
      
      

// set the dimensions and margins of the graph
var margin = {top: 10, right: 30, bottom: 30, left: 40},
    width = 960 - margin.left - margin.right,
    height = 500 - margin.top - margin.bottom;

var labels=[];
data.forEach(function(d){
labels.push(d.label)
})

var x = d3.scalePoint()
          .domain(labels)
      		.range([0, width]);
          
var y = d3.scaleLinear()
          .range([height, 0]);
          
        
// append the svg object to the body of the page
// append a 'group' element to 'svg'
// moves the 'group' element to the top left margin
var svg = d3.select("body").append("svg")
    .attr("width", width + margin.left + margin.right)
    .attr("height", height + margin.top + margin.bottom)
  .append("g")
    .attr("transform", 
          "translate(" + margin.left + "," + margin.top + ")");

  // Scale the range of the data in the y domain
y.domain([0, d3.max(data, function(d) { return +d.val; })]);

svg.selectAll("rect")
    .data(data)
    .enter().append("rect")
      .attr("x", function(d) { return x(d.label); })
      .attr("y",  function(d) { return height - y(d.val); })
      .attr("height", function(d) { return y(d.val); })
      .attr("width", 2);

  // add the x Axis
  svg.append("g")
      .attr("transform", "translate(0," + height + ")")
      .call(d3.axisBottom(x));