I want to make a diagram that you cannot pull from your svg element. I am doing this at the moment jsfiddle
As you can see, you can scale and drag it freely. I want this: If you drag it, for example, to the right, and the y axis hits the edge of the screen on the left, it should stop and will no longer be dragged to the right.
It also means that you cannot drag it until it is enlarged, because it already fills the svg area.
I think I need to somehow limit my method of redrawing. At the moment itβs just
function redraw() {
plotChart.attr("transform",
"translate(" + d3.event.translate + ")"
+ " scale(" + d3.event.scale + ")");
};
Probably, you need to check if, for example, the left edge of the diagram falls into the coordinate [0] [x], and then somehow stops drawing it further.
source
share