Skip to content

Commit

Permalink
Bug danielcaldas#180 is caused by implementation of adding label on L…
Browse files Browse the repository at this point in the history
…ink. Remove it so Link renders properly
  • Loading branch information
wendymungovan committed Mar 27, 2019
1 parent 981bbf1 commit dc5a624
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 563 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/link.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("[rd3g-link] link tests", function() {
});

describe("and some link has a 'label' property", function() {
it("should properly render the label in the link between two nodes", function() {
it.skip("should properly render the label in the link between two nodes", function() {
// link between nodes' 1 and 2 should have a label
this.link12PO.getLabel().contains("link 1 and 2");
});
Expand Down
2 changes: 1 addition & 1 deletion sandbox/rd3g.sandbox.bundle.js

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions src/components/link/Link.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default class Link extends React.Component {
lineProps.markerEnd = `url(#${this.props.markerId})`;
}

/* eslint-disable no-unused-vars */
const { label, id } = this.props;
const textProps = {
dy: -1,
Expand All @@ -96,18 +97,24 @@ export default class Link extends React.Component {
fontWeight: this.props.fontWeight,
},
};
/* eslint-enable no-unused-vars */

return (
<svg>
<path {...lineProps} id={id} />
{label && (
<text style={{ textAnchor: "middle" }} {...textProps}>
<textPath href={`#${id}`} startOffset="50%">
{label}
</textPath>
</text>
)}
</svg>
);
// NOTE: this adds support for labels on the arcs but causes an issue
// where if you pan the graph then only part of the line is rendered.
// I think it is a viewbox/viewport issue with the wrapping svg but
// I'm not sure how to fix it so for now i'm removing support for
// the line labels so all lines draw properly.
// <svg>
// <path {...lineProps} id={id} />
// {label && (
// <text style={{ textAnchor: "middle" }} {...textProps}>
// <textPath href={`#${id}`} startOffset="50%">
// {label}
// </textPath>
// </text>
// )}
// </svg>

return <path {...lineProps} id={id} />;
}
}
Loading

0 comments on commit dc5a624

Please sign in to comment.