@@ -31,7 +31,7 @@ import chartAnnotation, {
3131 type LabelOptions ,
3232} from "chartjs-plugin-annotation" ;
3333import chartTrendline from "chartjs-plugin-trendline" ;
34-
34+ import { get as getTypingSpeedUnit } from "../utils/typing-speed-units" ;
3535import * as ActivePage from "../states/active-page" ;
3636
3737Chart . register (
@@ -299,6 +299,9 @@ export type ActivityChartDataPoint = {
299299 x : number ;
300300 y : number ;
301301 amount ?: number ;
302+ avgWpm ?: number ;
303+ avgAcc ?: number ;
304+ avgCon ?: number ;
302305} ;
303306
304307export const accountHistory = new ChartWithUpdateColors <
@@ -695,6 +698,9 @@ export const accountActivity = new ChartWithUpdateColors<
695698 animation : { duration : 250 } ,
696699 intersect : false ,
697700 mode : "index" ,
701+ filter : ( tooltipItem ) : boolean => {
702+ return tooltipItem . datasetIndex === 0 ;
703+ } ,
698704 callbacks : {
699705 title : function ( tooltipItem ) : string {
700706 const firstItem = tooltipItem [ 0 ] as TooltipItem < "bar" | "line" > ;
@@ -707,20 +713,22 @@ export const accountActivity = new ChartWithUpdateColors<
707713 const resultData = tooltipItem . dataset . data [
708714 tooltipItem . dataIndex
709715 ] as ActivityChartDataPoint ;
710- switch ( tooltipItem . datasetIndex ) {
711- case 0 :
712- return `Time Typing: ${ DateTime . secondsToString (
713- Math . round ( resultData . y * 60 ) ,
714- true ,
715- true
716- ) } \nTests Completed: ${ resultData . amount } `;
717- case 1 :
718- return `Average ${ Config . typingSpeedUnit } : ${ Numbers . roundTo2 (
719- resultData . y
720- ) } `;
721- default :
722- return "" ;
723- }
716+ const typingSpeedUnit = getTypingSpeedUnit (
717+ Config . typingSpeedUnit
718+ ) ;
719+ return `Time Typing: ${ DateTime . secondsToString (
720+ Math . round ( resultData . y * 60 ) ,
721+ true ,
722+ true
723+ ) } \nTests Completed: ${
724+ resultData . amount
725+ } \nAverage ${ Config . typingSpeedUnit . toUpperCase ( ) } : ${ Numbers . roundTo2 (
726+ typingSpeedUnit . fromWpm ( resultData . avgWpm ?? 0 )
727+ ) } \nAverage Accuracy: ${ Numbers . roundTo2 (
728+ resultData . avgAcc ?? 0
729+ ) } %\nAverage Consistency: ${ Numbers . roundTo2 (
730+ resultData . avgCon ?? 0
731+ ) } %`;
724732 } ,
725733 label : function ( ) : string {
726734 return "" ;
0 commit comments