11// React component code
2- import React , { useContext , useEffect , useRef , useState } from 'react' ;
2+ import { FC , RefObject , useContext , useEffect , useRef , useState } from 'react' ;
33import { graphviz } from 'd3-graphviz' ;
44import {
55 generateDotString ,
@@ -21,12 +21,7 @@ interface GraphvizParentProps {
2121 minVisits : number ;
2222}
2323
24- const GraphvizParent : React . FC < GraphvizParentProps > = ( {
25- csvData,
26- filter,
27- selfLoops,
28- minVisits,
29- } ) => {
24+ const GraphvizParent : FC < GraphvizParentProps > = ( { csvData, filter, selfLoops, minVisits} ) => {
3025 const [ dotString , setDotString ] = useState < string | null > ( null ) ;
3126 const [ filteredDotString , setFilteredDotString ] = useState < string | null > ( null ) ;
3227 const [ topDotString , setTopDotString ] = useState < string | null > ( null ) ;
@@ -145,14 +140,14 @@ const GraphvizParent: React.FC<GraphvizParentProps> = ({
145140 . on ( 'end' , ( ) => {
146141 const svgElement = ref . current ?. querySelector ( 'svg' ) ;
147142 if ( svgElement ) {
148- exportGraphAsPNG ( svgElement , filename ) ;
143+ exportGraphAsPNG ( ref , filename ) ;
149144 }
150145 } ) ;
151146 }
152147 } ;
153148
154149 // Export a graph as high-quality PNG
155- const exportGraphAsPNG = ( graphRef : React . RefObject < HTMLDivElement > , filename : string ) => {
150+ const exportGraphAsPNG = ( graphRef : RefObject < HTMLDivElement > , filename : string ) => {
156151 if ( ! graphRef . current ) return ;
157152
158153 const svgElement = graphRef . current . querySelector ( 'svg' ) ;
@@ -215,8 +210,6 @@ const GraphvizParent: React.FC<GraphvizParentProps> = ({
215210 } , [ filteredDotString ] ) ;
216211
217212
218-
219-
220213 return (
221214 < div className = "graphviz-container flex-col w-[500px] items-center" >
222215 < ErrorBoundary >
0 commit comments