Files
weave-scope/client/app/scripts/charts/edge.js
Filip Barl 36ee5db1da Improved rendering order of nodes/edges in Graph View (#2623)
* Rendering both nodes and edges from one component.

* Organized the render layers in a more readable manner.

* Rerendering optimization.

* Finer edge rendering layers.

* Moved the constants out of the component file.

* Typo fix.

* Include edge thickness in <Motion /> instead of fade-in effect.
2017-06-22 11:58:31 +02:00

56 lines
1.4 KiB
JavaScript

import React from 'react';
import { connect } from 'react-redux';
import classNames from 'classnames';
import { enterEdge, leaveEdge } from '../actions/app-actions';
class Edge extends React.Component {
constructor(props, context) {
super(props, context);
this.handleMouseEnter = this.handleMouseEnter.bind(this);
this.handleMouseLeave = this.handleMouseLeave.bind(this);
}
render() {
const { id, path, highlighted, blurred, focused, thickness, source, target } = this.props;
const shouldRenderMarker = (focused || highlighted) && (source !== target);
const className = classNames('edge', { highlighted, blurred });
return (
<g
id={id} className={className}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
>
<path className="shadow" d={path} style={{ strokeWidth: 10 * thickness }} />
<path
className="link"
d={path}
markerEnd={shouldRenderMarker ? 'url(#end-arrow)' : null}
style={{ strokeWidth: thickness }}
/>
</g>
);
}
handleMouseEnter(ev) {
this.props.enterEdge(ev.currentTarget.id);
}
handleMouseLeave(ev) {
this.props.leaveEdge(ev.currentTarget.id);
}
}
function mapStateToProps(state) {
return {
contrastMode: state.get('contrastMode')
};
}
export default connect(
mapStateToProps,
{ enterEdge, leaveEdge }
)(Edge);