Skip to content

Commit

Permalink
fix: layerchart template (and use simplified AreaChart)
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed Oct 8, 2024
1 parent bbc80a3 commit c813993
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-beds-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte-ux': patch
---

fix: `layerchart` template (and use simplified AreaChart)
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
<script lang="ts">
import { Area, Axis, Chart, Highlight, Svg, Tooltip, TooltipItem } from 'layerchart';
import { PeriodType, format } from 'svelte-ux';
import { scaleTime } from 'd3-scale';
import { AreaChart } from 'layerchart';
import { data } from './data';
</script>

<main class="p-2">
<h1 class="text-xl font-semibold mb-1">Area example</h1>
<div class="h-[300px] p-4 border rounded">
<Chart
{data}
x="date"
xScale={scaleTime()}
y="value"
yDomain={[0, null]}
yNice
padding={{ left: 16, bottom: 24 }}
tooltip
>
<Svg>
<Axis placement="left" grid rule />
<Axis placement="bottom" format={(d) => format(d, PeriodType.Day, 'short')} rule />
<Area line={{ class: 'stroke-2 stroke-primary' }} class="fill-primary/30" />
<Highlight points lines />
</Svg>

<Tooltip header={(data) => format(data.date, PeriodType.Day)} let:data>
<TooltipItem label="value" value={data.value} />
</Tooltip>
</Chart>
<AreaChart {data} x="date" y="value" />
</div>
</main>

0 comments on commit c813993

Please sign in to comment.