Skip to content

Upgrading from v3 to v7 requires additional renders for my custom gauge #3833

Closed Answered by jjfrankovich
jjfrankovich asked this question in Q&A
Discussion options

You must be logged in to vote

With some more research, I see that with v4+, the selections are immutable. So something like this worked fine in v3:

  // Labels
  labels = gauge.selectAll('.label')
    .data(dataArray);

  labels
    .enter('g')
    .append('g')
    .attr('class', 'label');

The original "labels" selection would get the new data after it was appended by the enter, in v4 it doesn't because the selection doesn't get updated anymore.

Now I need to combine the .data with the join/enter before storing it as a separate variable in order to get the selection and all is well again:

  // Labels
  labels = gauge.selectAll('.label')
    .data(dataArray)
    .join('g')
    .attr('class', 'label');

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jjfrankovich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #3832 on March 22, 2024 17:01.