Code Monkey home page Code Monkey logo

react-network-diagrams's Introduction

React Network Diagrams

Build Status npm version

This repository contains an initial set of React circuit drawing and network mapping components which are used within the ESnet Portal, but are not tied to ESnet, or even to network visualization.

The mapping portion of this library is used in the public facing ESnet Portal. The circuit diagrams code us used internally to track ESnet circuits in the ESDB.

Current features of the library include:

  • Circuit diagrams:
    • Basic
    • Concatenated
    • Parallel
  • Circuit couplers
  • Patch panel diagrams
  • Topology mapping
    • Higher level network traffic visualization
    • Linear, arc, bidirectional traffic and square edge types
  • Route rendering

Please browse the examples for a feel for the library, or read on to get started.

Getting started

The charts library is intended to be used with npm and the built into your project with something like webpack.

npm install react-network-diagrams --save

Once installed, you can import the necessary components from the library:

import { TrafficMap } from "react-network-diagrams";

You can then render() the traffic map in your component:

<TrafficMap width={980} height={500} margin={50}
            topology={topo}
            traffic={traffic}
            edgeColorMap={edgeColorMap}
            edgeDrawingMethod="bidirectionalArrow"
            edgeThicknessMap={edgeThicknessMap}
            edgeShapeMap={edgeShapeMap}
            nodeSizeMap={nodeSizeMap}
            nodeShapeMap={nodeShapeMap}
            stylesMap={stylesMap}
            selection={mapSelection}
            onSelectionChange={this.handleSelectionChanged} />

See the examples for more information.

Examples

To run the examples yourself, from the main directory, you first need to run these commands in the specific order:

npm install lerna
lerna exec npm install
lerna bootstrap

This will bootstrap the packages in the current Lerna repo and install the development dependencies into your node_modules directory.

You can then start up the test server, as well as automatic source building, by doing:

npm run start

And now, for the magic, point your browser to:

http://localhost:3000/

From now on, if you change the source code for the examples section, the examples bundle will be rebuilt and the browser will refresh itself. Errors will also be reported in the browser window.

If you want to change the react-network-diagrams code, you will need to run npm run build after working on your changes and then, the browser running the examples should reflect the changes.

For changes within the main library, run the following commands before committing the code:

npm run build
npm run docs (if there's changes to the API documentation)

If there are changes to the website, run npm run build from the packages/website directory before merging to master.

Once this is done, you can make a pull request to merge this code into the master branch

Release Process

Deploying a new version

Merge all the changes you want to deploy into the master branch.

Make sure to add release notes in CHANGELOG.md

Then, from the top level directory, run

lerna publish

As part of this command, it will ask you the version number you want to pick.

Once that is selected, it will update the relevant package.json files and push code to github as well as deploy a new release to npm.

Deploying the website

Currently, the website that hosts the examples and documentation can be found here - http://software.es.net/react-network-diagrams

This is being served via github pages, from the branch gh-pages-latest. Make sure to merge the latest code from master into this branch and it should automatically deploy the latest website.

react-network-diagrams's People

Contributors

dependabot[bot] avatar gertvangravity avatar jdugan1024 avatar pjm17971 avatar rfdrake avatar sartaj10 avatar srichmond 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

react-network-diagrams's Issues

Refactor data model

  • decouple names of nodes and edges from their identity -- add id
  • data model should allow for multiple edges
  • spend some time up front thinking about the data model

pathColorMap prop not working with keys that are not camelCased

It seems if the path name values are not camelCased, it doesn't seem to render the corresponding color value.

const pathColorMap = {
Ate23 Z1: "#00008b"
Kile23 Zsd1: "#00008b"
Byte23 : "#00008b"
Ate24 21: "#00008b"
}

or

const pathColorMap = {
"Ate23 Z1": "#00008b"
"Kile23 Zsd1": "#00008b"
"Byte23" : "#00008b"
"Ate24 21": "#00008b"
}

The component does not seem to support either of these formats

percent used of link edgeColorMap colour

hi,

i like to have the percent of a link used and then map that to the color
so if 1% of a link is in use then color is blue
5% green
10% yellow
and so on

is there a way to do that ?

CRA examples

We'd like simple examples for maybe a couple of circuit examples, as well as map topology, that users can just cut and paste into the App.js file of a create-react-app. This is to get people started quicker and cut down on the number of questions we get concerning getting our examples running, as well as general dev problems with webpack, npm etc.

Basic examples issue

Can you add simple examples for maybe a couple of graphs examples e.g. TrafficMap as well as map topology examples, that users can just cut and paste into the App.js file of a create-react-app. This is to get people started quicker and cut down on the number of questions we get concerning getting our examples running, as well as general dev problems with webpack, npm, data to use for components etc.

Make handleSelectionChanged function dynamic

Hello, I would like to know if there is a way to make the handleSelectionChanged function for the edges on the map more dynamic in order to decouple traffic data from the objects.

Here is a snippet of the code:

handleSelectionChanged(selectionType, selection) {
	    if (selectionType === "edge" && selection === "MCT--SAX") {
            this.props.trafficKeyChanged("MCT - SAX");
        } else if (selectionType === "edge" && selection === "MCT--SL") {
            this.props.trafficKeyChanged("MCT - SL");
 	    } else if (selectionType === "edge" && selection === "MCT--AW") {
            this.props.trafficKeyChanged("MCT - AW");
	    }

import component fails

Thanks for this great module ! Unfortunately, when I try to import any component, I have this error :

node_modules/react-network-diagrams/lib/node.js:23
TypeError: _react2.default.createClass is not a function

My application is running with react 16.4.0

Update project to Babel 6

Some people are getting build issues trying to clone this project and run it locally. Like our other libraries, this should be updated to Babel 6.

optionally use source/target id's instead of names when building edges

If you build an edge between two nodes in the map topology editor, then rename one of the nodes it causes the links built between the nodes to disappear.

Example:

   "edges": [
     {
       "capacity": "100G",
       "source": "Node1",
       "target": "Node2"
     },

If I were to change "Node1" to "Node 1" then this link goes away. It would be nice if I could use "source-id": "08a6bfc0-0f80-45af-92fc-7e06c2fa59ae" instead so the link can follow the node rename.

PropTypes `Invalid argument supplied to oneOfType` on import

A dump from my chrome console.

index.js:1 Warning: Invalid argument supplied to oneOfType. Expected an array of check functions, but received undefined at index 1.
console.<computed> @ index.js:1
printWarning @ factoryWithTypeCheckers.js:23
createUnionTypeChecker @ factoryWithTypeCheckers.js:372
../../node_modules/react-network-diagrams/lib/components/ConcatenatedCircuit.js @ ConcatenatedCircuit.js:387
__webpack_require__ @ bootstrap:788
fn @ bootstrap:149
../../node_modules/react-network-diagrams/lib/index.js @ index.js:20
__webpack_require__ @ bootstrap:788
fn @ bootstrap:149
./pages/Index.jsx @ module.js:22
__webpack_require__ @ bootstrap:788
fn @ bootstrap:149
./pages/index.js @ index.js:1
__webpack_require__ @ bootstrap:788
fn @ bootstrap:149
(anonymous) @ next-client-pages-loader.js:3
register @ page-loader.js:179
registerPage @ page-loader.js:221
register @ index.js:280
../../node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js?page=%2F&absolutePagePath=%2Fhome%2Fkrudolph%2FProjects%2Fjs-network-viewer%2Fapps%2Fnetwork-viewer%2Fpages%2Findex.js!./ @ next-client-pages-loader.js:2
__webpack_require__ @ bootstrap:788
fn @ bootstrap:149
0 @ index.js:3
__webpack_require__ @ bootstrap:788
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ index.js?ts=1566946336249:1

DeepinScreenshot_chromium_20190827161003

Note, this is running in a next.js dev server. A tar of an app that throws the warning is attached here
react-network-diagrams-bug-proptypes-warning-on-import.tar.gz

/app » node --version
v11.15.0

react-select is a dependency (not devDependency) for installing this package

Using webpack, npm i react-network-diagrams gives me this.

ERROR in ./node_modules/react-network-diagrams/lib/components/MapEditor.js
Module not found: Error: Can't resolve 'react-select' in '/Users/xyz/project/node_modules/react-network-diagrams/lib/components'
 @ ./node_modules/react-network-diagrams/lib/components/MapEditor.js 22:19-42
 @ ./node_modules/react-network-diagrams/lib/index.js
 @ ./project/js/components/Network.js
 @ ./project/js/components/App.js
 @ ./project/js/index.js
 @ multi babel-polyfill ./project/js/index.js

Documentation

I would like to use this tool but the documentation lacks. It would be great to be given a vanilla example please

npm install failure

Error: Cannot find module '/root/workdir/nodejs/node_modules/react-network-diagrams/node_modules/history/npm-scripts/postinstall.js'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:134:18)
at node.js:962:3

Installation fails with that error message. On Debian stable/testing. Please advise.

node onMouseDown does not provide event

Clicking on an endpoint throws an error, saying Uncaught TypeError: can't access property "stopPropagation", e is undefined.
src/components/Node.js on line 281: onMouseDown={e => this.handleMouseDown()}.
The handleMouseDown method expects a parameter (e).

Running in react 18

Hi, thanks for releasing this software.
The examples at http://software.es.net/react-network-diagrams/#/guide/start are a bit out of date - and the pages they link to have the repo removed.
Does this software run in more modern versions of React? It looks to be dependency pinned to 16.0 and this makes the bootstrap process quite tricky.

There aren't many recent updates to this repo - is the software still under maintenance?
Thanks

Update to React 15

This library hasn't been updated in a while. It at least needs to be updated to work with React 0.14/15.

Add key to the map legend

Causes this warning message on the Portal:

warning.js:45 Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `map-legend

Module not found: Can't resolve 'react-network-diagrams'

Upon creating a new project using create-react-app and adding the diagrams code from the master branch to package.json, get the following error

./src/App.js
Module not found: Can't resolve 'react-network-diagrams' in '/Users/ssbaveja/Desktop/Projects/test-diagrams/src'

Package.json looks like -

"dependencies": {
    "react": "^16.4.0",
    "react-dom": "^16.4.0",
    "react-scripts": "1.1.4",
    "react-network-diagrams": "git+https://github.com/esnet/react-network-diagrams.git#master"
  }

Crash on large data set

I'm using this library to generate a backbone sensor network graph and it works great so far.
However, if I'm trying to graph large set of data (about 8000 nodes and 20,000 edges), the browser would crash
I don't know if my laptop doesn't have enough memory to load it or because chrome can't handle it.
Chrome would crash and the "aw snap" page is always there

Unable to render `angled` for EndpointLabelPosition

Trying to render a concatenated circuit with the code below.

const memberList2 = []
if (finalArr && finalArr.length > 0) {
  console.log('finalArr ', finalArr)
  console.log('activeTab ', this.state.activeTab)
  let selectedValue = finalArr.find(o => o.id === this.state.activeTab);
  if (selectedValue === undefined ) {
    selectedValue = finalArr[0]
  }
  console.log("selectedList " + selectedValue)
  console.log('this is the activePath ', selectedValue.activePath)
  for (var i = 0; i < selectedValue.activePath.length; i++) {
    console.log('i ', i)
    if (i != 0 && i  % 2 != 0) {
      memberList2.push({
                styleProperties: circuitTypeProperties.coupler,
                endpointStyle: stylesMap.endpoint,
                endpointLabelA: selectedValue.activePath[i-1].port_id,
                endpointLabelZ: selectedValue.activePath[i].port_id
            });
      if (i != selectedValue.activePath.length-1) {
        memberList2.push({
                  styleProperties: circuitTypeProperties.optical,
                  endpointStyle: stylesMap.endpoint,
                  endpointLabelA: selectedValue.activePath[i].port_id,
                  endpointLabelZ: selectedValue.activePath[i+1].port_id
              });
      }
    }
  }
  console.log('memberList2 ', memberList2);
  console.log('length  of pathNodeList ' + pathNodeList.length);
}

const serviceDisplay = finalArr ? (
  pathNodeList.map((item, i) =>
    <Tab eventKey={item.id} title={item.label}>
      <ConcatenatedCircuit
      memberList={memberList2}
      endpointLabelPosition="bottomleftangled"
      connectionLabelPosition="center"
      yOffset={1}
      disabled="false"
      title=""
      onSelectionChange={this.handleSelectionChange}
      endpointLabelOffset={10}
      parentId={"services_tab"} />
    </Tab>
  )
 )
 :
 '';

endpointLabelPosition="bottomleftangled"

Endpoint label position just stays at bottom or top horizontally and is not angled.

It should be possible to exclude edges from the bidirectionalArrows

In the case of the facilities map, we would like to show the bidirectional arrows for the backbone and to the sites. However, since the facilities cluster around sites it would nice to be able to leave the simple edges for the links between sites and facilities.

Something like a prop called simpleEdges that would be a list of edges to just use the simple lines.

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.