D3.js Template

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="//d3js.org/d3.v4.min.js"></script>
<div class="chart"></div>

CSS

* {
  margin: 0;
  padding: 0;
  border: 0;
}

body {
  background: #ffd;
}

svg {
  border: 1px solid red;
  background: grey;
}

JavaScript

var config = {};

        config.height = 200;
        config.width = 70;
        config.axisLabel = "test1 test2 test3";



        const chart = d3.select($('.chart')[0])
          .append("svg")
          .attr("width", config.width)
          .attr("height", config.height);


        const axisLabel = chart
          .append("g")
          .append("text")
          .attr("x", config.width / 2)
          .attr("y", config.height)
          .attr("dy", "-4px")
          .style("text-anchor", "middle")
          .text(config.axisLabel);