@@ -877,28 +877,31 @@ function mouseOnActionTouch(event, actionVar) {
877877// }
878878
879879function takeDataSnapshot ( resourceValue , currentTime ) {
880+ if ( currentTime <= 1 ) return ;
880881 if ( chartData . length === 0 ) {
881882 chartData . push ( {
882883 time : currentTime ,
883- value : resourceValue
884+ value : resourceValue ,
885+ HATL : data . actions [ "hearAboutTheLich" ] . level ,
886+ MQ : actionData . awakenYourGrimoire . manaQuality ( )
884887 } ) ;
885888 return ;
886889 }
887890
888891 const lastStoredPoint = chartData [ chartData . length - 1 ] ;
889- if ( resourceValue === lastStoredPoint . value ) {
890- return ;
891- }
892+ // if (resourceValue === lastStoredPoint.value) {
893+ // return;
894+ // }
892895
893- const lastValue = lastStoredPoint . value ;
894- const timeBeforeChange = currentTime - 1 ;
895-
896- if ( timeBeforeChange > lastStoredPoint . time ) {
897- chartData . push ( { time : timeBeforeChange , value : lastValue } ) ;
896+ if ( ( currentTime - lastStoredPoint . time ) > ( currentTime > 21600 ? 239 : 119 ) ) {
897+ chartData . push ( {
898+ time : currentTime ,
899+ value : resourceValue ,
900+ HATL : data . actions [ "hearAboutTheLich" ] . level ,
901+ MQ : actionData . awakenYourGrimoire . manaQuality ( )
902+ } ) ;
898903 }
899904
900- chartData . push ( { time : currentTime , value : resourceValue } ) ;
901-
902905 if ( chartData . length > 200 ) {
903906 chartData . splice ( 0 , 2 ) ;
904907 }
@@ -919,10 +922,11 @@ function drawChart() {
919922
920923 const canvasWidth = canvas . clientWidth ;
921924 const canvasHeight = canvas . clientHeight ;
922- const padding = 40 ;
925+ const padding = 50 ;
923926
924927 // Clear the canvas and fill with dark background
925928 ctx . fillStyle = '#2d3748' ;
929+ ctx . globalAlpha = 1 ;
926930 ctx . fillRect ( 0 , 0 , canvas . width , canvas . height ) ;
927931
928932 if ( chartData . length < 2 ) {
@@ -936,8 +940,6 @@ function drawChart() {
936940 // --- Determine Data Range ---
937941 const minTime = chartData [ 0 ] . time ;
938942 const maxTime = chartData [ chartData . length - 1 ] . time ;
939- const values = chartData . map ( d => d . value ) ;
940- const maxValue = Math . max ( ...values ) ;
941943
942944 // --- Draw Axes ---
943945 ctx . strokeStyle = '#4a5568' ; // Subtle gray for axes
@@ -951,53 +953,122 @@ function drawChart() {
951953 ctx . lineTo ( canvasWidth - padding , canvasHeight - padding ) ;
952954 ctx . stroke ( ) ;
953955
956+ ctx . fillStyle = '#a0aec0' ; // Light gray for labels
957+ ctx . font = '12px sans-serif' ;
958+ ctx . textAlign = 'center' ;
954959 // --- Draw Data Line ---
955960 ctx . strokeStyle = '#63b3ed' ; // Vibrant, contrasting blue for the line
956961 ctx . lineWidth = 3 ; // Thicker line
957962 ctx . lineJoin = 'round' ; // Smoother corners
958963 ctx . beginPath ( ) ;
959964
960- for ( let i = 0 ; i < chartData . length ; i ++ ) {
961- const dataPoint = chartData [ i ] ;
962- const x = padding + ( ( dataPoint . time - minTime ) / ( maxTime - minTime ) ) * ( canvasWidth - 2 * padding ) ;
963- let y ;
964- if ( chartScale === 'logarithmic' ) {
965+ let lastLabelX = - 1000 ;
966+ let lastHATL = 0 ;
967+ if ( graphType === "momentum" ) {
968+ const values = chartData . map ( d => d . value ) ;
969+ const minValue = Math . min ( ...values ) ;
970+ const maxValue = Math . max ( ...values ) ;
971+ for ( let i = 0 ; i < chartData . length ; i ++ ) {
972+ const dataPoint = chartData [ i ] ;
973+ const HATL = dataPoint . HATL ? dataPoint . HATL : 0 ;
974+ const x = padding + ( ( dataPoint . time - minTime ) / ( maxTime - minTime ) ) * ( canvasWidth - 2 * padding ) ;
975+ if ( ( x - lastLabelX ) >= ( ( canvasWidth - 2 * padding ) / 8 ) ) {
976+ lastLabelX = x ;
977+ ctx . fillStyle = '#a0aec0' ; // Light gray for labels
978+ ctx . font = '12px sans-serif' ;
979+ ctx . fillText ( secondsToTime ( dataPoint . time ) , x , canvasHeight - padding + 20 ) ;
980+ }
981+ const logMinValue = Math . log1p ( minValue ) ;
965982 const logMaxValue = Math . log1p ( maxValue ) ;
966- const logValue = Math . log1p ( dataPoint . value ) ;
967- y = ( canvasHeight - padding ) - ( ( logValue / logMaxValue ) * ( canvasHeight - 2 * padding ) ) ;
968- } else {
969- y = ( canvasHeight - padding ) - ( ( dataPoint . value / maxValue ) * ( canvasHeight - 2 * padding ) ) ;
983+ const logValue = Math . log1p ( dataPoint . value ) - logMinValue ;
984+ let y = ( canvasHeight - padding ) - ( ( logValue / ( logMaxValue - logMinValue ) ) * ( canvasHeight - 2 * padding ) ) ;
985+ if ( isNaN ( y ) ) y = canvasHeight - padding ;
986+ if ( HATL > 0 && HATL > lastHATL ) {
987+ lastHATL = HATL ;
988+ ctx . fillStyle = 'red' ; // Light gray for labels
989+ ctx . font = '14px sans-serif bold' ;
990+ ctx . fillText ( HATL , x , y - 4 ) ;
991+ if ( y < ( canvasHeight - padding - 10 ) ) {
992+ ctx . fillStyle = '#a0aec0' ; // Light gray for labels
993+ ctx . font = '12px sans-serif' ;
994+ ctx . fillText ( secondsToTime ( dataPoint . time ) , x , y + 18 ) ;
995+ }
996+ }
997+ if ( i === 0 ) ctx . moveTo ( x , y ) ;
998+ else ctx . lineTo ( x , y ) ;
970999 }
971- if ( isNaN ( y ) ) y = canvasHeight - padding ;
972- if ( i === 0 ) ctx . moveTo ( x , y ) ;
973- else ctx . lineTo ( x , y ) ;
974- }
975- ctx . stroke ( ) ;
1000+ ctx . stroke ( ) ;
9761001
977- // --- Draw Labels and Grid ---
978- ctx . fillStyle = '#a0aec0' ; // Light gray for labels
979- ctx . font = '12px sans-serif' ;
980- ctx . textAlign = 'center' ;
981- const numYLabels = 5 ;
982- for ( let i = 0 ; i <= numYLabels ; i ++ ) {
983- const yPos = padding + ( i / numYLabels ) * ( canvasHeight - 2 * padding ) ;
984- let labelValue ;
985- if ( chartScale === 'logarithmic' ) {
986- labelValue = Math . expm1 ( Math . log1p ( maxValue ) * ( 1 - ( i / numYLabels ) ) ) ;
987- } else {
988- labelValue = maxValue * ( 1 - ( i / numYLabels ) ) ;
1002+ // --- Draw Labels and Grid ---
1003+ ctx . fillStyle = '#a0aec0' ; // Light gray for labels
1004+ ctx . font = '12px sans-serif' ;
1005+ const numYLabels = 5 ;
1006+ for ( let i = 0 ; i <= numYLabels ; i ++ ) {
1007+ const yPos = padding + ( i / numYLabels ) * ( canvasHeight - 2 * padding ) ;
1008+ const labelValue = Math . expm1 ( ( Math . log1p ( maxValue ) - Math . log1p ( minValue ) ) * ( 1 - ( i / numYLabels ) ) + Math . log1p ( minValue ) ) ;
1009+ ctx . globalAlpha = 1 ;
1010+ ctx . fillText ( intToString ( labelValue , 1 ) , padding - 20 , yPos + 4 ) ;
1011+
1012+ // Horizontal grid line
1013+ ctx . strokeStyle = '#4a5568' ; // Subtle gray for grid
1014+ ctx . globalAlpha = 0.25 ;
1015+ ctx . beginPath ( ) ;
1016+ ctx . moveTo ( padding , yPos ) ;
1017+ ctx . lineTo ( canvasWidth - padding , yPos ) ;
1018+ ctx . stroke ( ) ;
1019+ }
1020+ } else {
1021+ // Magic Quality graph
1022+ const values = chartData . map ( d => d . MQ ) ;
1023+ const minValue = Math . min ( ...values ) ;
1024+ const maxValue = Math . max ( ...values ) ;
1025+ for ( let i = 0 ; i < chartData . length ; i ++ ) {
1026+ const dataPoint = chartData [ i ] ;
1027+ const HATL = dataPoint . HATL ? dataPoint . HATL : 0 ;
1028+ const x = padding + ( ( dataPoint . time - minTime ) / ( maxTime - minTime ) ) * ( canvasWidth - 2 * padding ) ;
1029+ if ( ( x - lastLabelX ) >= ( ( canvasWidth - 2 * padding ) / 8 ) ) {
1030+ lastLabelX = x ;
1031+ ctx . fillStyle = '#a0aec0' ; // Light gray for labels
1032+ ctx . font = '12px sans-serif' ;
1033+ ctx . fillText ( secondsToTime ( dataPoint . time ) , x , canvasHeight - padding + 20 ) ;
1034+ }
1035+ let y = ( canvasHeight - padding ) - ( ( dataPoint . MQ / maxValue ) * ( canvasHeight - 2 * padding ) ) ;
1036+ if ( isNaN ( y ) ) y = canvasHeight - padding ;
1037+ if ( HATL > 0 && HATL > lastHATL ) {
1038+ lastHATL = HATL ;
1039+ ctx . fillStyle = 'red' ; // Light gray for labels
1040+ ctx . font = '14px sans-serif bold' ;
1041+ ctx . fillText ( HATL , x , y - 4 ) ;
1042+ if ( y < ( canvasHeight - padding - 10 ) ) {
1043+ ctx . fillStyle = '#a0aec0' ; // Light gray for labels
1044+ ctx . font = '12px sans-serif' ;
1045+ ctx . fillText ( secondsToTime ( dataPoint . time ) , x , y + 18 ) ;
1046+ }
1047+ }
1048+ if ( i === 0 ) ctx . moveTo ( x , y ) ;
1049+ else ctx . lineTo ( x , y ) ;
9891050 }
990- ctx . fillText ( intToString ( labelValue , 1 ) , padding - 20 , yPos + 4 ) ;
991-
992- // Horizontal grid line
993- ctx . strokeStyle = '#4a5568' ; // Subtle gray for grid
994- ctx . beginPath ( ) ;
995- ctx . moveTo ( padding - 5 , yPos ) ;
996- ctx . lineTo ( canvasWidth - padding , yPos ) ;
9971051 ctx . stroke ( ) ;
1052+
1053+ // --- Draw Labels and Grid ---
1054+ ctx . fillStyle = '#a0aec0' ; // Light gray for labels
1055+ ctx . font = '12px sans-serif' ;
1056+ const numYLabels = 5 ;
1057+ for ( let i = 0 ; i <= numYLabels ; i ++ ) {
1058+ const yPos = padding + ( i / numYLabels ) * ( canvasHeight - 2 * padding ) ;
1059+ const labelValue = ( maxValue - minValue ) * ( 1 - ( i / numYLabels ) ) + minValue ;
1060+ ctx . globalAlpha = 1 ;
1061+ ctx . fillText ( intToString ( labelValue , 1 ) , padding - 20 , yPos + 4 ) ;
1062+
1063+ // Horizontal grid line
1064+ ctx . strokeStyle = '#4a5568' ; // Subtle gray for grid
1065+ ctx . globalAlpha = 0.25 ;
1066+ ctx . beginPath ( ) ;
1067+ ctx . moveTo ( padding , yPos ) ;
1068+ ctx . lineTo ( canvasWidth - padding , yPos ) ;
1069+ ctx . stroke ( ) ;
1070+ }
9981071 }
999- ctx . fillText ( secondsToTime ( minTime ) , padding , canvasHeight - padding + 20 ) ;
1000- ctx . fillText ( secondsToTime ( maxTime ) , canvasWidth - padding , canvasHeight - padding + 20 ) ;
10011072}
10021073
10031074function addLogMessage ( text , type ) {
0 commit comments