Coder Social home page Coder Social logo

flowhub / the-graph Goto Github PK

View Code? Open in Web Editor NEW
1.0K 49.0 180.0 9.13 MB

SVG custom elements for FBP graph editing and visualization. Used in noflo/noflo-ui

Home Page: https://flowhub.github.io/the-graph/demo-full.html

License: MIT License

JavaScript 89.39% HTML 0.15% Stylus 10.47%
react graph svg editor flowhub

the-graph's Introduction

The Graph Editor MIT license

This project provides a set React components for viewing and editing node-based graphs. The focus is on graphs used for dataflow and Flow-based programming.

The graph structure is stored by fbp-graph, which supports extendable metadata and undo/redo.

You can optionally use klayjs-noflo for automatic layout of graphs.

the-graph is used as the editor in the Flowhub IDE.

Examples

Using

Install via NPM

npm install the-graph

See the examples for how to include the .js and .css files, and API usage.

License

The MIT License

Support

Please refer to https://noflojs.org/support/.

Developing

Clone the repo

git clone https://github.com/flowhub/the-graph.git # or your own fork on Github
cd the-graph

Install dependencies and build

npm install
npm run build

Run the demo server

npm start

or http://localhost:3000/examples/demo-full.html for interactive demo.

Send pull requests on Github!

the-graph's People

Contributors

astanciu avatar automata avatar bergie avatar bitdeli-chef avatar d4tocchini avatar davecarlson avatar dependabot[bot] avatar djdeath avatar ever-null avatar fabiancook avatar forresto avatar greenkeeper[bot] avatar greenkeeperio-bot avatar ifitzpatrick avatar jonnor avatar kinimodmeyer avatar krizka avatar ku-kueihsi avatar llandwerlin-intel avatar plasticpie avatar rhalff avatar townxelliot avatar u39kun avatar williamrclark avatar xdissent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

the-graph's Issues

center process label

<the-graph-process>
  <h1 class="the-graph-process-label">makeMinuteRotation</h1>
</the-graph-process>

Pretty basic, but impossible with css unless they all have a certain width.

dragging node crosshair

It can be tough to know where you'll release the node when your finger covers it. A simple solution could be a crosshair in the background:

touch crosshair

Snap newly loaded graph to grid, keep node x, y as absolute

The snap-to-grid feature from #8 should be entirely a visual aid for making graphs look cleaner with less fiddling. However, the grid should not affect the actual x, y coordinates of nodes:

  • When loading nodes from an initial graph, apply the grid to their positions
  • When moving nodes, store their real x, y value, but show them with the grid applied

This way we can even make the grid configurable, as it might be that the desirable grid size for a graph is anything between 1 pixel and [node-width].

prevent flash on panning

Panning -x -y direction fires a bumped event, which process and edges listen for to compensate. We should ensure that this happens within a single redraw, not the next event loop.

pointer event performance

I'm noticing that moving nodes is pretty slow, and I think the timeline is saying it is the pointer event polyfill's fault.

screen shot 2013-10-15 at 10 00 02 pm

Found another polyfill that could be worth trying: https://github.com/Rich-Harris/Points

Since that one intercepts events at the window level, it could maybe allow gmaps-like panning while dragged outside of the window.

Limit canvas panning

Even though we need to have an infinite canvas (#10), we still should not users get lost in the dot grid jungle.

So, limit panning so that at least one node from the graph is always visible on screen.

Implement a minimap for the graph

When parts of the graph are outside the current view, we should display a minimap showing the whole graph, with the current viewport highlighted.

It doesn't have to be an exact reproduction of the big graph, it is probably enough to just show the nodes as "blips"

(This could also be useful to preview a subgraph or collapsed group.)

civ

Architectural questions

Think we should iron these out sooner than later:

  • When does it make sense to use lightdom vs shadowdom
  • Attributes vs properties: seems like attributes are always strings, which is annoying to have to parse them back and forth.
  • Positional attributes as vectors pos="x y" pan="x y" since we need to react to both when one or both change. (Or properties? node.pos = {x:100, y:100})
  • the-behavior with a scale attribute. That way moving nodes and panning can be done in graph-relative units. The gestures can stay in screen-relative pixels.

Make Port calculatePosition faster

Currently position calculations seem kind of heavy. On a graph with 45 nodes that contain 105 ports, the calculation can take around 500-700ms.

A big part of this might be the fact that each port queries its siblings to find its relative position. It might be better to put the-graph-inports and the-graph-outports into the driver's seat to make this more coordinated.

See gss/gss#6

Correlate zoom centering and level to finger positions

With #14 zooming is now centered, which is perfect for non-touchscreen devices that use the zoom controls on the map screen.

However, this still isn't exactly how zooming should behave on the pinch gesture. Essentially what you want is tracking the position of the fingers, and changing map zooming and panning so that the fingers constantly stay on the same "absolute" graph coordinates regardless of how you pinch.

wow

Make wires touchable

Now the wires are so narrow that it is pretty much impossible to touch and manipulate them. We need to make the thicker without affecting how they look.

Different edge drawing algorithm for different edge directions

Instead of having a single edge drawing algorithm, we should look at the heading of the edge (from source node to target node), and pick the right algorithm:

  • E, NE, SE: from right side to left side, possibly with a curve
  • S: from bottom to top, possibly with a curve
  • N, NW, W: from bottom to left with a curve passing both nodes
  • SW: from bottom to top, with a curve passing both nodes

make edges with clicks/taps instead of dnd

Another way to make edges:

  • click node to show ports
  • click port
  • compatible ports expand (might require another tap to open that node)
  • click port

We should see if this is better than the directional gestures to move vs connect.

consider modes

graph: select, pan, zoom

node: move, connect

We've been avoiding modes as a design constraint, but I think eventually we'll have to break down and use them (+ keyboard shortcuts).

Center zoom

Currently we zoom at an edge. Instead, zooming should center at:

  • center of the screen when using the on-screen buttons
  • based on the touches when pinching

This should affect pan state accordingly

Swipe across a wire to remove it

For touchscreen devices, it would be nice to have a gesture where by swiping across a wire (or a set of them) they get removed.

drag pan outside of window

if the listener is attached to window is will also fire when dragging and releasing outside of the window, like gmaps

tested and working with

    var graph = this;
    window.addEventListener('track', function(event) {
      graph.panning({
        x: graph._pan.x + event.dx,
        y: graph._pan.y + event.dy
      });
    });
    window.addEventListener('trackend', function(event) {
      graph.panned({
        x: graph._pan.x + event.dx,
        y: graph._pan.y + event.dy
      });
    });

Nodes disappearing on state changes

Side effect of the work on #10 , currently we have nodes disappearing on several situations, like:

  • changing zoom level
  • highlighting a node

They reappear on pan, so this is probably a bumped value problem.

Momentum panning

A fast swipe should pan all the way across the graph (but not further, #15).

Should feel the same as the browser's momentum scrolling. Is there an accepted equation for that?

Show graph exports

the-graph-export nodes should be visualized as "pseudo-nodes" that can be moved around, removed, etc.

Basically the same look as regular the-graph-process instances but without highlighting.

gpu scaling looks like vector?

transform: scale(2)

ff
screen shot 2013-10-30 at 11 16 15 pm

chrome
screen shot 2013-10-30 at 11 17 03 pm

any idea why ff looks like vector scaling, and chrome a scaled texture (expected)?... seems like it must not be accelerating the css transform, though it feels just as fast.

grid alignment

nodes should snap #8 centered in the css grid

and the grid is getting off on zoom, fixing itself on pan

Background heat map

Currently the graph background is a passive dot grid. In the sketches however it had some additional features:

  1. Red guide line every third grid unit
  2. "Heatmap" showing the impact of currently selected node(s)

screenshot 2013-11-18 at 18 29 15

The heatmap should react to selection/highlighting state of nodes and show a brighter background for the grid under selected nodes, fading towards the regular dark background along the connections of that node

port order match order specified in component

I think this is important for muscle memory. After the initial ports are loaded based on the connections present in the graph, we will need to correct the order once the info is loaded from the library.

Otherwise...
screen shot 2013-10-18 at 2 56 56 pm

Node groups/layers

For a better way of explaining the structure of a graph, we need to support something like node grouping/layering with some textual information added.

The groups could be possible to either hide completely ('show only the templating part of this graph'), or maybe showable as a single node, sort of as 'inline subgraphs'.

Originally opened as meemoo/dataflow#56, see that for older discussion. The NoFlo side of this ticket is noflo/noflo#62

UI mockups

Grouped nodes in a graph:

screenshot 2013-11-05 at 11 55 33

Group navigator card (which would be in noflo/noflo-ui):

screenshot 2013-11-05 at 11 52 00

Clarify roles of the-graph and the-graph-editor

The graph component is responsible for displaying a graph. It may allow things like panning and zooming, but it shouldn't make any modifications to the graph (though it can of course react to modifications that happen anyway).

The graph editor component uses the graph component and adds the editing features.

This way we can use the-graph for static graph visualization, and the-graph-editor as the actual editing UI.

Snap-to-grid

Currently node dragging is 100% accurate, following your pointer (though, see #5). This makes graphs fiddly and easily messy-looking. We should instead implement a snap-to-grid feature. The sizing of that grid is another question... even a 10 pixel grid could be helpful, but on the bigger end we could even impose a grid of the same size as the nodes are.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.