मैं रीक्टजेएस के साथ साइटोस्केप का उपयोग करने की कोशिश कर रहा हूं और कुछ सरल घटक में कुछ भी प्रदर्शित नहीं हो रहा है, मैं कोशिश कर रहा हूं।साइटोसस्केप और रीएक्टजेएस एकीकरण
यहां कोड है। मैं mapStateToProps में एक खाली ऑब्जेक्ट लौट रहा हूं क्योंकि मैं एक स्थिर ग्राफ प्रदर्शित करने की कोशिश कर रहा हूं जहां मैंने किनारों और नोड्स को कड़ी मेहनत की है।
Cytoscape संस्करण मैं उपयोग कर रहा हूँ मेरी package.json से है
"cytoscape": "^ 2.7.6", "प्रतिक्रिया": "^ 15.2.1",
यहाँ Cyctoscape है jsbin मैं अपने नमूने के लिए उपयोग कर रहा हूँ।
किसी भी मदद की सराहना।
धन्यवाद
import React,{Component} from 'react';
import cytoscape from 'cytoscape';
import {connect} from 'react-redux';
import { bindActionCreators } from 'redux';
class GraphContainer extends React.Component{
constructor(props){
super(props);
this.renderCytoscapeElement = this.renderCytoscapeElement.bind(this);
}
renderCytoscapeElement(){
console.log('* Cytoscape.js is rendering the graph..');
this.cy = cytoscape(
{
container: document.getElementById('cy'),
boxSelectionEnabled: false,
autounselectify: true,
style: cytoscape.stylesheet()
.selector('node')
.css({
'height': 80,
'width': 80,
'background-fit': 'cover',
'border-color': '#000',
'border-width': 3,
'border-opacity': 0.5,
'content': 'data(name)',
'text-valign': 'center',
})
.selector('edge')
.css({
'width': 6,
'target-arrow-shape': 'triangle',
'line-color': '#ffaaaa',
'target-arrow-color': '#ffaaaa',
'curve-style': 'bezier'
})
,
elements: {
nodes: [
{ data: { id: 'cat' } },
{ data: { id: 'bird' } },
{ data: { id: 'ladybug' } },
{ data: { id: 'aphid' } },
{ data: { id: 'rose' } },
{ data: { id: 'grasshopper' } },
{ data: { id: 'plant' } },
{ data: { id: 'wheat' } }
],
edges: [
{ data: { source: 'cat', target: 'bird' } },
{ data: { source: 'bird', target: 'ladybug' } },
{ data: { source: 'bird', target: 'grasshopper' } },
{ data: { source: 'grasshopper', target: 'plant' } },
{ data: { source: 'grasshopper', target: 'wheat' } },
{ data: { source: 'ladybug', target: 'aphid' } },
{ data: { source: 'aphid', target: 'rose' } }
]
},
layout: {
name: 'breadthfirst',
directed: true,
padding: 10
}
});
}
componentDidMount(){
this.renderCytoscapeElement();
}
render(){
return(
<div className="node_selected">
<div id="cy"/>
</div>
)
}
}
function mapStateToProps(state){
return {};
}
export default connect(mapStateToProps,null)(GraphContainer);
यह काम करना चाहिए। कंसोल पर कुछ भी? यदि साइटोसस्केप पर कोई डिफ़ॉल्ट निर्यात नहीं है, तो आयात करें {cytoscape}। – vijayst
कंसोल में कोई त्रुटि नहीं। मैं कंसोल.लॉग को रेंडरस्केप एलीमेंट() से देख रहा हूं, इसलिए मुझे लगता है कि आयात में कुछ भी गलत नहीं है। जब मैंने अपने आयात को उस व्यक्ति के साथ बदल दिया जिस पर आपने सुझाव दिया था कि मुझे त्रुटि मिली है, तो मुझे ग्राफिकॉन्टेनर.जेएस त्रुटि मिली है: 24 अनकही टाइपरर: अपरिभाषित –