Skip to content

Commit 70e032c

Browse files
committed
Move Radar example to RadialLine with simplfied implementation
1 parent 0a0392f commit 70e032c

5 files changed

Lines changed: 51 additions & 172 deletions

File tree

packages/layerchart/src/routes/_NavMenu.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
'Line',
1818
'Oscilloscope',
1919
'PunchCard',
20-
'Radar',
2120
'RadialLine',
2221
'Scatter',
2322
'Sparkbar',

packages/layerchart/src/routes/docs/examples/Radar/+page.svelte

Lines changed: 0 additions & 108 deletions
This file was deleted.

packages/layerchart/src/routes/docs/examples/Radar/+page.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/layerchart/src/routes/docs/examples/Radar/AxisRadial.svelte

Lines changed: 0 additions & 47 deletions
This file was deleted.

packages/layerchart/src/routes/docs/examples/RadialLine/+page.svelte

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script lang="ts">
2-
import { scaleLinear, scaleRadial, scaleUtc } from 'd3-scale';
2+
import { scaleBand, scaleUtc } from 'd3-scale';
33
import { flatGroup } from 'd3-array';
44
import { curveLinearClosed, curveCatmullRomClosed, curveCatmullRom } from 'd3-shape';
5-
import { PeriodType, cls } from 'svelte-ux';
5+
import { Field, PeriodType, ToggleGroup, ToggleOption, cls } from 'svelte-ux';
66
77
import Chart, { Svg } from '$lib/components/Chart.svelte';
88
import Area from '$lib/components/Area.svelte';
@@ -11,17 +11,62 @@
1111
import Spline from '$lib/components/Spline.svelte';
1212
1313
import Preview from '$lib/docs/Preview.svelte';
14+
import Points from '$lib/components/Points.svelte';
1415
1516
export let data;
1617
17-
/**
18-
* TODO:
19-
* - [ ] Tooltip (manual with path, radial bisect?). Work with Highlight
20-
*/
18+
const pitchData = [
19+
{ name: 'fastball', value: 10 },
20+
{ name: 'change', value: 0 },
21+
{ name: 'slider', value: 4 },
22+
{ name: 'cutter', value: 8 },
23+
{ name: 'curve', value: 5 },
24+
];
25+
let curve = curveLinearClosed;
2126
</script>
2227

2328
<h1>Examples</h1>
2429

30+
<div class="grid grid-cols-[1fr,auto] gap-2 items-end">
31+
<h2>Radar</h2>
32+
<Field label="curve: " labelPlacement="left" class="mb-1" dense>
33+
<ToggleGroup bind:value={curve} size="sm">
34+
<ToggleOption value={curveLinearClosed}>Linear</ToggleOption>
35+
<ToggleOption value={curveCatmullRomClosed}>CatmullRom</ToggleOption>
36+
</ToggleGroup>
37+
</Field>
38+
</div>
39+
40+
<Preview data={pitchData}>
41+
<div class="h-[300px] p-4 border rounded">
42+
<Chart
43+
data={pitchData}
44+
x="name"
45+
xScale={scaleBand()}
46+
xDomain={pitchData.map((d) => d.name)}
47+
xRange={[0, 2 * Math.PI]}
48+
y="value"
49+
yRange={({ height }) => [0, height / 2]}
50+
yPadding={[0, 10]}
51+
padding={{ top: 32, bottom: 8 }}
52+
>
53+
<Svg>
54+
<Group center>
55+
<Axis
56+
placement="radius"
57+
grid={{ class: 'stroke-surface-content/20 fill-surface-200/50' }}
58+
ticks={[0, 5, 10]}
59+
format={(d) => ''}
60+
/>
61+
<Axis placement="angle" grid={{ class: 'stroke-surface-content/20' }} />
62+
<Spline radial {curve} class="stroke-primary fill-primary/20" />
63+
<Points radial class="fill-primary stroke-surface-200" />
64+
</Group>
65+
</Svg>
66+
</Chart>
67+
</div>
68+
</Preview>
69+
2570
<h2>Line with Areas</h2>
2671

2772
<Preview data={data.sfoTemperatures}>
@@ -32,7 +77,6 @@
3277
xScale={scaleUtc()}
3378
xRange={[0, 2 * Math.PI]}
3479
y={['minmin', 'maxmax']}
35-
yScale={scaleRadial()}
3680
yRange={({ height }) => [height / 5, height / 2]}
3781
let:yScale
3882
>

0 commit comments

Comments
 (0)