Skip to content

Commit 0914f59

Browse files
Enable WebGL renderer in Cytoscape
1 parent b3693e2 commit 0914f59

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

src/common/CyWorkflow.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import CytoscapeComponent from "react-cytoscapejs";
1+
import CytoscapeComponent from "./CytoscapeComponentWebGl";
22
import Cytoscape from "cytoscape";
33
import { useEffect, useRef, MutableRefObject } from "react";
44
import { triggerDownload } from "../services/utils";
@@ -42,7 +42,8 @@ const GRAPH_STYLE = [
4242
style: {
4343
label: "data(id)",
4444
"text-valign": "top",
45-
"border-style": "dashed",
45+
"border-style": "solid",
46+
"background-opacity": 0.5,
4647
"text-margin-y": -8,
4748
"text-opacity": 0.75,
4849
"font-style": "italic",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import CytoscapeComponent from "react-cytoscapejs";
2+
import Cytoscape from "cytoscape";
3+
4+
class CytoscapeComponentWebGl extends CytoscapeComponent {
5+
componentDidMount() {
6+
const container = this.containerRef.current;
7+
8+
const {
9+
global,
10+
headless,
11+
styleEnabled,
12+
hideEdgesOnViewport,
13+
textureOnViewport,
14+
motionBlur,
15+
motionBlurOpacity,
16+
wheelSensitivity,
17+
pixelRatio,
18+
} = this.props;
19+
20+
const cy = (this._cy = new Cytoscape({
21+
container,
22+
headless,
23+
styleEnabled,
24+
hideEdgesOnViewport,
25+
textureOnViewport,
26+
motionBlur,
27+
motionBlurOpacity,
28+
wheelSensitivity,
29+
pixelRatio,
30+
renderer: {
31+
// Add WebGL renderer options
32+
name: "canvas",
33+
webgl: true, // turns on WebGL mode
34+
showFps: true, // (optional) shows the current FPS at the top-left
35+
webglDebug: true, // (optional) prints debug info to the browser console
36+
},
37+
}));
38+
39+
if (global) {
40+
window[global] = cy;
41+
}
42+
43+
this.updateCytoscape(null, this.props);
44+
}
45+
}
46+
47+
export default CytoscapeComponentWebGl;

0 commit comments

Comments
 (0)