File tree Expand file tree Collapse file tree
packages/modules/web_themes/koala/source/src/components/charts/historyChart Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments