Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making Marker height and width configurable #245

Merged
merged 6 commits into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions src/components/graph/graph.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@
* ```javascript
* link.strokeWidth * (1 / transform); // transform is a zoom delta Δ value
* ```
* @param {number} [link.markerHeight=6] - <a target="_blank" href="https://developer.mozilla.org/en/docs/Web/SVG/Attribute/markerHeight">markerHeight</a>
* property for the link arrowhead height.
* @param {number} [link.markerWidth=6] - <a target="_blank" href="https://developer.mozilla.org/en/docs/Web/SVG/Attribute/markerWidth">markerWidth</a>
* property for the link arrowhead width.
* @param {string} [link.type="STRAIGHT"] - the type of line to draw, available types at this point are:
* - "STRAIGHT" <small>(default)</small> - a straight line.
* - "CURVE_SMOOTH" - a slight curve between two nodes
Expand Down Expand Up @@ -266,6 +270,8 @@ export default {
renderLabel: false,
semanticStrokeWidth: false,
strokeWidth: 1.5,
markerHeight: "6",
danielcaldas marked this conversation as resolved.
Show resolved Hide resolved
markerWidth: "6",
type: "STRAIGHT",
},
};
17 changes: 11 additions & 6 deletions src/components/graph/graph.renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,19 @@ function _renderDefs() {
const medium = small + (MARKER_MEDIUM_OFFSET * config.maxZoom) / 3;
const large = small + (MARKER_LARGE_OFFSET * config.maxZoom) / 3;

const markerProps = {
markerWidth: config.link.markerWidth,
markerHeight: config.link.markerHeight,
};

cachedDefs = (
<defs>
<Marker id={MARKERS.MARKER_S} refX={small} fill={config.link.color} />
<Marker id={MARKERS.MARKER_SH} refX={small} fill={config.link.highlightColor} />
<Marker id={MARKERS.MARKER_M} refX={medium} fill={config.link.color} />
<Marker id={MARKERS.MARKER_MH} refX={medium} fill={config.link.highlightColor} />
<Marker id={MARKERS.MARKER_L} refX={large} fill={config.link.color} />
<Marker id={MARKERS.MARKER_LH} refX={large} fill={config.link.highlightColor} />
<Marker id={MARKERS.MARKER_S} refX={small} fill={config.link.color} {...markerProps} />
<Marker id={MARKERS.MARKER_SH} refX={small} fill={config.link.highlightColor} {...markerProps} />
<Marker id={MARKERS.MARKER_M} refX={medium} fill={config.link.color} {...markerProps} />
<Marker id={MARKERS.MARKER_MH} refX={medium} fill={config.link.highlightColor} {...markerProps} />
<Marker id={MARKERS.MARKER_L} refX={large} fill={config.link.color} {...markerProps} />
<Marker id={MARKERS.MARKER_LH} refX={large} fill={config.link.highlightColor} {...markerProps} />
</defs>
);

Expand Down
4 changes: 2 additions & 2 deletions src/components/marker/Marker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default class Marker extends React.Component {
viewBox="0 -5 10 10"
refX={this.props.refX}
refY="0"
markerWidth="6"
markerHeight="6"
markerWidth={this.props.markerWidth}
danielcaldas marked this conversation as resolved.
Show resolved Hide resolved
markerHeight={this.props.markerHeight}
orient="auto"
fill={this.props.fill}
>
Expand Down