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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:04:35+00:00 2026-06-18T15:04:35+00:00

I have a scatter plot that is generated using D3. Points (SVG circles) on

  • 0

I have a scatter plot that is generated using D3. Points (SVG circles) on the plot can be selected by clicking on them and regions can be selected using a D3 brush.

To ensure the circles get the click event I need to create the brush first so the circles are above it. Unfortunately this means I can’t drag to create the brush extent when my cursor is over a point in the plot.

Is there a way to pass hover and click events to the circles, but handle drag related events with the brush?

  • 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-18T15:04:37+00:00Added an answer on June 18, 2026 at 3:04 pm

    It can be accomplished but with use of the D3 brush API (See note below).

    This is an example http://bl.ocks.org/4747894 where:

    1. The brush element is behind the circles
    2. The circles respond to the mousedown event. (Can respond to other events as well.)
    3. The brush element is well-behaved even if dragging starts from inside one of the circles.

    Some tracing and a look at the D3 source code suggests that the extent is not being reset properly when a mousemove event is fired from a circle element atop the brush. That can be fixed by resetting the extent for the brush in the mousedown listener for the circle elements:

            circles.on("mousedown", function (d, i) {
                // _svg_ is the node on which the brush has been created
                // x is the x-scale, y is the y-scale
                var xy = d3.mouse(svg.node()),
                    xInv = x.invert(xy[0]),
                    yInv = y.invert(xy[1]);
    
                // Reset brush's extent
                brush.extent([[xInv, yInv], [xInv, yInv]]);
    
                // Do other stuff which we wanted to do in this listener
            });
    

    Note: As per the API, the brush’s selection will not be refreshed automatically on calling .extent(values). Merely clicking on a circle will reset the extent but will not redraw the selection made. The selection will be discarded only when a different selection is started inside the circle, or by clicking outside the circles and the current selection. This is the desired behavior, as I understand from the question. However, this might break code which is written with the assumption that whatever is the extent of the brush would be the selection visible on the graph.

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

Sidebar

Related Questions

I would like to connect points in a 3d scatter plot in Matlab that
I have thousands of points to Plot on a JFreeChart scatter plot. The problem
I am using Core Plot 1.0. I have successfully made an XY scatter plot
if I have a scatter plot in matplotlib that returns a CircleCollection: coll =
I have a Highchart scatter chart that plots data calculated using a PHP script.
I have an Nx4 array of vertices that I'd like to plot using glVertexArray
I have managed to produce a scatter plot which has a scale 1:1 using
I have a scatter plot in R (with ggplot2). The data has a numeric
I have some surface data that is generated by an external program as XYZ
I am using R to analyse statistical data and plot histograms, scatter plots etc.

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.