Brush not working!!!

Hi! I’m new to programming. I love data visualization very much. I would really like to be able to see the data as it is presented.
In the draft there is an answer to the error that I cannot understand: (
you will notice for my mistakes …)

https://observablehq.com/@chartasflow123/untitled

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

this kind of visualization is beautiful. I thank you so much for helping me!! I rewrite this draft… maybe its suitable (have flaws):

https://observablehq.com/@chartasflow123/untitled/2

thank you so much…

I rewrite this too…
https://observablehq.com/@chartasflow123/untitled/2