JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://d3js.org/d3.v3.min.js"></script>
CSS
.axis text {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #fff;
shape-rendering: crispEdges;
}
/*.x.axis path {
display: none;
}*/
div.tooltip {
position: absolute;
text-align: center;
width: 100px;
height: 18px;
padding: 2px;
font: 12px sans-serif;
background: lightsteelblue;
border: 0px;
border-radius: 10px;
pointer-events: none;
}
.tick line {
display: none;
}
JavaScript
var data = [
{
"episode": "Ep. 01",
"donations": 1000,
"ngo": "abc",
"bar_color": "#B3DA29",
"shadow_color": "#708125"
},
{
"episode": "Ep. 02",
"donations": 3880.98,
"ngo": "abc",
"bar_color": "#78C0F2",
"shadow_color": "#3E7FA5"
},
{
"episode": "Ep. 03",
"donations": 603.00,
"ngo": "abc",
"bar_color": "#9B58B5",
"shadow_color": "#5A3E6F"
},
{
"episode": "Ep. 04",
"donations": 4070.0,
"ngo": "abc",
"bar_color": "#E54C3C",
"shadow_color": "#B4320E"
},
{
"episode": "Ep. 05",
"donations": 210.00,
"ngo": "abc",
"bar_color": "#F2519D",
"shadow_color": "#BD3F7F"
},
{
"episode": "Ep. 06",
"donations": 100,
"ngo": "abc",
"bar_color": "#B3DA29",
"shadow_color": "#708125"
},
{
"episode": "Ep. 07",
"donations": 388.98,
"ngo": "abc",
"bar_color": "#78C0F2",
"shadow_color": "#3E7FA5"
},
{
"episode": "Ep. 08",
"donations": 603.00,
"ngo": "abc",
"bar_color": "#9B58B5",
"shadow_color": "#5A3E6F"
},
{
"episode": "Ep. 09",
"donations": 407.70,
"ngo": "abc",
"bar_color": "#E54C3C",
"shadow_color": "#B4320E"
},
{
"episode": "Ep. 10",
"donations": 210.00,
"ngo": "abc",
"bar_color": "#F2519D",
"shadow_color": "#BD3F7F"
}
];
var margin = {top: 100, right: 20, bottom: 60, left: 40},
width = 500 - margin.left - margin.right,
height = 355 - margin.top - margin.bottom;
var paddingProportion = 0.2;
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], paddingProportion);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom")
.tickSize(10,10);
var yAxis =...