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 8610085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:02:43+00:00 2026-06-12T04:02:43+00:00

My quest for d3.js wisdom continues! This time, I have added a guide line

  • 0

My quest for d3.js wisdom continues!

This time, I have added a guide line which is hovering in a vertical direction as a tool close to the pointer. The problem is that the line disturbs the mousemove functions since it adds an extra layer on top of the rest of the graph, which makes the the code run the mouseout event on sudden pointer movements. Is there a solution for this?

I have implemented the function in the following manner:

svg.on("mousemove", function(d) {
    svg.select(".guideline").remove();
    //svg.select(".valuelabel").remove();

    svg.append("line")
        .attr("class", "guideline")
        .attr("x1", d3.mouse(this)[0]-3)
        .attr("x2", d3.mouse(this)[0]-3)
        .attr("y1", margin[0])
        .attr("y2", height+margin[0])
        .attr("opacity", originOpacity)
        .attr("stroke", "#333");

});

And as an example of an event it is disturbing:

//Highlight each stack when hovering, and calculate y value for legend
stacks.on("mousemove", function(d) {
    svg.select(".label").remove();  

    //Calculate the closest index when hovering
    var perValue = width / data[0].data.length;
    var index = Math.ceil((d3.mouse(this)[0]-margin[3]) / perValue - 0.5);
    chart.selectAll(".valuelabel").each(function(data) { 
        if (data.name == d.name) { 
            d3.select(this).text(Math.round(data.data[index].y) + "%");
        } 
    });

    d3.select(this).attr("opacity", "1");
    svg.selectAll("." + d3.select(this).attr("class")).attr("opacity", "1");

    svg.append("text")
        .attr("class", "label")
        .attr("width", "100px")
        .attr("height", "20px")
        .attr("x", d3.mouse(this)[0] + 40)
        .attr("y", d3.mouse(this)[1] - 5)
        .text(d.group + ": " + d.name);
});
stacks.on("mouseout", function(d) {
    groups.selectAll("." + d.name).text(d.name);
    svg.select(".label").remove();
    svg.selectAll("." + d3.select(this).attr("class")).attr("opacity", originOpacity);
});
  • 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-12T04:02:44+00:00Added an answer on June 12, 2026 at 4:02 am

    Looks like you want pointer-events none on the guide line.

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

Sidebar

Related Questions

My quest of starting to use namespaces in PHP keeps continuing. This time PHPUnit
I have an entity Quest which contains many Task s: @Entity public class Quest
In my quest for a version-wide database filter for an application, I have written
Quest I am looking to fetch rows that have accented characters. The encoding for
In my quest for my first iPhone app I have posted about the correct
In my quest to correctly grasp Interface best practices, I have noticed declarations such
Which is a better way to select ans and quest from the table? SELECT
In my quest to generate new code in a Scala compiler plugin, I have
In my quest for looking for a BigInt library, I came across this post:
On my quest to implement a very simple 'drag' mechanism to my application (which

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.