Skip to content

Commit d3bf3cb

Browse files
committed
Fix bug where live data shows wrong labels
1 parent bdacaec commit d3bf3cb

File tree

6 files changed

+38
-40
lines changed

6 files changed

+38
-40
lines changed

src/__tests__/archtest/default-build-config.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,4 @@ describe('Default build config test', () => {
3131
expect(windiContent.includes("secondary: '#2CCAC0'"), message).toBeFalsy();
3232
expect(features.title, message).toBe('Learning tool');
3333
});
34-
35-
test("deleteme pls", () => {
36-
// TODO: Remember to add feature flag for fingerprint!
37-
expect(true).toBeFalsy();
38-
});
3934
});

src/components/features/bottom/BottomPanel.svelte

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import StandardButton from '../../ui/buttons/StandardButton.svelte';
1919
import { stores } from '../../../lib/stores/Stores';
2020
import LiveDataFingerprint from './LiveDataFingerprint.svelte';
21+
import { Feature, hasFeature } from '../../../lib/FeatureToggles';
2122
2223
const devices = stores.getDevices();
2324
@@ -79,16 +80,20 @@
7980
onOutputDisconnectButtonClicked={outputDisconnectButtonClicked} />
8081
</div>
8182
</div>
83+
8284
<div
8385
class="absolute right-0 cursor-pointer w-45 hover:bg-secondary hover:bg-opacity-10 transition"
8486
on:click={() => (isLive3DOpen = true)}>
8587
<div class="flex flex-row">
86-
<div class="absolute h-full">
87-
<LiveDataFingerprint gestureName="Live" />
88-
</div>
88+
{#if hasFeature(Feature.FINGERPRINT)}
89+
<div class="absolute h-full">
90+
<LiveDataFingerprint gestureName="Live" />
91+
</div>
92+
{/if}
8993
<View3DLive width={160} height={160} freeze={isLive3DOpen} />
9094
</div>
9195
</div>
96+
9297
<BaseDialog isOpen={isLive3DOpen} onClose={() => (isLive3DOpen = false)}>
9398
<!-- hardcoded margin-left matches the size of the sidebar -->
9499
<div

src/components/features/bottom/LiveDataFingerprint.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import { ClassifierInput } from '../../../lib/domain/ClassifierInput';
99
import { stores } from '../../../lib/stores/Stores';
1010
import StaticConfiguration from '../../../StaticConfiguration';
11-
import StandardButton from '../../ui/buttons/StandardButton.svelte';
1211
import Fingerprint from '../../ui/recording/Fingerprint.svelte';
1312
1413
export let gestureName: string;
@@ -20,7 +19,7 @@
2019
2120
$: filtersLabels = $filters.flatMap(filter => {
2221
const filterName = filter.getName();
23-
return [`${filterName} - x`, `${filterName} - y`, `${filterName} - z`];
22+
return $highlightedAxes.map(axis => `${filterName} - ${axis.label}`);
2423
});
2524
// $: fingerprint = $classifier.filteredInput.normalized.getValue();
2625
onMount(() => {

src/components/ui/recording/Fingerprint.svelte

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@
44
SPDX-License-Identifier: MIT
55
-->
66
<script lang="ts">
7-
import { stores } from "../../../lib/stores/Stores";
8-
import { onDestroy } from "svelte";
7+
import { onDestroy } from 'svelte';
98
109
export let fingerprint: number[];
1110
export let title: string;
1211
export let filterLabels: string[];
1312
1413
// Tooltip state
1514
let tooltipVisible = false;
16-
let tooltipLabel = "";
15+
let tooltipLabel = '';
1716
let tooltipIndex = 0;
1817
let tooltipValue = 0;
1918
let containerElement: HTMLDivElement;
2019
let tooltipX = 0;
2120
let tooltipXOffset = -80;
2221
let tooltipY = 0;
23-
let tooltipYOffset = -60;
22+
let tooltipYOffset = -85;
2423
let tooltipInterval: NodeJS.Timeout | null = null;
2524
2625
// Function to convert value (0-1) to viridis-like color
@@ -61,16 +60,16 @@
6160
tooltipLabel = filterLabels[index] || `Cell ${index}`;
6261
tooltipIndex = index;
6362
tooltipValue = value;
64-
63+
6564
// Calculate fixed position relative to the visualization container
6665
if (containerElement) {
6766
const rect = containerElement.getBoundingClientRect();
6867
tooltipX = rect.right + tooltipXOffset; // Position near the right edge of the container
6968
tooltipY = rect.top + tooltipYOffset; // Position near the top of the container
7069
}
71-
70+
7271
tooltipVisible = true;
73-
72+
7473
// Start polling the value every 200ms
7574
if (tooltipInterval) {
7675
clearInterval(tooltipInterval);
@@ -84,7 +83,7 @@
8483
8584
const hideTooltip = () => {
8685
tooltipVisible = false;
87-
86+
8887
// Clear the polling interval
8988
if (tooltipInterval) {
9089
clearInterval(tooltipInterval);
@@ -103,23 +102,24 @@
103102
<div class="flex flex-col font-sans w-full h-full" bind:this={containerElement}>
104103
<div class="flex flex-col border border-gray-300 flex-1">
105104
{#each fingerprint as value, index}
106-
<div
107-
class="border-b border-white border-opacity-10 transition-opacity duration-200 hover:opacity-80 cursor-pointer last:border-b-0 flex-1"
108-
style="background-color: {getViridisColor(value)};"
109-
on:mouseenter={() => showTooltip(index, value)}
110-
on:mouseleave={hideTooltip}
111-
on:click|stopPropagation
112-
role="button"
113-
tabindex="0"/>
105+
<div
106+
class="border-b border-white border-opacity-10 transition-opacity duration-200 hover:opacity-80 cursor-pointer last:border-b-0 flex-1"
107+
style="background-color: {getViridisColor(value)};"
108+
on:mouseenter={() => showTooltip(index, value)}
109+
on:mouseleave={hideTooltip}
110+
on:click|stopPropagation
111+
role="button"
112+
tabindex="0" />
114113
{/each}
115114
</div>
116115
</div>
117116

118117
<!-- Fixed tooltip positioned globally but relative to the visualization -->
119118
{#if tooltipVisible}
120-
<div
119+
<div
121120
class="fixed bg-white shadow-md text-primarytext text-sm px-3 py-2 rounded z-50 pointer-events-none whitespace-nowrap"
122121
style="left: {tooltipX}px; top: {tooltipY}px;">
122+
<div class="font-semibold text-md">{title}</div>
123123
<div class="font-semibold">{tooltipLabel}</div>
124124
<div>Value: {tooltipValue.toFixed(3)}</div>
125125
</div>

src/components/ui/recording/Recording.svelte

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import { serializeRecordingToCsvWithoutGestureName } from '../../../lib/utils/CSVUtils';
1616
import RecordingFingerprint from './RecordingFingerprint.svelte';
1717
import { Feature, hasFeature } from '../../../lib/FeatureToggles';
18-
import { tr } from '../../../i18n';
18+
import { tr } from '../../../i18n';
1919
2020
// get recording from mother prop
2121
export let recording: RecordingData;
@@ -96,23 +96,23 @@
9696
{/if}
9797
</div>
9898
{/if}
99-
<Tooltip title={$tr("content.data.tooltip.remove")} offset={{ x: -26, y: -50 }}>
100-
<button class="absolute -left-2.8px top-0px outline-none">
101-
<div class="relative">
102-
<i class="z-1 absolute fas fa-circle fa-lg text-white" />
103-
<i
104-
class="z-2 absolute far fa-times-circle fa-lg transition
99+
<Tooltip title={$tr('content.data.tooltip.remove')} offset={{ x: -26, y: -50 }}>
100+
<button class="absolute -left-2.8px top-0px outline-none">
101+
<div class="relative">
102+
<i class="z-1 absolute fas fa-circle fa-lg text-white" />
103+
<i
104+
class="z-2 absolute far fa-times-circle fa-lg transition
105105
ease cursor-pointer text-light-800 hover:text-black"
106-
on:click={deleteClicked} />
107-
</div>
108-
</button>
109-
</Tooltip>
106+
on:click={deleteClicked} />
107+
</div>
108+
</button>
109+
</Tooltip>
110110

111111
<!-- Download Button -->
112112
{#if downloadable}
113113
<Tooltip title="CSV" offset={{ x: 12, y: -50 }}>
114114
<button
115-
class="absolute top-0px left-6 text-light-800 hover:text-black transition ease"
115+
class="absolute top-0px left-6 text-light-800 hover:text-black transition ease"
116116
on:click={bottomRightButtonClicked}>
117117
<i class="fas fa-download z-1 absolute fa-md" />
118118
</button>

src/components/ui/recording/RecordingFingerprint.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<script lang="ts">
77
import type { RecordingData } from '../../../lib/domain/RecordingData';
88
import { stores } from '../../../lib/stores/Stores';
9-
import type { Vector } from '../../../lib/domain/Vector';
109
import BaseVector from '../../../lib/domain/BaseVector';
1110
import Fingerprint from './Fingerprint.svelte';
1211

0 commit comments

Comments
 (0)