I just started using d3.js yesterday, and I have some problems getting my things.
At the moment, I have created a chart with two y axes, each of which shows some values, and the x axis shows dates.
When clicking on the y-axis values, I show the corresponding horizontal grid lines.
My problem is that when scaling or drawing or dragging the grid lines (horizontal and vertical) do not scale correctly with the axis values, they just don't move at all.
Today I searched a lot and found some examples of how to do this, but none of them seem to work with the code that I already have.
I assume that logic should be added to the scaling behavior, but I'm not sure
function make_x_gridlines() {
return d3.axisBottom(x)
.ticks(5)
}
let xGrid = svg.append("g")
.attr('class', 'grid')
.attr("id", "grid")
.attr("transform", "translate(0," + height + ")")
.call(make_x_gridlines()
.tickSize(-height)
.tickFormat("")
)
function zoomed() {
.. some behavior ..
.. some behavior ..
}
Please see this script for all this.
I named the second y axis (right) zAxis, even if it is not a z axis.
Help would be greatly appreciated.
source
share