@@ -15,6 +15,10 @@ class NeoTestReport extends NeoReport {
1515 }
1616
1717
18+ /**
19+ * Convert the results of the Cypher query into an object that we can render on a map.
20+ * Also uses some nice math to determine the center of the map and zoom level to ensure everything is visible.
21+ */
1822 recomputeMapInformation ( ) {
1923 this . state . width = this . props . clientWidth - 50 ; //-90 + props.width * 105 - xShift * 0.5;
2024 this . state . height = - 145 + this . props . height * 100 ;
@@ -67,21 +71,17 @@ class NeoTestReport extends NeoReport {
6771 }
6872
6973
70-
71- render ( ) {
72- let rendered = super . render ( ) ;
73-
74- if ( rendered ) {
75- return rendered ;
76- }
77-
78- this . recomputeMapInformation ( ) ;
74+ /**
75+ * Creates the leaflet visualization to render in the report.
76+ */
77+ createMapVisualization ( ) {
7978 let colors = [ "#588c7e" , "#f2e394" , "#f2ae72" , "#d96459" , "#5b9aa0" , "#d6d4e0" , "#b8a9c9" , "#622569" , "#ddd5af" , "#d9ad7c" , "#a2836e" , "#674d3c" , "grey" ]
8079 let markers = ( this . state . nodesAndPositions ) ?
8180 this . state . nodesAndPositions . map ( i =>
8281 < Marker position = { i . pos }
8382 icon = { < div style = { { color : colors [ 0 ] } } > < Icon className = "close" > place</ Icon > </ div > } >
84- < Popup > < code > { Object . keys ( i . node ) . map ( key => < pre > { key + ": " + i . node [ key ] + "\n" } </ pre > ) } </ code > </ Popup >
83+ < Popup > < code > { Object . keys ( i . node ) . map ( key =>
84+ < pre > { key + ": " + i . node [ key ] + "\n" } </ pre > ) } </ code > </ Popup >
8585 </ Marker > ) : < div > </ div >
8686 let lines = < div > </ div > // [<Polyline key={0} positions={[this.state.pos1, this.state.pos2]} color={colors[0]}/>];
8787
@@ -103,6 +103,17 @@ class NeoTestReport extends NeoReport {
103103 { lines }
104104 </ MapContainer > ;
105105 }
106+
107+ render ( ) {
108+ let rendered = super . render ( ) ;
109+ if ( rendered ) {
110+ return rendered ;
111+ }
112+
113+ // TODO - do this on component initialization instead of on each render.
114+ this . recomputeMapInformation ( ) ;
115+ return this . createMapVisualization ( ) ;
116+ }
106117}
107118
108119export default ( NeoTestReport ) ;
0 commit comments