Merge branch 'module/poll' into dev
All checks were successful
Build Docker Image / Docker-Build (push) Successful in 2m23s
Build Docker Image / Clean-Registry (push) Successful in -6s

This commit is contained in:
2026-03-10 11:35:01 +01:00
13 changed files with 153 additions and 27 deletions

View File

@@ -0,0 +1,28 @@
<script>
import { t } from '../translations.svelte';
let { data = {} } = $props();
let max = $derived(Math.max(...Object.values(data)));
</script>
<style>
.histo {
display: flex;
align-items: flex-end;
gap: 2px;
}
.bar {
display: flex; /* flexbox for text alignment */
align-items: flex-end; /* text sticks to bottom of bar */
height: 100%; /* full height of flex item */
padding: 0 2px; /* space for text */
box-sizing: border-box; /* include padding in height */
}
</style>
<div class="histo">
{#each Object.entries(data).sort((a,b) => a[0] - b[0]) as [weight,count]}
<div class="bar" style="height: {100*count/max}%" title={t('voted {count} times',{count})}>{weight}</div>
{/each}
</div>

View File

@@ -1,4 +1,5 @@
<script>
import Histogram from '../../Components/Histogram.svelte';
import { onMount } from 'svelte';
import { api, get } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
@@ -62,25 +63,22 @@
</tr>
</thead>
<tbody>
{#each Object.entries(poll.evaluation) as [option_id,hist]}
{#each Object.entries(poll.evaluation).sort((a,b) => b[0] - a[0]) as [avg,optionset]}
{#each Object.entries(optionset) as [option_id,histo]}
<tr>
<td>
{poll.options[option_id].name}
</td>
<td>
{average(hist)}
{(+avg).toFixed(3)}
</td>
<td class="histogram">
{#each Object.entries(hist).sort((a,b) => a[0] - b[0]) as [weight,count]}
<span style="height: {100*count/max_val(hist)}%" title={t('voted {count} times',{count:count})}>
<span>{weight}</span>
</span>
{/each}
<td>
<Histogram data={histo} />
</td>
</tr>
{/each}
{/each}
</tbody>
</table>
</fieldset>
{/if}
<span class="warn">TODO: sort by average</span>