@@ -365,7 +365,7 @@ function calculateEdgeColors(outcomes: { [outcome: string]: number }): string {
365365 * @param edgeCounts - A dictionary tracking the total number of transitions between steps (edges).
366366 * @param totalNodeEdges - A dictionary of total transitions starting from a specific node.
367367 * @param threshold - Minimum thickness value to include an edge in the visualization.
368- * @param min_visits - Minimum number of visits an edge must have to be included in the graph.
368+ * @param minVisits - Minimum number of visits an edge must have to be included in the graph.
369369 * @param selectedSequence - The selected sequence of steps used to color the nodes.
370370 *
371371 * @param justTopSequence
@@ -378,7 +378,7 @@ export function generateDotString(
378378 edgeCounts : EdgeCounts [ 'edgeCounts' ] ,
379379 totalNodeEdges : EdgeCounts [ 'totalNodeEdges' ] ,
380380 threshold : number ,
381- min_visits : number ,
381+ minVisits : number ,
382382 selectedSequence : SequenceCount [ "sequence" ] ,
383383 justTopSequence : boolean ,
384384 totalVisits : { [ key : string ] : number } ,
@@ -404,37 +404,42 @@ export function generateDotString(
404404 const totalCount = totalNodeEdges [ currentStep ] || 0 ;
405405 const color = calculateColor ( rank , totalSteps ) ;
406406 const edgeColor = calculateEdgeColors ( outcomes ) ;
407- const node_tooltip = `Rank:\n\t\t ${ rank + 1 } \nColor:\n\t\t ${ color } ` ;
407+ const nodeTooltip = `Rank:\n\t\t ${ rank + 1 } \nColor:\n\t\t ${ color } \nTotal Students:\n\t\t ${ totalNodeEdges [ currentStep ] || 0 } ` ;
408408
409- dotString += ` "${ currentStep } " [rank=${ rank + 1 } , style=filled, fillcolor="${ color } ", tooltip="${ node_tooltip } "];\n` ;
409+ dotString += ` "${ currentStep } " [rank=${ rank + 1 } , style=filled, fillcolor="${ color } ", tooltip="${ nodeTooltip } "];\n` ;
410410
411- if ( edgeCount > min_visits ) {
412- let tooltip = `${ currentStep } to ${ nextStep } \n`
413- + `- Unique Students: \n\t\t ${ edgeCount } \n`
414- + `- Total Edge Visits: \n\t\t ${ visits } \n`
415- + `- Total Students at ${ currentStep } : \n\t\t${ totalNodeEdges [ currentStep ] || 0 } \n`
416- + `- Ratio: \n\t\t${ ( ( ratioEdges [ edgeKey ] || 0 ) * 100 ) . toFixed ( 2 ) } % of students at ${ currentStep } go to ${ nextStep } \n`
417- + `- Outcomes: \n\t\t ${ Object . entries ( outcomes ) . map ( ( [ outcome , count ] ) => `${ outcome } : ${ count } ` ) . join ( '\n\t\t ' ) } \n`
418- + `- Color Codes: \n\t\t Hex: ${ color } ` ;
411+ if ( edgeCount > minVisits ) {
412+ let tooltip = `${ currentStep } to ${ nextStep } \n\n`
413+ + `Student Statistics:\n`
414+ + `- Total Students at ${ currentStep } : \n\t\t${ totalCount } \n`
415+ + `- Unique Students on this path: \n\t\t ${ edgeCount } \n`
416+ + `- Total Edge Visits: \n\t\t ${ visits } \n` ;
419417
420418 // Add repeat visit information for all edges
421419 if ( repeatVisits [ edgeKey ] ) {
422420 const repeatCounts = Object . values ( repeatVisits [ edgeKey ] ) ;
423421 const studentsWithRepeats = repeatCounts . filter ( count => count > 1 ) . length ;
424422 const maxRepeats = Math . max ( ...repeatCounts ) ;
425- tooltip += `\n- Repeat Visits:\n\t\t ${ studentsWithRepeats } students visited this edge multiple times\n\t\t Maximum visits by a student: ${ maxRepeats } ` ;
423+ tooltip += `- Students who repeated this path: \n\t\t ${ studentsWithRepeats } \n`
424+ + `- Maximum visits by a student: \n\t\t ${ maxRepeats } \n` ;
426425 }
427426
427+ tooltip += `\nPath Statistics:\n`
428+ + `- Ratio: \n\t\t${ ( ( ratioEdges [ edgeKey ] || 0 ) * 100 ) . toFixed ( 2 ) } % of students at ${ currentStep } go to ${ nextStep } \n`
429+ + `- Outcomes: \n\t\t ${ Object . entries ( outcomes ) . map ( ( [ outcome , count ] ) => `${ outcome } : ${ count } ` ) . join ( '\n\t\t ' ) } \n`
430+ + `\nVisual Properties:\n`
431+ + `- Color: \n\t\t Hex: ${ color } \n` ;
432+
428433 dotString += ` "${ currentStep } " -> "${ nextStep } " [penwidth=${ thickness } , color="${ edgeColor } ", tooltip="${ tooltip } "];\n` ;
429434 }
430435 }
431436 } else {
432437 for ( let rank = 0 ; rank < totalSteps ; rank ++ ) {
433- const step = steps [ rank ] ;
438+ const currentStep = steps [ rank ] ;
434439 const color = calculateColor ( rank , totalSteps ) ;
435- const node_tooltip = `Rank:\n\t\t ${ rank + 1 } \nColor:\n\t\t ${ color } ` ;
440+ const nodeTooltip = `Rank:\n\t\t ${ rank + 1 } \nColor:\n\t\t ${ color } \nTotal Students:\n\t\t ${ totalNodeEdges [ currentStep ] || 0 } ` ;
436441
437- dotString += ` "${ step } " [rank=${ rank + 1 } , style=filled, fillcolor="${ color } ", tooltip="${ node_tooltip } "];\n` ;
442+ dotString += ` "${ currentStep } " [rank=${ rank + 1 } , style=filled, fillcolor="${ color } ", tooltip="${ nodeTooltip } "];\n` ;
438443 }
439444
440445 for ( const edge of Object . keys ( normalizedThicknesses ) ) {
@@ -450,25 +455,31 @@ export function generateDotString(
450455 . map ( ( [ outcome , count ] ) => `${ outcome } : ${ count } ` )
451456 . join ( '\n\t\t ' ) ;
452457
453- if ( edgeCount > min_visits ) {
454- let tooltip = `- Total Students at ${ currentStep } : \n\t\t${ totalNodeEdges [ currentStep ] || 0 } \n\n`
455- + `${ currentStep } to ${ nextStep } \n`
456- + `- Unique Students on edge (each student only counted once): \n\t\t ${ edgeCount } \n`
457- + `- Edge taken ${ visits } times\n`
458- + `- Ratio: \n\t\t${ ( ( ratioEdges [ edge ] || 0 ) * 100 ) . toFixed ( 2 ) } % of students at ${ currentStep } go to ${ nextStep } \n`
459- + `- Outcomes: \n\t\t ${ outcomesStr } \n`
460- + `- Color Codes: \n\t\t Hex: ${ color } \n\t\t RGB: ${ [ parseInt ( color . substring ( 1 , 3 ) , 16 ) , parseInt ( color . substring ( 3 , 5 ) , 16 ) , parseInt ( color . substring ( 5 , 7 ) , 16 ) ] } ` ;
461-
462- // Add repeat visit information for all edges
463- if ( repeatVisits [ edge ] ) {
464- const repeatCounts = Object . values ( repeatVisits [ edge ] ) ;
465- const studentsWithRepeats = repeatCounts . filter ( count => count > 1 ) . length ;
466- const maxRepeats = Math . max ( ...repeatCounts ) ;
467- tooltip += `\n- Repeat Visits:\n\t\t ${ studentsWithRepeats } students visited this edge multiple times\n\t\t Maximum visits by a student: ${ maxRepeats } ` ;
458+ if ( edgeCount > minVisits ) {
459+ let tooltip = `${ currentStep } to ${ nextStep } \n\n`
460+ + `Student Statistics:\n`
461+ + `- Total Students at ${ currentStep } : \n\t\t${ totalCount || 0 } \n`
462+ + `- Unique Students on this path: \n\t\t ${ edgeCount } \n`
463+ + `- Total Edge Visits: \n\t\t ${ visits } \n` ;
464+
465+ // Add repeat visit information for all edges
466+ if ( repeatVisits [ edge ] ) {
467+ const repeatCounts = Object . values ( repeatVisits [ edge ] ) ;
468+ const studentsWithRepeats = repeatCounts . filter ( count => count > 1 ) . length ;
469+ const maxRepeats = Math . max ( ...repeatCounts ) ;
470+ tooltip += `- Students who repeated this path: \n\t\t ${ studentsWithRepeats } \n`
471+ + `- Maximum visits by a student: \n\t\t ${ maxRepeats } \n` ;
472+ }
473+
474+ tooltip += `\nPath Statistics:\n`
475+ + `- Ratio: \n\t\t${ ( ( ratioEdges [ edge ] || 0 ) * 100 ) . toFixed ( 2 ) } % of students at ${ currentStep } go to ${ nextStep } \n`
476+ + `- Outcomes: \n\t\t ${ outcomesStr } \n`
477+ + `\nVisual Properties:\n`
478+ + `- Color: \n\t\t Hex: ${ color } \n`
479+ + `\t\t RGB: ${ [ parseInt ( color . substring ( 1 , 3 ) , 16 ) , parseInt ( color . substring ( 3 , 5 ) , 16 ) , parseInt ( color . substring ( 5 , 7 ) , 16 ) ] } ` ;
480+
481+ dotString += ` "${ currentStep } " -> "${ nextStep } " [penwidth=${ thickness } , color="${ color } ", tooltip="${ tooltip } "];\n` ;
468482 }
469-
470- dotString += ` "${ currentStep } " -> "${ nextStep } " [penwidth=${ thickness } , color="${ color } ", tooltip="${ tooltip } "];\n` ;
471- }
472483 }
473484 }
474485 }
0 commit comments