11import React , { useEffect } from 'react' ;
22import * as d3 from 'd3' ;
3+ import { modelOfInterestData } from "../../../dataStore" ;
34
45const ArcDiagram : React . FC = ( ) => {
56 useEffect ( ( ) => {
6- const githubRawUrl = 'https://raw.githubusercontent.com/Be-Secure/besecure-assets-store/main/models/model-metadata.json' ;
7-
87 // Fetch data from GitHub raw URL and save it into a variable as JSON
9- fetch ( githubRawUrl )
8+ fetch ( modelOfInterestData )
109 . then ( response => {
1110 if ( ! response . ok ) {
1211 throw new Error ( `Failed to fetch data. Status: ${ response . status } ` ) ;
@@ -31,14 +30,29 @@ const ArcDiagram: React.FC = () => {
3130 const jsonData = data ;
3231
3332 // Extract unique nodes and links from the JSON data
34- const nodes : { name : string , group : string } [ ] = [ ] ;
33+ const nodes : { name : string , group : string , color : string } [ ] = [ ] ;
3534 const links : { source : string , target : string } [ ] = [ ] ;
3635
36+ // get color
37+ function getColor ( type : string ) {
38+ if ( type === "Classic" ) {
39+ return "blue" ;
40+ } else {
41+ return "#EC5800" ;
42+ }
43+ }
3744 jsonData . forEach ( node => {
38- const mainNode = { name : node . name , group : node . group } ;
45+ const mainNode = { name : node . name , group : node . group , color : getColor ( node . type ) } ;
3946 nodes . push ( mainNode ) ;
4047 node . dependencies . forEach ( dependency => {
41- const dependentNode = { name : dependency , group : node . group } ;
48+ // check if the dependency tracked under BeS
49+ const trackedObj = jsonData . find ( item => item . name === dependency ) ;
50+ let dependentNode ;
51+ if ( trackedObj ) {
52+ dependentNode = { name : dependency , group : node . group , color : getColor ( trackedObj . type ) } ;
53+ } else {
54+ dependentNode = { name : dependency , group : node . group , color : "currentColor" } ;
55+ }
4256 nodes . push ( dependentNode ) ;
4357 links . push ( { source : mainNode . name , target : dependentNode . name } ) ;
4458 } ) ;
@@ -92,7 +106,7 @@ const ArcDiagram: React.FC = () => {
92106 . attr ( "cx" , ( d : { name : string , x : number | undefined } ) => d . x !== undefined ? d . x : 0 ) // Explicitly provide type information
93107 . attr ( "cy" , height - 30 )
94108 . attr ( "r" , 8 )
95- . style ( "fill" , d => color ( d . name ) as string )
109+ . style ( "fill" , d => d . color )
96110 . attr ( "stroke" , "white" )
97111 . on ( 'click' , ( event , d ) => {
98112 if ( isClickable ( d . name ) && ! event . active ) {
@@ -202,7 +216,27 @@ const ArcDiagram: React.FC = () => {
202216 } , [ ] ) ; // Empty dependency array ensures useEffect runs once on component mount
203217
204218 return (
205- < div id = "Arc_diagram" > </ div >
219+ < div >
220+ < div id = "indicator" style = { { position : "absolute" , top : "0" , right : "0" , margin : "20px" , marginTop : "70px" } } >
221+ < div className = "container" style = { { display : "flex" , alignItems : "center" , marginBottom : "2px" , marginTop : "17px" } } >
222+ < div className = "circle model" style = { { backgroundColor : "blue" , width : "10px" , height : "10px" , borderRadius : "50%" , marginRight : "5px" , marginLeft : "20px" } } > </ div >
223+ < p style = { { fontSize : "13px" } } > Classic (Model)</ p >
224+ </ div >
225+
226+ < div className = "container" style = { { display : "flex" , alignItems : "center" , marginBottom : "5px" , marginTop : "2px" } } >
227+ < div className = "circle dependency" style = { { backgroundColor : "#EC5800" , width : "10px" , height : "10px" , borderRadius : "50%" , marginRight : "5px" , marginLeft : "20px" } } > </ div >
228+ < p style = { { fontSize : "13px" } } > LLM (Model)</ p >
229+ </ div >
230+
231+ < div className = "container" style = { { display : "flex" , alignItems : "center" , marginBottom : "5px" , marginTop : "2px" } } >
232+ < div className = "circle dependency" style = { { backgroundColor : "currentColor" , width : "10px" , height : "10px" , borderRadius : "50%" , marginRight : "5px" , marginLeft : "20px" } } > </ div >
233+ < p style = { { fontSize : "13px" } } > Not Tracked</ p >
234+ </ div >
235+ </ div >
236+ < div id = "Arc_diagram" >
237+ { /* Your graph content goes here */ }
238+ </ div >
239+ </ div >
206240 ) ;
207241}
208242
0 commit comments