Skip to content

Tooltips #47

@gerardjk

Description

@gerardjk

The code for tooltips seems to have changed between d3 versions.

.on("mouseover", function(d) {

                //Get this bar's x/y values, then augment for the tooltip

                var xPosition = parseFloat(d3.select(this).attr("x")) + xScale.bandwidth() / 2;
                var yPosition = parseFloat(d3.select(this).attr("y")) / 2 + h / 2;

                //Update the tooltip position and value
                d3.select("#tooltip")
                    .style("left", xPosition + "px")
                    .style("top", yPosition + "px")
                    .select("#value")
                    .text(d);

Returns "Object Mouse Event" in the tooltip rather than the actual number.
I got it to work by changing function(d) to function(e,d)

Metadata

Metadata

Assignees

Labels

v5This needs revision for D3 v5.x

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions