|
1 | 1 | <script lang="ts"> |
2 | 2 | import { scaleLinear, scaleRadial, scaleUtc } from 'd3-scale'; |
3 | | - import { flatGroup, max, min, range } from 'd3-array'; |
| 3 | + import { flatGroup, range } from 'd3-array'; |
4 | 4 | import { curveLinearClosed, curveCatmullRomClosed, curveCatmullRom } from 'd3-shape'; |
5 | 5 | import { PeriodType, cls } from 'svelte-ux'; |
6 | 6 |
|
|
25 | 25 |
|
26 | 26 | <h1>Examples</h1> |
27 | 27 |
|
28 | | -<h2>Complex</h2> |
| 28 | +<h2>Line with Area</h2> |
29 | 29 |
|
30 | | -<Preview data={data.sfoTemperature}> |
| 30 | +<Preview data={data.sfoTemperatures}> |
31 | 31 | <div class="h-[500px] p-4 border rounded"> |
32 | 32 | <Chart |
33 | | - data={data.sfoTemperature} |
| 33 | + data={data.sfoTemperatures} |
34 | 34 | x="date" |
35 | 35 | xScale={scaleUtc()} |
36 | | - xDomain={[new Date('2000-01-01'), new Date('2001-01-01') - 1]} |
37 | 36 | xRange={[0, 2 * Math.PI]} |
38 | | - y="avg" |
| 37 | + y={['minmin', 'maxmax']} |
39 | 38 | yScale={scaleRadial()} |
40 | | - yDomain={[ |
41 | | - min(data.sfoTemperature, (d) => d.minmin), |
42 | | - max(data.sfoTemperature, (d) => d.maxmax), |
43 | | - ]} |
44 | 39 | yRange={({ height }) => [height / 5, height / 2]} |
45 | 40 | let:yScale |
46 | 41 | > |
47 | 42 | <Svg> |
48 | 43 | <Group center> |
49 | | - <Spline radial curve={curveCatmullRom} class="stroke-primary" /> |
| 44 | + <Spline y={(d) => yScale(d.avg)} radial curve={curveCatmullRom} class="stroke-primary" /> |
50 | 45 | <Area |
51 | 46 | radial |
52 | 47 | y0={(d) => yScale(d.min)} |
|
0 commit comments