Skip to content

Commit 036b5db

Browse files
committed
ui: air: make the grid show days if granularity > 1day
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 394935f commit 036b5db

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

ui/air.html

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,9 +1344,13 @@ <h3 style="margin-top: 40px;">Feedback Breakdown (36-hour rolling)</h3>
13441344
delete reviewChart.options.scales.y1;
13451345
}
13461346

1347+
reviewChart.options.scales.x.time.unit = bucketSize >= 24 ? 'day' : 'hour';
1348+
reviewChart.options.scales.x.time.stepSize = bucketSize >= 24 ? 1 : bucketSize;
1349+
reviewChart.options.scales.x.time.displayFormats = bucketSize >= 24 ? { day: 'MMM d' } : { hour: 'MMM d HH:mm' };
13471350
reviewChart.update();
13481351
} else {
13491352
// Create new chart
1353+
const timeUnit = bucketSize >= 24 ? 'day' : 'hour';
13501354
const datasets = [
13511355
{
13521356
label: 'Completed',
@@ -1388,11 +1392,9 @@ <h3 style="margin-top: 40px;">Feedback Breakdown (36-hour rolling)</h3>
13881392
x: {
13891393
type: 'time',
13901394
time: {
1391-
unit: 'hour',
1392-
stepSize: 6,
1393-
displayFormats: {
1394-
hour: 'MMM d HH:mm'
1395-
}
1395+
unit: timeUnit,
1396+
stepSize: bucketSize >= 24 ? 1 : bucketSize,
1397+
displayFormats: bucketSize >= 24 ? { day: 'MMM d' } : { hour: 'MMM d HH:mm' }
13961398
},
13971399
grid: {
13981400
color: getComputedStyle(document.documentElement).getPropertyValue('--border-color')
@@ -1653,6 +1655,9 @@ <h3 style="margin-top: 40px;">Feedback Breakdown (36-hour rolling)</h3>
16531655
delete averagesChart.options.scales.y1;
16541656
}
16551657

1658+
averagesChart.options.scales.x.time.unit = bucketSize >= 24 ? 'day' : 'hour';
1659+
averagesChart.options.scales.x.time.stepSize = bucketSize >= 24 ? 1 : bucketSize;
1660+
averagesChart.options.scales.x.time.displayFormats = bucketSize >= 24 ? { day: 'MMM d' } : { hour: 'MMM d HH:mm' };
16561661
averagesChart.update();
16571662
} else {
16581663
// Create new chart
@@ -1710,10 +1715,9 @@ <h3 style="margin-top: 40px;">Feedback Breakdown (36-hour rolling)</h3>
17101715
x: {
17111716
type: 'time',
17121717
time: {
1713-
unit: 'day',
1714-
displayFormats: {
1715-
day: 'MMM d'
1716-
}
1718+
unit: bucketSize >= 24 ? 'day' : 'hour',
1719+
stepSize: bucketSize >= 24 ? 1 : bucketSize,
1720+
displayFormats: bucketSize >= 24 ? { day: 'MMM d' } : { hour: 'MMM d HH:mm' }
17171721
},
17181722
grid: {
17191723
color: getComputedStyle(document.documentElement).getPropertyValue('--border-color')
@@ -1831,6 +1835,9 @@ <h3 style="margin-top: 40px;">Feedback Breakdown (36-hour rolling)</h3>
18311835
if (volumeChart) {
18321836
volumeChart.data.datasets[0].data = submissionsData;
18331837
volumeChart.data.datasets[1].data = patchesData;
1838+
volumeChart.options.scales.x.time.unit = bucketSize >= 24 ? 'day' : 'hour';
1839+
volumeChart.options.scales.x.time.stepSize = bucketSize >= 24 ? 1 : bucketSize;
1840+
volumeChart.options.scales.x.time.displayFormats = bucketSize >= 24 ? { day: 'MMM d' } : { hour: 'MMM d HH:mm' };
18341841
volumeChart.update();
18351842
} else {
18361843
const textColor = getComputedStyle(document.documentElement).getPropertyValue('--text-primary');
@@ -1883,9 +1890,9 @@ <h3 style="margin-top: 40px;">Feedback Breakdown (36-hour rolling)</h3>
18831890
x: {
18841891
type: 'time',
18851892
time: {
1886-
unit: 'hour',
1887-
stepSize: 6,
1888-
displayFormats: { hour: 'MMM d HH:mm' }
1893+
unit: bucketSize >= 24 ? 'day' : 'hour',
1894+
stepSize: bucketSize >= 24 ? 1 : bucketSize,
1895+
displayFormats: bucketSize >= 24 ? { day: 'MMM d' } : { hour: 'MMM d HH:mm' }
18891896
},
18901897
grid: { color: borderColor },
18911898
ticks: { color: textColor }

0 commit comments

Comments
 (0)