Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:15:45+00:00 2026-06-17T22:15:45+00:00

I have a table that has different rows. Every row is a different data

  • 0

I have a table that has different rows. Every row is a different data set.
I have an on click event attached to the rows that gives an extra chart when you click on the specific row.

But it only works the first time. After you first click on a specific row that data is shown in the chart, but if you click on another row the chart doesn’t change.

Here is some of my code:

    var chart = d3.select("body").append("svg")
          .attr("class", "chart")
          .attr("width", w * 24)
          .attr("height", h);

//saturday
var saturday = d3.select(".saturday")
        .selectAll("td")
        .data(d3.values(twitterDays[5][5]))
          .enter()
          .append("td")
          .attr("class", function(d) { return "hour h" + color(d); });

d3.select(".saturday").on("click", function() {
              chart.selectAll("rect")
                   .data(d3.values(twitterDays[5][5]))
                 .enter().append("rect")
                   .attr("x", function(d, i) { return x(i) - .5; })
                   .attr("y", function(d) { return h - y(d) - .5; })
                   .attr("width", w)
                   .attr("height", function(d) { return y(d); })

              chart.append("line")
                   .attr("x1", 0)
                   .attr("x2", w * d3.values(twitterDays[5][5]).length)
                   .attr("y1", h - .5)
                   .attr("y2", h - .5)
                   .style("stroke", "#000");
            });

//sunday
var sunday = d3.select(".sunday")
        .selectAll("td")
        .data(d3.values(twitterDays[6][6]))
          .enter()
          .append("td")
          .attr("class", function(d) { return "hour h" + color(d); });         

d3.select(".sunday").on("click", function() {
            chart.selectAll("rect")
                 .data(d3.values(twitterDays[6][6]))
               .enter().append("rect")
                 .attr("x", function(d, i) { return x(i) - .5; })
                 .attr("y", function(d) { return h - y(d) - .5; })
                 .attr("width", w)
                 .attr("height", function(d) { return y(d); })

            chart.append("line")
                 .attr("x1", 0)
                 .attr("x2", w * d3.values(twitterDays[6][6]).length)
                 .attr("y1", h - .5)
                 .attr("y2", h - .5)
                 .style("stroke", "#000");
          });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:15:46+00:00Added an answer on June 17, 2026 at 10:15 pm

    Your are only taking care of the so-called enter selection; meaning only the creation but not the update or removal of the rects is implemented in your code.

    See the General Update Pattern: General Update Pattern, I

      // DATA JOIN
      // Join new data with old elements, if any.
      var text = svg.selectAll("text")
          .data(data);
    
      // UPDATE
      // Update old elements as needed.
      text.attr("class", "update");
    
      // ENTER
      // Create new elements as needed.
      text.enter().append("text")
          .attr("class", "enter")
          .attr("x", function(d, i) { return i * 32; })
          .attr("dy", ".35em");
    
      // ENTER + UPDATE
      // Appending to the enter selection expands the update selection to include
      // entering elements; so, operations on the update selection after appending to
      // the enter selection will apply to both entering and updating nodes.
      text.text(function(d) { return d; });
    
      // EXIT
      // Remove old elements as needed.
      text.exit().remove();
    }
    

    Make sure to have a look at Mike’s Thinking with Joins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that has three different date columns, so I set each
I have a table that has multiple payments occuring on different dates each month.
I have a resultSet that has a different number of results every time, and
I have a set of rows that contain duplicate entries because the data originates
I have a table barcodes that has 1000's of rows of barcode in it.
I have a table users that has an auto-incrementing id column. For every new
I have a table that has account numbers in (account_num) and user profiles (profile_id).
I have a table that has two datetime columns (one for start time and
I have a table that has duplicate email address, I need to insert just
I have a table that has no primary key, and one cannot be created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.