Skip to content

Commit d6b66d3

Browse files
committed
0.0.2
- renders tooltips in the correct place
1 parent d065b46 commit d6b66d3

File tree

7 files changed

+37
-12
lines changed

7 files changed

+37
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.0.2
2+
3+
- renders tooltips in the correct place
4+
15
# 0.0.1
26

37
- removes the need for directoryHash

dist/build.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lcov-server",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "🎯 A simple lcov server & cli parser",
55
"main": "index.js",
66
"homepage": "https://github.com/gabrielcsapo/lcov-server#readme",

src/lib/chart/line.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ class LineChart extends React.Component {
4343
});
4444
}
4545
hideTooltip() {
46-
this.setState(this.getInitialState());
46+
this.setState({
47+
tooltip: false,
48+
value: '',
49+
dataSet: 0,
50+
index: 0,
51+
x: 0,
52+
y: 0,
53+
color: '',
54+
updating: false
55+
});
4756
}
4857
render() {
4958
const { updating, tooltip, value, x, y, color } = this.state;
@@ -124,7 +133,7 @@ class LineChart extends React.Component {
124133
stroke={ stroke }
125134
/>
126135

127-
<Points hideLabels={ hideLabels } dots={ dots } label={ labels[pi] } points={ p } dataSetIndex={ pi } showTooltip={ this.showTooltip } hideTooltip={ this.hideTooltip } stroke={ stroke } radius={ radius } />
136+
<Points hideLabels={ hideLabels } dots={ dots } label={ labels[pi] } points={ p } dataSetIndex={ pi } showTooltip={ this.showTooltip.bind(this) } hideTooltip={ this.hideTooltip.bind(this) } stroke={ stroke } radius={ radius } />
128137
</g>
129138
)}
130139
</svg>

src/lib/chart/pie.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ class Pie extends React.Component {
2929
});
3030
}
3131
hideTooltip() {
32-
this.setState(this.getInitialState());
32+
this.setState({
33+
tooltip: false,
34+
value: '',
35+
label: 0,
36+
x: 0,
37+
y: 0,
38+
color: ''
39+
});
3340
}
3441
render() {
3542
const { colors, percent, labels, hole, radius, data, stroke, strokeWidth } = this.props;
@@ -71,8 +78,8 @@ class Pie extends React.Component {
7178
fill={ colors[sliceIndex % colorsLength] }
7279
stroke={ stroke }
7380
strokeWidth={ strokeWidth }
74-
showTooltip={ this.showTooltip }
75-
hideTooltip={ this.hideTooltip }
81+
showTooltip={ this.showTooltip.bind(this) }
82+
hideTooltip={ this.hideTooltip.bind(this) }
7683
/>);
7784
})}
7885
</svg>

src/lib/chart/point.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33

44
class Point extends React.Component {
5+
constructor(props) {
6+
super(props);
7+
}
58
mouseEnter() {
6-
this.props.showTooltip(this.props.point, this.props.dataSetIndex, this.props.index);
9+
const { radius, point, dataSetIndex, index } = this.props;
10+
11+
this.props.showTooltip([point[0] + radius * 3, point[1] + radius * 3], dataSetIndex, index);
712
}
813
mouseLeave() {
914
this.props.hideTooltip();
@@ -21,8 +26,8 @@ class Point extends React.Component {
2126
fill={ color }
2227
strokeWidth={ stroke }
2328
stroke={ '#ffffff' }
24-
onMouseEnter={ this.mouseEnter }
25-
onMouseLeave={ this.mouseLeave }
29+
onMouseEnter={ this.mouseEnter.bind(this) }
30+
onMouseLeave={ this.mouseLeave.bind(this) }
2631
/>);
2732
}
2833
}

src/lib/chart/slice.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class Slice extends React.Component {
7575
fill={ fill }
7676
stroke={ stroke }
7777
strokeWidth={ strokeWidth }
78-
onMouseEnter={ this.mouseEnter }
79-
onMouseLeave={ this.mouseLeave }
78+
onMouseEnter={ this.mouseEnter.bind(this) }
79+
onMouseLeave={ this.mouseLeave.bind(this) }
8080
/>
8181
{ showLabel && percentValue > 5 ?
8282
<text x={ x } y={ y } fill="#fff" textAnchor="middle">

0 commit comments

Comments
 (0)