Transitioning from version 3 to version 4 has resulted in an issue where tooltips are not displaying properly

After following a tutorial on creating a scatter plot using this reference, everything worked perfectly in version 3. However, upon switching to version 4, I encountered issues with the tooltip, x-axis, and y-axis not appearing.

To troubleshoot, I created a Plunker showcasing the code. Any insights on what might be causing the problem would be greatly appreciated.

function showTooltip (d, i) {

    //Save the chosen circle (not the voronoi)
    var element = d3.selectAll(".countries."+d.CountryCode);

    //Define and display the tooltip
    $(element).popover({
        placement: 'auto top',
        container: '#chart',
        trigger: 'manual',
        html : true,
        content: function() {
            return "<span style='font-size: 12px; text-align: center;'>" + "<span>" + "Speaker: " + "</span>" + d.Speaker + "\n"
            + "<span>" + "Duration: " + "</span>" + Math.round(d.Duration) + "\n" +"</span>"; }
    });
    $(element).popover('show');

    //Enhance visibility of chosen circle
    element.style("opacity", 1)
        .style("stroke-width", 6);

Update:

A corrected version of the scatter plot in v4 of d3 can be found here. Big thanks to Lary for assisting me in resolving the issue.

Answer №1

To resolve the issue with x-axis and y-axis not appearing:

Simply remove the following from your style:

 .axis .domain {
      display: none;
    }

For the tooltip and lines concern:

In the showtooltip function, make the following changes:

var element = d3.select(".countries."+d.CountryCode);

//Define and display the tooltip
$(element.node()).popover({
    placement: 'auto top',
    container: '#chart',
    trigger: 'manual',
    html : true,
    content: function() {
        return "<span style='font-size: 12px; text-align: center;'>" + "<span>" + "Speaker: " + "</span>" + d.Speaker + "\n"
        + "<span>" + "Duration: " + "</span>" + Math.round(d.Duration) + "\n" +"</span>"; }
});
$(element.node()).popover('show');

//Make selected circle more visible
element.style("opacity", 1)
    .style("stroke-width", 6);

//Add lines to bubbles for displaying precise data points
//vertical line
d3.select(".chordWrapper").append("g")
    .attr("class", "guide")
    .append("line")
        .attr("x1", element.attr("cx"))
        .attr("x2", element.attr("cx"))
        .attr("y1", +element.attr("cy"))
        .attr("y2", (height))
        .style("stroke", element.style("fill"))
        .style("opacity",  0)
        .style("pointer-events", "none")
        .transition().duration(200)
        .style("opacity", 0.5);
//horizontal line
d3.select(".chordWrapper").append("g")
    .attr("class", "guide")
    .append("line")
        .attr("x1", +element.attr("cx"))
        .attr("x2", 0)
        .attr("y1", element.attr("cy"))
        .attr("y2", element.attr("cy"))
        .style("stroke",  element.style("fill"))
        .style("opacity",  0)
        .style("pointer-events", "none")
        .transition().duration(200)
        .style("opacity", 0.5);

Additionally, add the following to your circles:

.on("mouseover", showTooltip)
.on("mouseout",  removeTooltip);

This should be implemented in your circles at line 84 of script.js)

You can view an example here:

https://embed.plnkr.co/86jdbWgHtABY95ZEv9SE/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The value sent from the ajax call did not reach the PHP file as expected

Here's the code I'm working with: HTML and Javascript: function getValues(){ var filter; $.ajax({ type: "POST", url: "myphpfile.PHP?action=sek", data: "id=1", async: false, suc ...

Exploring the functionalities of AngularJS' ng-options when working with select elements

In my search through other posts, I came across this issue but couldn't find a solution. Here is the array in question: $scope.items = [ {ID: '000001', Title: 'Chicago'}, {ID: '000002', Title: 'New York' ...

Is it possible to repeat this action by swiping to the left?

I'm currently developing an app in PhoneGap and retrieving information using JSON. My goal is to trigger this function again with Ajax when I slide left. This is the code I have so far. Thank you to everyone for your assistance. $(document).ready( ...

Checkbox in Angular FormGroup not triggering touched state

There seems to be an issue with the Angular form when checking if the form is touched, especially in relation to a checkbox element. Despite the value of the checkbox changing on click, I am seeing !newDeviceGroup.touched = true. I'm not quite sure wh ...

The functionality of Google's AdMob in the context of Meteor.js/Cordova is currently not defined

I have been working on developing a mobile app specifically for android platforms using Meteor.js As I am nearing completion, I decided to integrate Google AdMob into my application. Unfortunately, despite my efforts, I could not find any suitable package ...

MUI version 5 - Checkboxes are receiving a variety of unique classes

After recently upgrading from Mui v4 to v5, I've noticed a strange behavior with checkboxes. Upon inspecting the DOM differences between the two versions, it appears that some additional classes are now being applied in v5 and the extra span with the ...

Animating back with a jQuery if statement

Is there a way to implement an if statement that triggers an animation when the right image reaches +400px, and then animates back to -400px upon hovering over the image? $('#left img').mouseenter(function() { $('#right img').animate ...

The response parser in Angular 7 is failing to function correctly

Hey, I recently updated my Angular from version 4.4 to the latest 7 and after encountering several errors, I was able to get my service up and running. However, I'm facing an issue with my output parser function which is supposed to parse the login re ...

Bring in a function by its name from the ts-nameof package that is not declared in the d.ts export

Recently, I came across a captivating package that caught my interest and I would love to incorporate it into my TypeScript application: https://github.com/dsherret/ts-nameof However, upon attempting to import the nameof function, I realized it was not be ...

Ways to determine whether an element is presently engaged in scrolling

Is there a way to determine if certain actions can be disabled while an element is being scrolled? The scrolling may be triggered by using the mouse wheel or mouse pad, or by calling scrollIntoView(). Can we detect if an element is currently being scroll ...

Finding and comparing a specific portion of a text in JavaScript: A guide

Can you help me with a JavaScript algorithm that can find a substring within a string? subStringFinder('abbcdabbbbbck', 'ab') This should return index 0. Similarly, subStringFinder('abbcdabbbbbck', 'bck') should ...

Omit node_modules from typescript compilation using gulp-typescript

Having trouble running a gulp task to compile my typescript due to dependency-related errors. /content/node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Map'. /content/node_modules/@angular/core/src/facade/l ...

javascript - Add a function to an array, iterate through, and delete once executed

I've been attempting to develop an array that stores all pending error messages appearing on the DOM using jQuery. My goal is to iterate through the array to check for any error messages to display, and then remove them after execution. However, I&ap ...

Initial request fails to retrieve cookie generated by Javascript

I created a shopping cart that generates a cart, adds items, and stores it in a cookie named 'cart'. However, when I click on a hyperlink that leads to the checkout page, my ASP.NET application is unable to access the cookie. The cookie only get ...

Different methods for incorporating script-specific data into markup

How can we include extra meta data in HTML code to support client-side javascript functionality? Let's consider some straightforward examples: A list of contacts that, when clicked, displays their location on a map. For instance, how can we link la ...

Using Angular's ng-repeat directive to iterate over a list of <li> elements containing strings with

Query: <li ng-repeat='msg in msgs'>{{msg}}</li> Directive: msgs=['abc','a b v', '123'] msgs.push('Something entered from textarea, possibly containing line breaks') ...

Filtering JSON array is just as simple as working with XML

During my project, I have transitioned from using XML format to JSON format. The XML structure includes nodes such as: <Creature> <Name>Someone</Name> <Desert>false</Desert> <Woods>false</Woods> < ...

Refreshing the MarkerCluster following an AJAX request

My current challenge involves an AJAX function that retrieves posts based on users with a specific role. While the query itself works fine, I am encountering an issue with refreshing the markers on Google Maps after the AJAX request is complete and the pos ...

Activate jqGrid's navigation bar save icon when the ondblClickRow event is triggered

After setting the jqGrid row edit on the ondblClickRow event, how can I enable the save icon on the navigation bar when a row is double clicked? ondblClickRow: function (rowid) { jQuery(this).jqGrid('editRow', rowid, true, null, null); ...

Developing several sliders and ensuring they operate independently of each other

I am currently in the process of developing multiple sliders for a website that I am building. As I reach the halfway point, I have encountered a problem that has stumped me. With several sliders involved, I have successfully obtained the length or count ...