I can apply a zoom to a path in d3v7. However, how can I zoom only in the x-axis instead of a standard zoom?
(1) How I call the zoom function:
var svgArea = d3.select('#svg');
const path = svgArea.append("path");
const line = d3.line()
.x(d => scale.x(d.sample))
.y(d => scale.y(d.value));
path
.datum(dataset)
.attr("fill", fillColor)
.attr("stroke", color)
.attr("d", line);
svgArea.call(zoom, padding, width, height, path);
(2) Zoom Function
function zoom(svg, padding, width, height, path) {
var extent = [
[padding, padding],
[width, height]
];
var zooming = d3.zoom()
.scaleExtent([1, 3])
.translateExtent(extent)
.extent(extent)
.on("zoom", zoomed);
svg.call(zooming);
function zoomed(e) {
path.attr("transform", e.transform);
}
}