Skip to content

Commit 9ba201b

Browse files
authored
Merge pull request #2724 from benderl/koala
Koala fixes
2 parents 85cd0ad + 166f2dc commit 9ba201b

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

  • packages/modules/web_themes/koala/source/src/components/charts/historyChart

packages/modules/web_themes/koala/source/src/components/charts/historyChart/HistoryChart.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,32 @@ const chartOptions = computed<ChartOptions<'line'>>(() => ({
289289
},
290290
},
291291
ticks: {
292-
maxTicksLimit: 12,
293-
source: 'auto' as const,
292+
maxTicksLimit: 40,
293+
source: 'data' as const,
294+
callback: (value) => {
295+
const formatTimestamp = (date: Date): string => {
296+
return date.toLocaleTimeString([], {
297+
hour: '2-digit',
298+
minute: '2-digit',
299+
});
300+
};
301+
// value is timestamp in ms
302+
const date = new Date(value as number);
303+
const minutes = date.getMinutes();
304+
const seconds = date.getSeconds();
305+
// only display rounded minutes
306+
if (seconds < 10) {
307+
if (chartRange.value <= 2700)
308+
// if chart range is 45min or less, show every minute
309+
// is limited by maxTicksLimit if too many points
310+
return formatTimestamp(date);
311+
if (minutes % 5 === 0) {
312+
// show every 5 minutes
313+
return formatTimestamp(date);
314+
}
315+
}
316+
return;
317+
},
294318
},
295319
grid: {
296320
tickLength: 5,

0 commit comments

Comments
 (0)