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', function(d) {
            return path.centroid(d)[0];
          })
          .attr('y', function(d) {
            return path.centroid(d)[1] + 4;
          })
          .each(function(d) {
              var arr = d.properties.eventname.split(" ");
              if (arr != undefined) {
                for (var i = 0; i < arr.length; i++) {
                  d3.select(this).append("tspan")
                    .text(function() {
                        return arr[i];
                      })
                      .attr("y", path.centroid(d)[1] + i * 8 + 8)
                      .attr("x", path.centroid(d)[0])
                      .attr("text-anchor", "middle");
                    }
                }
              });