| 1 |
<script lang="ts"> |
| 2 |
import { group } from "d3-array"; |
| 3 |
|
| 4 |
import ChartSwitcher from "../../charts/ChartSwitcher.svelte"; |
| 5 |
import { ScatterPlot } from "../../charts/scatterplot"; |
| 6 |
import { _, format } from "../../i18n"; |
| 7 |
import type { EventsReportProps } from "."; |
| 8 |
import EventTable from "./EventTable.svelte"; |
| 9 |
|
| 10 |
let { events }: EventsReportProps = $props(); |
| 11 |
|
| 12 |
let groups = $derived([...group(events, (e) => e.type)]); |
| 13 |
|
| 14 |
let charts = $derived([ |
| 15 |
new ScatterPlot( |
| 16 |
_("Events"), |
| 17 |
events.map(({ date, type, description }) => ({ |
| 18 |
date: new Date(date), |
| 19 |
type, |
| 20 |
description, |
| 21 |
})), |
| 22 |
), |
| 23 |
]); |
| 24 |
</script> |
| 25 |
|
| 26 |
{#if groups.length} |
| 27 |
<ChartSwitcher {charts} /> |
| 28 |
|
| 29 |
{#each groups as [type, events_in_group] (type)} |
| 30 |
<div class="left"> |
| 31 |
<h3>{format(_("Event: %(type)s"), { type })}</h3> |
| 32 |
<EventTable events={events_in_group} /> |
| 33 |
</div> |
| 34 |
{/each} |
| 35 |
{:else} |
| 36 |
<p> |
| 37 |
{_("No events.")} |
| 38 |
</p> |
| 39 |
{/if} |