diff --git a/client/src/App.js b/client/src/App.js index a973364..1eb6949 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -84,7 +84,27 @@ function useSensor(measurement, name, end, duration) { }; const isDST = end.tz('America/Edmonton').isDST(); - const tickFormatter = (timeStr) => memoConvertTZ(isDST, timeStr, duration.format); + + const labelMap = {}; + if (Array.isArray(data)) { + let lastLabel = null; + data.forEach(d => { + const lbl = memoConvertTZ(isDST, d.time, duration.format); + if (lbl !== lastLabel) { + labelMap[d.time] = lbl; + lastLabel = lbl; + } else { + labelMap[d.time] = ''; + } + }); + } + + const tickFormatter = (timeStr) => { + if (labelMap[timeStr] !== undefined) { + return labelMap[timeStr]; + } + return memoConvertTZ(isDST, timeStr, duration.format); + }; return [data, loading, tickFormatter]; }; @@ -712,7 +732,27 @@ function MultiLineChart({title, measurement, dataKey, sensors, colors, end, dura }; const isDST = end.tz('America/Edmonton').isDST(); - const tickFormatter = (timeStr) => memoConvertTZ(isDST, timeStr, duration.format); + + const labelMap = {}; + if (Array.isArray(data)) { + let lastLabel = null; + data.forEach(d => { + const lbl = memoConvertTZ(isDST, d.time, duration.format); + if (lbl !== lastLabel) { + labelMap[d.time] = lbl; + lastLabel = lbl; + } else { + labelMap[d.time] = ''; + } + }); + } + + const tickFormatter = (timeStr) => { + if (labelMap[timeStr] !== undefined) { + return labelMap[timeStr]; + } + return memoConvertTZ(isDST, timeStr, duration.format); + }; return (