MrBlenny / react-flow-chart

🌊 A flexible, stateless, declarative flow chart library for react.
https://mrblenny.github.io/react-flow-chart/index.html
MIT License
1.46k stars 307 forks source link

[Question] How to make Left to Right? #62

Closed jamesdwilson closed 4 years ago

jamesdwilson commented 4 years ago

Is it possible to make the flow of the nodes left to right instead of top to bottom?

Thank you!

jamesdwilson commented 4 years ago

In src/components/Ports/Ports.default.tsx

I changed

      <PortsGroupDefault config={config} side="top">
...
      <PortsGroupDefault config={config} side="bottom">

to:

      <PortsGroupDefault config={config} side="left">
...
      <PortsGroupDefault config={config} side="right">

and that seems to work. Do you think this is a good solution?

jamesdwilson commented 4 years ago

Can you please expose this as a prop either way?

jamesdwilson commented 4 years ago

Okay I solved it in a better way I think by copying Ports.default.tsx from the libary to my local project as PortsLtr.tsx and then consumed it as so:

 <FlowChart
                    chart={chart}
                    callbacks={stateActions}
                    Components={{
                        NodeInner: NodeInnerCustom,
                        Ports: PortsLtr
                    }}
                />

Open to better ideas.

MehdiSaffar commented 4 years ago

I also did something similar because I didn't want the nodes to hook to the bottom/top/left/right but wanted the links to end at the center behind the node.

Something like this:

image

jason-james commented 4 years ago

I also did something similar because I didn't want the nodes to hook to the bottom/top/left/right but wanted the links to end at the center behind the node.

Something like this:

image

This looks nice, could you share your changes?

mrkchang commented 4 years ago

Yes. Would be great to have this as a property. Personally prefer L->R

mrkchang commented 4 years ago

Actually you can just change your port type: type: "left" and it'll do the job

jamesdwilson commented 4 years ago

Actually you can just change your port type: type: "left" and it'll do the job

@mrkchang can you please post a code sample?