Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/inherit/barEvt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default class BarEvt extends Component {
}

mouseOver(e, d) {

const contentTooltip = {title: d.name, value:d.y, fieldTitle: d.x, color: d.color};
const customContentToolTip = this.props.contentTooltip;
const contentTooltip = customContentToolTip? customContentToolTip(d): {title: d.name, value:d.y, fieldTitle: d.x, color: d.color};
this.setState({
xTooltip: e.clientX,
yTooltip: e.clientY,
Expand Down
5 changes: 3 additions & 2 deletions src/inherit/voronoiEvt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export default class VoronoiEvt extends Component {
}

voronoiMouseOver(e, d, xScaleSet, yScaleSet, stack) {
var newY = stack? yScaleSet(d.y + d.y0): yScaleSet(d.y);
const contentTooltip = {title: d.x.toString(), fieldTitle: d.name.toString(), value: d.y.toString(), color: d.color};
var newY = stack ? yScaleSet(d.y + d.y0) : yScaleSet(d.y);
const customContentToolTip = this.props.contentTooltip;
const contentTooltip = customContentToolTip ? customContentToolTip(d) : { title: d.x.toString(), fieldTitle: d.name.toString(), value: d.y.toString(), color: d.color };

this.setState({
focusX: xScaleSet(d.x),
Expand Down
33 changes: 4 additions & 29 deletions src/pie.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,17 @@ import {

import {Legend} from 'react-d3-core';
import Tooltip from './utils/tooltip';
import BarEvt from './inherit/barEvt';
import pieProps from './commonProps';

export default class PieTooltip extends Component {
export default class PieTooltip extends BarEvt {
constructor(props) {
super(props);

this.state = {
xTooltip: null,
yTooltip: null,
contentTooltip: null
}
}

static defaultProps = pieProps

_mouseOver(e, d) {
const contentTooltip = {
fieldTitle: d.data.name,
value: d.value,
color: d.color
}
this.setState({
xTooltip: e.clientX,
yTooltip: e.clientY,
contentTooltip: contentTooltip
})
}

_mouseOut(e, d) {
this.setState({
xTooltip: null,
yTooltip: null,
contentTooltip: null
})
}

render() {

const {
Expand All @@ -74,8 +49,8 @@ export default class PieTooltip extends Component {
{...this.props}
radius= {radius}
outerRadius= {outerRadius}
onMouseOver={this._mouseOver.bind(this)}
onMouseOut={this._mouseOut.bind(this)}
onMouseOver={this.mouseOver.bind(this)}
onMouseOut={this.mouseOut.bind(this)}
/>
</ChartPie>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/utils/voronoi.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export default class Voronoi extends Component {
d={"M" + area.join("L") + "Z"}
onMouseOut={this.triggerOut.bind(this, area.point)}
onMouseOver={this.triggerOver.bind(this, area.point)}
style={{fill: 'none', pointerEvents: 'all'}},
key: Math.random()
style={{fill: 'none', pointerEvents: 'all'}}
key={Math.random()}
/>
)
})
Expand Down