JSFiddle - React, Tailwind, and code Playground

by Shashank D

HTML

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

<svg width="900" height="500"></svg>

CSS

.zoom {
  cursor: move;
  fill: none;
  pointer-events: all;
}

.TIMELINE {
  stroke-width : 2px;
  stroke-opacity:0.5;
}

.TIMELINE2 {
  stroke-width : 0.5px;
  stroke-opacity:0.5;
}

JavaScript

const data={"summary": [
      {
      "SheetName":  "Line 1",
      "N" : "3922 ",
      "Min" : "19990508 ",
      "Max" : "20180905 ",
      "Range" : "19.34 "
      },
      {
      "SheetName":  "Line 2",
      "N" : "482 ",
      "Min" : "20080215 ",
      "Max" : "20180720 ",
      "Range" : "10.41 "
      },
      {
      "SheetName":  "Line 3",
      "N" : "77 ",
      "Min" : "20080917 ",
      "Max" : "20150514 ",
      "Range" : "6.66 "
      },
      {
      "SheetName":  "Line 4",
      "N" : "60 ",
      "Min" : "20090325 ",
      "Max" : "20171205 ",
      "Range" : "8.76 "
      }],
      "data" :[
      {
      "DMY" : "19990101 ",
      },
      {
      "DMY" : "20190101 ",
      }
]};

var svg = d3.select("svg"),
    margin = {top: 20, right: 20, bottom: 110, left: 180},
    margin2 = {top: +svg.attr("height")-80, right: margin.right, bottom: 30, left: margin.left},
    width = +svg.attr("width") - margin.left - margin.right,
    height = +svg.attr("height") - margin.top - margin.bottom,
    height2 = +svg.attr("height") - margin2.top - margin2.bottom;

var parseDate = d3.timeParse("%b %Y");

var x = d3.scaleTime().range([0, width]),
    x2 = d3.scaleTime().range([0, width]),
    y = d3.scaleBand().range([0, height]),
    y2 = d3.scaleBand().range([0, height2]);

var xAxis = d3.axisBottom(x),
    xAxis2 = d3.axisBottom(x2),
    yAxis = d3.axisLeft(y);

var brush = d3.brushX()
    .extent([[0, 0], [width, height2]])
    .on("brush end", brushed);

var zoom = d3.zoom()
    .scaleExtent([1, Infinity])
    .translateExtent([[0, 0], [width, height]])
    .extent([[0, 0], [width, height]])
    .on("zoom", zoomed);

svg.append("defs").append("clipPath")
    .attr("id", "clip")
  .append("rect")
    .attr("width", width)
    .attr("height", height);

var focus = svg.append("g")
    .attr("class", "focus")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

var context = svg.append("g")
    .attr("class", "context")
   ...