react-diagrams icon indicating copy to clipboard operation
react-diagrams copied to clipboard

Unable to start using the same code

Open shoebmogal opened this issue 7 years ago • 2 comments

Hi,

I have created a sample project using create-react-app and added the sample code: ` import React from 'react'; import logo from './logo.svg'; // import './App.css';

import createEngine, { DefaultLinkModel, DefaultNodeModel, DiagramModel } from '@projectstorm/react-diagrams';

import { CanvasWidget } from '@projectstorm/react-canvas-core';

function App() {

// create an instance of the engine with all the defaults const engine = createEngine();

// node 1 const node1 = new DefaultNodeModel({ name: 'Node 1', color: 'rgb(0,192,255)', }); node1.setPosition(100, 100); let port1 = node1.addOutPort('Out');

// node 2 const node2 = new DefaultNodeModel({ name: 'Node 1', color: 'rgb(0,192,255)', }); node2.setPosition(100, 100); let port2 = node2.addOutPort('Out');

// link them and add a label to the link const link = port1.link(port2); link.addLabel('Hello World!');

const model = new DiagramModel(); model.addAll(node1, node2, link); engine.setModel(model);

return (

); }

export default App;

`

This does not work. It displays nothing except some warnings in the console.

Any leads?

shoebmogal avatar Aug 21 '19 18:08 shoebmogal

Check the CSS and element heights. Some parts might not have any height and therefore might just not be visible.

David-Melo avatar Aug 22 '19 14:08 David-Melo

thank @David-Melo , it works

TranVanKung avatar Oct 02 '19 09:10 TranVanKung