Brush not working!!!

Welcome, guilhermelight1!

In chart’s update function, you write path.attr("d", area(focusX, focusY));, as if area is a function that expects an x scale and y scale and returns a path generator using those scales. But the definition of area is just a path generator that always uses the global xScale and yScale. So when you pass it (focusX, focusY), it’s treating focusX as the array of data — so I think it’s looking for focusX[0].date, which doesn’t exist.

In this suggestion, I’ve updated area to take (x, y) arguments for those scales, and updated the initial calls to area (in both chart and focus) to pass xScale and yScale. It’s still not totally working (other aspects of the chart don’t update), but the brush at least now works to rescale the area.

Here’s the suggestion, which you can merge:

1 Like