Skip to content
Snippets Groups Projects
Commit baf2bd71 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Add decomposition tree with amounts. Add toggle to show null values.

parent 1547461d
No related branches found
No related tags found
No related merge requests found
<script lang="ts">
import type { Decomposition } from "$lib/decompositions"
export let decomposition: Decomposition
export let showNulls: boolean
</script>
<span>{Math.round(decomposition.delta)}</span>
<span>{decomposition.short_name}</span>
{#if decomposition.children !== undefined}
<ul class="list-disc list-inside ml-4">
{#each decomposition.children as child}
{#if showNulls || child.delta !== 0}
<li><svelte:self decomposition={child} /></li>
{/if}
{/each}
</ul>
{/if}
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
import Column from "./Column.svelte" import Column from "./Column.svelte"
export let decomposition: Decomposition export let decomposition: Decomposition
export let showNulls: boolean
$: data = [...walkDecomposition(decomposition, true)] $: data = [...walkDecomposition(decomposition, true)]
$: xDomain = data $: xDomain = data
.filter(({ delta }) => delta !== 0) .filter(({ delta }) => showNulls || delta !== 0)
.map((node) => node.short_name) .map((node) => node.short_name)
$: yDomain = computeYDomain(data) $: yDomain = computeYDomain(data)
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
</script> </script>
{#if xDomain.length > 0} {#if xDomain.length > 0}
<div class="h-64 max-w-2xl mx-auto"> <div class="h-64 w-full mx-auto">
<LayerCake <LayerCake
{data} {data}
x="short_name" x="short_name"
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import { session } from "$app/stores" import { session } from "$app/stores"
import type { Decomposition } from "$lib/decompositions" import type { Decomposition } from "$lib/decompositions"
import { decomposition as decompositionWithoutValue } from "$lib/decompositions" import { decomposition as decompositionWithoutValue } from "$lib/decompositions"
import DecompositionTree from "$lib/DecompositionTree.svelte"
import type { Situation } from "$lib/situations" import type { Situation } from "$lib/situations"
import TestCaseEdit from "$lib/TestCaseEdit.svelte" import TestCaseEdit from "$lib/TestCaseEdit.svelte"
import Waterfall from "$lib/Waterfall" import Waterfall from "$lib/Waterfall"
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
decompositionWithoutValue as Decomposition, decompositionWithoutValue as Decomposition,
deltaByCode, deltaByCode,
) )
let showNulls = false
let situation: Situation | undefined = undefined let situation: Situation | undefined = undefined
let webSocket: Sockette | undefined = undefined let webSocket: Sockette | undefined = undefined
let webSocketOpen = false let webSocketOpen = false
...@@ -137,5 +139,14 @@ ...@@ -137,5 +139,14 @@
<button on:click={submit}>Simuler</button> <button on:click={submit}>Simuler</button>
</div> </div>
<Waterfall {decomposition} /> <div class="flex">
<!-- <pre>{JSON.stringify(simulation, null, 2)}</pre> --> <div>
<DecompositionTree {decomposition} {showNulls} />
</div>
<Waterfall {decomposition} {showNulls} />
</div>
<label
><input bind:checked={showNulls} type="checkbox" /> Montrer les montants nuls</label
>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment