Skip to content

Commit b1b7365

Browse files
committed
docs(AreaChart): Add point and band scale examples
1 parent 29e4bfe commit b1b7365

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

  • packages/layerchart/src/routes/docs/components/AreaChart

packages/layerchart/src/routes/docs/components/AreaChart/+page.svelte

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
import { curveBasis, curveCatmullRom, curveStepAfter } from 'd3-shape';
2323
import { group } from 'd3-array';
2424
import { timeDay } from 'd3-time';
25+
import { scaleBand, scalePoint } from 'd3-scale';
2526
import { Button, Field, Kbd, Switch } from 'svelte-ux';
2627
import { format, sortFunc } from '@layerstack/utils';
2728
import { cls } from '@layerstack/tailwind';
2829
2930
import Preview from '$lib/docs/Preview.svelte';
30-
import { createDateSeries, randomWalk } from '$lib/utils/genData.js';
31+
import { createDateSeries, longData, randomWalk } from '$lib/utils/genData.js';
3132
import type { DomainType } from '$lib/utils/scales.svelte.js';
3233
import Blockquote from '$lib/docs/Blockquote.svelte';
3334
import CurveMenuField from '$lib/docs/CurveMenuField.svelte';
@@ -1322,6 +1323,40 @@
13221323
</div>
13231324
</Preview>
13241325

1326+
<h2>Point scale</h2>
1327+
1328+
<Preview data={dateSeriesData}>
1329+
<div class="h-[300px] p-4 border rounded-sm">
1330+
<AreaChart
1331+
data={longData.filter((d) => d.year === 2019)}
1332+
xScale={scalePoint()}
1333+
x="fruit"
1334+
y="value"
1335+
{renderContext}
1336+
{debug}
1337+
/>
1338+
</div>
1339+
</Preview>
1340+
1341+
<h2>Band scale</h2>
1342+
1343+
<Preview data={dateSeriesData}>
1344+
<div class="h-[300px] p-4 border rounded-sm">
1345+
<AreaChart
1346+
data={longData.filter((d) => d.year === 2019)}
1347+
xScale={scaleBand()}
1348+
x="fruit"
1349+
y="value"
1350+
tooltip={{
1351+
mode: 'band',
1352+
debug,
1353+
}}
1354+
{renderContext}
1355+
{debug}
1356+
/>
1357+
</div>
1358+
</Preview>
1359+
13251360
<h2>Custom chart</h2>
13261361

13271362
<Preview data={dateSeriesData}>

0 commit comments

Comments
 (0)