Skip to content

Commit 70c9b69

Browse files
committed
Fix: Legend circles and webhook duration display
1. Added boxHeight: 8 to legend labels to make perfect circles (not ovals) 2. Fixed webhook duration conversion with parseFloat for accuracy 3. Updated Y-axis ticks to show decimals for values < 10ms 4. Added tooltip formatting to show 3 decimal places for small durations 5. Made duration points visible for sparse data (< 50 records)
1 parent 3a7a201 commit 70c9b69

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

addon/components/widget/api-metrics.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)