File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,56 @@ export default {
117117 } ) ;
118118
119119 // ======================== Per script name Per hour ========================
120+ // Stacked Bar Chart for each script
121+ const scriptNamePerHour_dataset = Array . from (
122+ scriptNameCount . keys ( )
123+ ) . map ( ( scriptName ) => {
124+ const data = Array ( 24 ) . fill ( 0 ) ;
125+ logData . forEach ( ( log ) => {
126+ let lastColon = log . lastIndexOf ( ":" ) ;
127+ let lastArrow = log . lastIndexOf ( "->" ) ;
128+ let scriptName_log = log . substring ( lastColon + 1 , lastArrow - 1 ) ;
129+ if ( scriptName_log === scriptName ) {
130+ let hour = extractTime ( log ) . getHours ( ) ;
131+ data [ hour ] ++ ;
132+ }
133+ } ) ;
134+ return {
135+ label : scriptName ,
136+ data,
137+ backgroundColor : `rgb(${ Math . floor (
138+ Math . random ( ) * 255
139+ ) } ,${ Math . floor ( Math . random ( ) * 255 ) } ,${ Math . floor (
140+ Math . random ( ) * 255
141+ ) } )`,
142+ } ;
143+ } ) ;
144+
145+ const canvas3 = document . createElement ( "canvas" ) ;
146+ canvas3 . style . cssText = "max-width: 900px; max-height: 300px;" ;
147+ document . body . prepend ( canvas3 ) ;
148+ const ctx3 = canvas3 . getContext ( "2d" ) ;
149+ const scriptNamePerHourChart = new Chart ( ctx3 , {
150+ type : "bar" ,
151+ data : {
152+ labels : Array . from ( { length : 24 } , ( _ , i ) => `${ i } :00` ) ,
153+ datasets : scriptNamePerHour_dataset ,
154+ } ,
155+ options : {
156+ interaction : {
157+ intersect : false ,
158+ } ,
159+ responsive : true ,
160+ scales : {
161+ x : {
162+ stacked : true ,
163+ } ,
164+ y : {
165+ stacked : true ,
166+ } ,
167+ } ,
168+ } ,
169+ } ) ;
120170 }
121171 ) ;
122172 } ) ( ) ;
You can’t perform that action at this time.
0 commit comments