Skip to content

Commit 2266b66

Browse files
author
Sean Connole
committed
fix: update x scales time unit
1 parent 5ca40be commit 2266b66

File tree

7 files changed

+74
-22
lines changed

7 files changed

+74
-22
lines changed

public/build/assets/cachet-BXLEFZKk.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/assets/cachet-D0qURpuI.js

+49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/assets/cachet-DCZQ8JcZ.js

-18
This file was deleted.

public/build/assets/cachet-Df9g2n5M.css

-1
This file was deleted.

public/build/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"resources/css/cachet.css": {
3-
"file": "assets/cachet-Df9g2n5M.css",
3+
"file": "assets/cachet-BXLEFZKk.css",
44
"src": "resources/css/cachet.css",
55
"isEntry": true
66
},
@@ -10,7 +10,7 @@
1010
"isEntry": true
1111
},
1212
"resources/js/cachet.js": {
13-
"file": "assets/cachet-DCZQ8JcZ.js",
13+
"file": "assets/cachet-D0qURpuI.js",
1414
"name": "cachet",
1515
"src": "resources/js/cachet.js",
1616
"isEntry": true

resources/views/components/metrics.blade.php

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
const previous7Days = new Date(now - 7 * 24 * 60 * 60 * 1000)
66
const previous30Days = new Date(now - 30 * 24 * 60 * 60 * 1000)
77
8+
const MetricView = {{
9+
Js::from([
10+
'last_hour' => \Cachet\Enums\MetricViewEnum::last_hour->value,
11+
'today' => \Cachet\Enums\MetricViewEnum::today->value,
12+
'week' => \Cachet\Enums\MetricViewEnum::week->value,
13+
'month' => \Cachet\Enums\MetricViewEnum::month->value,
14+
])
15+
}}
16+
817
function init() {
918
// Parse metric points
1019
const metricPoints = this.metric.metric_points.map((point) => {
@@ -45,8 +54,18 @@ function init() {
4554
4655
this.$watch('period', () => {
4756
chart.data.datasets[0].data = this.points[this.period]
57+
chart.options.scales.x.time.unit = getTimeUnit(this.period)
58+
4859
chart.update()
4960
})
61+
62+
function getTimeUnit(period) {
63+
if (period == MetricView.last_hour) return 'minute'
64+
if (period == MetricView.today) return 'hour'
65+
if (period == MetricView.week) return 'week'
66+
if (period == MetricView.month) return 'month'
67+
return 'day'
68+
}
5069
}
5170
</script>
5271

src/View/Components/Metrics.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function render(): View
2626
// Convert each metric point to Chart.js format (x, y)
2727
$metrics->each(function ($metric) {
2828
$metric->metricPoints->transform(fn ($point) => [
29-
'x' => $point->created_at->toIso8601String(),
29+
'x' => $point->created_at->utc(),
3030
'y' => $point->value,
3131
]);
3232
});
@@ -45,6 +45,8 @@ private function metrics(Carbon $startDate): Collection
4545
->with([
4646
'metricPoints' => fn ($query) => $query->orderBy('created_at'),
4747
])
48+
->where('display_chart', '=', 1)
49+
->where('visible', '=', 1)
4850
->where('visible', '>=', !auth()->check())
4951
->whereHas('metricPoints', fn (Builder $query) => $query->where('created_at', '>=', $startDate))
5052
->orderBy('places', 'asc')

0 commit comments

Comments
 (0)