overhauled histograms

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-03-10 11:34:52 +01:00
parent 577e99d840
commit 2cd99f362b
13 changed files with 144 additions and 24 deletions

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>