question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Really Struggling

See original GitHub issue

Hello all, First and foremost, I’m a complete n00b to react and webpack. But I’d really like to use react-diagrams in my project, but can’t seem to get it to render properly.

Here is what I’ve done so far:

  1. cd into my project folder
  2. ran npm install --save storm-react-diagrams
  3. Created a new page on my site and added the following code to it:
import React, { Component } from 'react';

import {
	DiagramEngine,
	DiagramModel,
	DefaultNodeModel,
	LinkModel,
  DefaultPortModel,
  DiagramWidget,
  DefaultLinkModel
} from "storm-react-diagrams";


//1) setup the diagram engine
var engine = new DiagramEngine();
engine.installDefaultFactories();

//2) setup the diagram model
var model = new DiagramModel();

//3-A) create a default node
var node1 = new DefaultNodeModel("Node 1", "rgb(0,192,255)");
var port1 = node1.addPort(new DefaultPortModel(false, "out-1", "Out"));
node1.x = 100;
node1.y = 100;

//3-B) create another default node
var node2 = new DefaultNodeModel("Node 2", "rgb(192,255,0)");
var port2 = node2.addPort(new DefaultPortModel(true, "in-1", "IN"));
node2.x = 400;
node2.y = 100;

//3-C) link the 2 nodes together
var link1 = new LinkModel();
link1.setSourcePort(port1);
link1.setTargetPort(port2);

//4) add the models to the root graph
model.addNode(node1);
model.addNode(node2);
model.addLink(link1);

//5) load model into engine
engine.setDiagramModel(model);

class SandboxPage extends Component {
  render() {
    return (
      <div>
        <DiagramWidget diagramEngine={engine} />
      </div>
    );
  }
}

export default SandboxPage;

But the page renders like this: image

I pretty much copied the code from the simple demo example, but obviously, something is wrong.

Any help would be appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
mahesh-gorlacommented, Apr 2, 2020

import “@projectstorm/react-diagrams/dist/style.min.css”; is not working for the latest update, can anyone help me on it.

4reactions
matt-erhartcommented, Dec 13, 2018
// in './diagram.css';
.srd-diagram {
    height: 100vh;
}

then

import 'storm-react-diagrams/dist/style.min.css';
import './diagram.css';

but then the links only show on hover.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SAMHSA's National Helpline
Created for family members of people with alcohol abuse or drug abuse problems. Answers questions about substance abuse, its symptoms, different ...
Read more >
Signs you may be struggling to cope - Samaritans
Struggling to cope with everyday life doesn't look or feel the same in everyone. We can't generalise about how it'll make you feel...
Read more >
I Am Struggling - Please Live
What if you're struggling day in and day out and you don't really know why? If you're feeling this way, chances are you...
Read more >
10 Things to Remember When You're Struggling & Feel Stuck
1. The problem is a symptom of something else. · 2. You are never alone. · 3. You can overcome. · 4. People...
Read more >
What to do When You're Struggling Mentally
Talk to Someone You Trust. If you're struggling mentally, it's important to reach out for help. · Exercise and Eat Healthy. It's no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found