JSFiddle - React, Tailwind, and code Playground

by Critter

HTML

<script src="http://d3js.org/d3.v3.js"></script>

CSS

body {
  font: 10px sans-serif;
}

.axis path,
.axis line {
  fill: none;
  stroke: #000;
  shape-rendering: crispEdges;
}

.x.axis path {
  display: none;
}

.line {
  fill: none;
  stroke: steelblue;
  stroke-width: 1.5px;
}

JavaScript

var data = {
    {
      "city" : "New York",
      "values" : {
           "20111001" : 63.4,
           "20111002" : 58.0,
           "20111003" : 53.3
           }
    },
    {
      "city" : "San Francisco",
      "values" : {
           "20111001" : 62.7,
           "20111002" : 59.9,
           "20111003" : 59.1
           }
    },
    {
      "city" : "Austin",
      "values" : {
           "20111001" : 72.2,
           "20111002" : 67.7,
           "20111003" : 69.4
           }
    }
};


/* ALL CODE BELOW WAS COPIED DIRECTLY FROM MBOSTOCKS MULTI SERIES LINE CHART EXAMPLE AT http://bl.ocks.org/mbostock/3884955 */

var margin = {top: 20, right: 80, bottom: 30, left: 50},
    width = 960 - margin.left - margin.right,
    height = 500 - margin.top - margin.bottom;

var parseDate = d3.time.format("%Y%m%d").parse;

var x = d3.time.scale()
    .range([0, width]);

var y = d3.scale.linear()
    .range([height, 0]);

var color = d3.scale.category10();

var xAxis = d3.svg.axis()
    .scale(x)
    .orient("bottom");

var yAxis = d3.svg.axis()
    .scale(y)
    .orient("left");

var line = d3.svg.line()
    .interpolate("basis")
    .x(function(d) { return x(d.date); })
    .y(function(d) { return y(d.temperature); });

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 + ")");

color.domain(d3.keys(data[0]).filter(function(key) { return key !== "date"; }));

data.forEach(function(d) {
    d.date = parseDate(d.date);
});

var cities = color.domain().map(function(name) {
    return {
        name: name,
        values: data.map(function(d) {
            return {date: d.date, temperature: +d[name]};
        })
    };
});

x.domain(d3.extent(data, function(d) { return d.date; }));

y.domain([
    d3.min(cities, function(c) { return d3.min(c.values, function(v) { return v.temperature;...