Now trying this:
var x = d3.time.scale().range([0, width]);
var y0 = d3.scale.linear().range([height, 0]);
var y1 = d3.scale.linear().range([height, 0]);
var xAxis = d3.svg.axis().scale(x)
.orient("bottom").ticks(5);
var yAxisLeft = d3.svg.axis().scale(y0)
.orient("left").ticks(5);
var yAxisRight = d3.svg.axis().scale(y1)
.orient("right").ticks(5);
And my code:
const min = 0;
const max = 200;
const min2 = 100;
const max2 = 500;
// Step 4
let xScale = d3.scaleTime().domain([Jan1 , new Date]).range([0, width]).nice(),
yScale = d3.scaleLinear().domain([min, max+10]).range([height, 0]).nice(),
zScale = d3.scaleLinear().domain([min2, max2+10]).range([height, 0]).nice(),
newX = xScale,
newY = yScale,
newZ = zScale;
var yAxisLeft = d3.svg.axis().scale(yScale)
.orient("left").ticks(10);
var yAxisRight = d3.svg.axis().scale(zScale)
.orient("right").ticks(10);
already says: Uncaught TypeError: d3.svg.axis is not a function
at the line var yAxisLeft = d3.svg.axis().scale(yScale)
Wrong D3 version or problem with domain? But the book uses it similarly, scaleLinear, domain, range, nice.
At the end axisRight and axisLeft.
Later this has to be adapted and the right one has to be added.
var axLft = g.append("g")
.attr('id', 'y-axis')
.call(d3.axisLeft(yScale));
my guess is
var axLft = g.append("g")
.attr('id', 'y-axis')
.call(d3.axisLeft(yAxisLeft));
var axRgt = g.append("g")
.attr('id', 'y-axis')
.call(d3.axisLeft(yAxisRight));
Seems to be complicated since it affects the data, zooming and percentages.