Trying to use d3.js and not sure how to reference it properly:
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="bootstrap.min.css">
<script src="jquery-1.7.1.js"></script>
<<<<other scripts>>>
<script src="topbar.js"></script>
<script>
$(function() {
var n = 4, // number of layers
m = 64, // number of samples per layer
data = d3.layout.stack()(stream_layers(n, m, .1)),
color = d3.interpolateRgb("#aad", "#556");
});
</script>
</head>
...
</html>
You need to include d3.layout.js in addition to d3.js; the layout module is in a separate file by default. You can also make a custom build of d3.js that includes everything you need in a single file.
(it's not the answer for this question)
For the people with the same error:
d3.layout is undefined
In my case was the problem I just link directly to the latest release (v4)
https://d3js.org/d3.v4.min.js
With (v3) it is working again.
https://d3js.org/d3.v3.min.js
You should use d3.stack instead.
Every symbol in D3 4.0 now shares a flat namespace rather than the nested one of D3 3.x. For example, d3.scale.linear is now d3.scaleLinear, and d3.layout.treemap is now d3.treemap.
For other d3.layout changes go here: https://github.com/d3/d3/blob/master/CHANGES.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With