Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't see the any nodes. #1008

Open
DevWari opened this issue Jul 3, 2023 · 1 comment
Open

I can't see the any nodes. #1008

DevWari opened this issue Jul 3, 2023 · 1 comment

Comments

@DevWari
Copy link

DevWari commented Jul 3, 2023

import React from 'react';
import logo from './logo.svg';

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

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

const 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 is a package.json.

{
"name": "test",
"version": "0.1.0",
"private": true,
"dependencies": {
"@projectstorm/react-canvas-core": "^7.0.1",
"@projectstorm/react-diagrams": "^7.0.2",
"@projectstorm/react-diagrams-core": "^7.0.1",
"@projectstorm/react-diagrams-defaults": "^7.1.1",
"@projectstorm/react-diagrams-routing": "^7.1.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.38",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"gsap": "^3.12.2",
"json-beautify": "^1.1.1",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "PORT=3200 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

This is a source code I tried.
But nodes are not shown. I can't see anything.

@LynchyC
Copy link
Contributor

LynchyC commented Jul 9, 2023

It seems you are importing CanvasWidget, but you are not using it. That is the component that renders out your diagram model.

If you refer to this demo. Take line 40 and try again, you should be able to see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants