D3 Bar Chart Help - Tooltip Test #2

When adding the data-date attribute to the tooltips. It only adds the first date to every tooltip.

Error: Tooltip’s “data-date” property should be equal to the active area’s “data-date” property: expected ‘1947-01-01’ to equal ‘1948-10-01’

Codepen: https://codepen.io/tsingh/pen/RwrzaBV

If someone could help that would be very appreciated.


    .on("mouseover", (d, i) => {

is an old D3 .on() function call and you’re using D3v7. You’ll need something like

  .on("mouseover", (event, datum) => {

which means you need to pass in the date/GDP pair in datum since you don’t have easy access to the outer dataset index. As it is, you’re passing in your scaledPrice which is a float, and the array subscripting to set data-date in data[i][0] is not behaving as intended. It looks like it is using zero everytime, which would explain the behavior the test is reporting.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.