I am trying to use dc.js to implement the crossfilter and d3. I am almost successful. When I run my code in JSFiddle, it works perfectly ok! But when i try to implement the exact code on the local system, it gives me Uncaught TypeError: Cannot read property 'textContent' of null error.
My code is
trial1.js
var yearChart = dc.barChart('#year-chart');
//the data
var data = [
{date: "2015-10-01", type: "car", quantity: 3}];
var dispatch = crossfilter(data);
var parseDate = d3.time.format("%Y-%m-%d").parse;
data.forEach(function (d) {
d.date = parseDate(d.date);
d.quantity = +d.quantity;
d.Year = d.date.getFullYear();
});
var dateDim = dispatch.dimension(function (d) {
return d.date;
});
var productions = dateDim.group().reduceSum(function (d) {
return d.quantity;
});
var minDate = dateDim.bottom(1)[0].date;
var maxDate = dateDim.top(1)[0].date;
yearChart.width(2000).height(200)
.dimension(dateDim)
.group(productions)
.x(d3.time.scale().domain([minDate, maxDate]))
.brushOn(false)
.centerBar(true)
.yAxisLabel("Productions per day")
.xUnits(function(){return 10;});
yearChart.render();
<html>
<head>
<meta charset="utf-8">
<script src="https:////cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="https://dc-js.github.io/dc.js/js/d3.js"></script>
<script type="text/javascript" src="https://dc-js.github.io/dc.js/js/crossfilter.js"></script>
<script type="text/javascript" src="https://dc-js.github.io/dc.js/js/dc.js"></script>
<script type="text/javascript" src="https://dc-js.github.io/dc.js/js/colorbrewer.js"></script>
<script type="text/javascript" src = "trial1.js"></script>
</head>
<body>
<div id="year-chart"></div>
</body>
</html>
the line of code in d3.js that gives the error is this.node().textContent;
<script src="https:////cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" charset="utf-8"></script>
the other imports are wrong.... – Godmotherscripts
– Godmother