@@ -250,10 +250,18 @@ export default class WidgetApiMetricsComponent extends Component {
250250 after : this . chartDateStart . toISOString ( ) ,
251251 } )
252252 . then ( ( webhookRequestLogs ) => {
253- const data = webhookRequestLogs . toArray ( ) . map ( ( req ) => ( {
254- x : new Date ( req . created_at ) ,
255- y : ( req . duration || 0 ) * 1000 , // Convert seconds to milliseconds
256- } ) ) ;
253+ const records = webhookRequestLogs . toArray ( ) ;
254+ const data = records . map ( ( req ) => {
255+ // Duration is in seconds, convert to milliseconds
256+ const durationMs = parseFloat ( req . duration || 0 ) * 1000 ;
257+ return {
258+ x : new Date ( req . created_at ) ,
259+ y : durationMs ,
260+ } ;
261+ } ) ;
262+
263+ // Show points if we have sparse data
264+ const showPoints = records . length < 50 ;
257265
258266 resolve ( [
259267 {
@@ -264,9 +272,11 @@ export default class WidgetApiMetricsComponent extends Component {
264272 borderWidth : 3 ,
265273 fill : true ,
266274 tension : 0.4 ,
267- pointRadius : 2 ,
268- pointHoverRadius : 6 ,
275+ pointRadius : showPoints ? 3 : 0 ,
269276 pointBackgroundColor : 'rgb(168, 85, 247)' ,
277+ pointBorderColor : 'rgb(168, 85, 247)' ,
278+ pointBorderWidth : showPoints ? 2 : 0 ,
279+ pointHoverRadius : 6 ,
270280 pointHoverBackgroundColor : 'rgb(168, 85, 247)' ,
271281 pointHoverBorderColor : '#fff' ,
272282 pointHoverBorderWidth : 2 ,
@@ -296,6 +306,7 @@ export default class WidgetApiMetricsComponent extends Component {
296306 color : '#9CA3AF' ,
297307 usePointStyle : true ,
298308 pointStyleWidth : 8 ,
309+ boxHeight : 8 ,
299310 padding : 15 ,
300311 font : {
301312 size : 12 ,
@@ -315,6 +326,13 @@ export default class WidgetApiMetricsComponent extends Component {
315326 title : ( context ) => {
316327 return format ( new Date ( context [ 0 ] . parsed . x ) , 'MMM d, yyyy h:mm a' ) ;
317328 } ,
329+ label : ( context ) => {
330+ const value = context . parsed . y ;
331+ const label = context . dataset . label || '' ;
332+ // Format small values with decimals, large values as whole numbers
333+ const formattedValue = value < 10 ? value . toFixed ( 3 ) : Math . round ( value ) ;
334+ return `${ label } : ${ formattedValue } ` ;
335+ } ,
318336 } ,
319337 } ,
320338 } ,
@@ -346,7 +364,10 @@ export default class WidgetApiMetricsComponent extends Component {
346364 } ,
347365 ticks : {
348366 color : '#6B7280' ,
349- precision : 0 ,
367+ callback : function ( value ) {
368+ // Show decimals for small values (< 10), whole numbers for larger
369+ return value < 10 ? value . toFixed ( 2 ) : Math . round ( value ) ;
370+ } ,
350371 } ,
351372 } ,
352373 } ,
0 commit comments