Skip to content

Commit 47d359e

Browse files
committed
fixed tooltip location issue
1 parent 4e8423c commit 47d359e

File tree

2 files changed

+5
-46
lines changed

2 files changed

+5
-46
lines changed

src/app/components/Chart.jsx

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import React, { Component } from 'react';
66
import PropTypes from 'prop-types';
77
import * as d3 from 'd3';
8-
import * as _d3Tip from "d3-tip"
8+
import d3Tip from "d3-tip";
99

1010
let root = {};
1111
let duration = 750;
@@ -91,11 +91,11 @@ class Chart extends Component {
9191
.attr("r", 15)
9292

9393
//creating a d3.tip method where the html has a function that returns the data we passed into tip.show from line 120
94-
const d3Tip = _d3Tip.bind(d3)
9594
let tip = d3Tip()
9695
.attr("class", "d3-tip")
9796
.html(function (d) { return "State Snapshot: " + d; })
98-
//invoking tooltip for nodes
97+
98+
//invoking tooltip for nodes
9999
node.call(tip)
100100

101101
node
@@ -116,51 +116,12 @@ class Chart extends Component {
116116

117117
//applying tooltip on mouseover and removes it when mouse cursor moves away
118118
node
119-
// .on('mouseover', mouseover)
120-
// .on('mouseout', mouseout)
121-
// .on('mousemove', d => mousemove(d));
122119
.on('mouseover', function (d) {
123120
// without JSON.stringify, data will display as object Object
124-
tip.show(JSON.stringify(d.data.stateSnaphot))
121+
console.log('this is inside mouseover fxnality', JSON.stringify(d.data.stateSnaphot))
122+
tip.show(JSON.stringify(d.data), this)
125123
})
126124
.on('mouseout', tip.hide)
127-
128-
// function mousemove(d) {
129-
// div
130-
// .text(JSON.stringify(d.data.stateSnapshot))
131-
// }
132-
133-
// // Show state on mouse over
134-
// function mouseover() {
135-
// div
136-
// .transition()
137-
// .duration(300)
138-
// .style('display', 'block')
139-
// .style('opacity', 1);
140-
// }
141-
142-
// function mouseout() {
143-
// div
144-
// .transition()
145-
// .duration(3000)
146-
// .style('opacity', 1e-6)
147-
// .style('display', 'none');
148-
// }
149-
150-
// function tipMouseover() {
151-
// div
152-
// .transition()
153-
// .duration(300)
154-
// .style('opacity', 1);
155-
// }
156-
157-
// function tipMouseout() {
158-
// div
159-
// .transition()
160-
// .duration(3000)
161-
// .style('opacity', 1e-6)
162-
// .style('display', 'none');
163-
// }
164125

165126
function reinfeldTidierAlgo(x, y) {
166127
return [(y = +y) * Math.cos(x -= Math.PI / 2), y * Math.sin(x)];

src/app/d3tooltip.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)