Skip to content

Commit 99015f4

Browse files
committed
fix: correlation table lag rendering
1 parent f8a2795 commit 99015f4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/data/correlationUtils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @returns string
55
*/
66
export function lagToOffset(lag, wrapped = true) {
7-
const wrap = wrapped ? (v) => ` (${v})` : (v) => ` ${v}`;
7+
const wrap = wrapped === 'zero' ? String : wrapped ? (v) => ` (${v})` : (v) => ` ${v}`;
88
if (lag === 1) {
99
return wrap('1 day later');
1010
}
@@ -17,5 +17,8 @@ export function lagToOffset(lag, wrapped = true) {
1717
if (lag < -1) {
1818
return wrap(`${-lag} days earlier`);
1919
}
20+
if (wrapped === 'zero') {
21+
return '0 days';
22+
}
2023
return '';
2124
}

src/modes/mobile/IndicatorCorrelation.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { modeByID } from '..';
44
import { sensorList, currentMode, currentSensor2 } from '../../stores';
55
import { scrollToTop } from '../../util';
6-
import { generateCorrelationMetrics } from '../../data/correlation';
6+
import { generateCorrelationMetrics, lagToOffset } from '../../data/correlation';
77
import { formatRawValue } from '../../formats';
88
import FancyHeader from './FancyHeader.svelte';
99
import SortColumnIndicator from './components/SortColumnIndicator.svelte';
@@ -165,7 +165,7 @@
165165
{:then m}
166166
<td class="uk-text-right">{formatRawValue(m.r2At0)}</td>
167167
<td class="uk-text-right">{formatRawValue(m.r2AtMaxR2)}</td>
168-
<td class="uk-text-right">{m.lagAtMaxR2.toLocaleString()} days</td>
168+
<td class="uk-text-right">{lagToOffset(m.lagAtMaxR2, 'zero')}</td>
169169
{:catch err}
170170
<td colspan="3" class="small">{err.message}</td>
171171
{/await}

0 commit comments

Comments
 (0)