Files
trueref/trueref-frontend/web/src/lib/components/BarChart.svelte
moze c5f950c2c0
Some checks failed
Build and publish Docker image / Build and push (push) Failing after 1m27s
Initial commit: trueref v0.1.0-SNAPSHOT
Java 21 / Spring Boot 3.5.3 multi-module Maven project.
Hybrid BM25+HNSW search with RRF, cross-encoder reranker,
ONNX Runtime 1.22.0 (CPU + CUDA 12 GPU variants).
2026-05-06 00:49:16 +02:00

74 lines
1.5 KiB
Svelte

<script lang="ts">
interface Datum {
label: string;
value: number;
}
interface Props {
data: Datum[];
height?: number;
format?: (n: number) => string;
}
let { data, height = 180, format = (n) => n.toLocaleString() }: Props = $props();
let safeData = $derived(data ?? []);
let max = $derived(Math.max(1, ...safeData.map((d) => d.value)));
</script>
<div class="bars" style="--h: {height}px;">
{#each safeData as d (d.label)}
<div class="row">
<div class="lbl" title={d.label}>{d.label}</div>
<div class="track">
<div class="fill" style="width: {(d.value / max) * 100}%"></div>
</div>
<div class="val">{format(d.value)}</div>
</div>
{:else}
<div class="empty">No data yet.</div>
{/each}
</div>
<style>
.bars {
display: flex;
flex-direction: column;
gap: 6px;
max-height: var(--h);
overflow-y: auto;
}
.row {
display: grid;
grid-template-columns: 160px 1fr 90px;
gap: 10px;
align-items: center;
font-size: 12px;
}
.lbl {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--fg-dim);
}
.track {
background: var(--bg-alt);
border: 1px solid var(--border);
height: 10px;
border-radius: 4px;
overflow: hidden;
}
.fill {
background: var(--accent);
height: 100%;
}
.val {
text-align: right;
font-family: var(--mono);
color: var(--fg-dim);
}
.empty {
color: var(--muted);
font-style: italic;
font-size: 12px;
}
</style>