Comments (9)
@atruttmann I'm working on this, it's a bit harder since I have to re-structure the library around a getSmartEdge
function instead of factories, so it'll be a breaking change. The good thing is it will have a very similar API to React Flow's examples, and it'll give more control to developers when the path-finding happens
from react-flow-smart-edge.
Hey @tisoap, these updates are fabulous! 🥳 This was really easy to add to my project and works really well for my use case. From my testing so far it all works great, I'll let you know if anything changes.
from react-flow-smart-edge.
Hey @tisoap, thanks for the update, it looks great and working as expected in order to provide a custom label.
But one thing that I felt is that how can I chose what kind of smart edge I need using getSmartEdge
?
We have extra info about the type of edge as part of data
through which we used to identify what kind of smart edge need to be drawn and this is how the previous implementation looks like
This is my CustomEdge
component
const CustomEdge = props => {
const { data: { edgeLineType } } = props;
const edgeProps = { ...props, style: { strokeWidth: 2.2 }, labelStyle: { fontSize: '12px' } };
switch (edgeLineType) {
case 'straight': {
return <SmartStraightEdge { ...edgeProps } />;
}
case 'step': {
return <SmartStepEdge { ...edgeProps } />;
}
default: {
return <SmartBezierEdge { ...edgeProps } />;
}
}
};
In the other component where we render ReactFlow
const edgeTypes = {
customEdge: CustomEdge,
};
// Rest of the code
<ReactFlow
edgeTypes={ edgeTypes }
// other props
/>
Any suggestions how I can achieve this?
from react-flow-smart-edge.
how can I chose what kind of smart edge I need using getSmartEdge?
You would need pass an options
object to the getSmartEdge
, with the specific drawEdge
and generatePath
functions to create the desired line shape and path-finding behavior, respectively. You can see some examples on the Advanced Custom Smart Edges sections of the README.
To create a custom edge that behaves the same way as the built-in SmartStepEdge
for example, you would need to do something like this:
import {
getSmartEdge,
svgDrawStraightLinePath,
pathfindingJumpPointNoDiagonal
} from '@tisoap/react-flow-smart-edge'
// ...
const result = getSmartEdge({
sourcePosition,
targetPosition,
sourceX,
sourceY,
targetX,
targetY,
nodes,
options: {
drawEdge: svgDrawStraightLinePath,
generatePath: pathfindingJumpPointNoDiagonal,
}
})
Now I realize the README needs better examples, and of the importance of working on issue #29
from react-flow-smart-edge.
Hey @tisoap Thank you very much for the quick reply 🙌🏼. This works like a charm 🥳 🎉 as per our need. Will be waiting for the official release of this version of the library.
And sorry for missing out to check some of the examples under README as I was checking the source code and found that the getSmartEdge
also accepts options
as well. But, haven't checked that the methods under functions
like svgDrawStraightLinePath
, pathfindingJumpPointNoDiagonal
were also exposed to outside world.
I would be happy to help to work on #29
from react-flow-smart-edge.
Hey @NithishG , I'm glad you liked the library!
I see, you guys need to be able to implement an edge with an button, like this example on React Flow docs. Currently the smart edges in this package only allow for text labels using the edge options, but I can see this being a nice addition.
from react-flow-smart-edge.
This library looks awesome! I have the same use case - a custom edge with a button - and would love to see support for this too. I would like to center the button the same way as React Flow provides with getBezierEdgeCenter
.
from react-flow-smart-edge.
Hey @NithishG and @atruttmann ! I've released a beta version of the library that exposes a getSmartEdge
function, that allows for custom edges with custom labels to be created, could you guys test it out?
Available to test using the beta
tag. Install with NPM:
npm install @tisoap/react-flow-smart-edge@beta
New documentation can be found here.
from react-flow-smart-edge.
@NithishG @atruttmann : Version 2.0.0
was published
from react-flow-smart-edge.
Related Issues (20)
- Create templates for new issues
- Update Sponsor Badge
- Diagram becomes unresponsive with large data HOT 7
- Add draggable point to smart edge HOT 4
- Update to be compatible with React Flow 11 HOT 5
- In version 3.0 Beta - Edge between 2 nodes goes away if the nodes are close to each other HOT 3
- Props that are generated when you start dragging new connection are missing for <StepEdge /> in react flow v11 HOT 2
- Make edges not overlap each other HOT 1
- Connection line appears broken when using specific grid snapping HOT 3
- Connection line appears broken when using specific grid snapping HOT 1
- Demo page/Storybook is no longer working HOT 2
- Smart Edge Not Considering nodes inside a group. HOT 2
- Edges not starting/ending on XY coords HOT 1
- Bending of edge from source HOT 4
- Edge labels getting overlapped HOT 6
- Add SmoothStepPath HOT 3
- edgeCenterX and edgeCenterY sometimes aren't calculated properly! HOT 1
- Option to propagate exceptions outside of getSmartEdge HOT 2
- engine warning when installing latest version HOT 2
- Add helper function for EdgeTypes and Options
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-flow-smart-edge.