layerchart 0.30.0 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Area.svelte +12 -5
- package/dist/components/Area.svelte.d.ts +2 -0
- package/dist/components/Axis.svelte +70 -7
- package/dist/components/Axis.svelte.d.ts +1 -1
- package/dist/components/Chart.svelte +12 -0
- package/dist/components/Chart.svelte.d.ts +4 -0
- package/dist/components/GeoCircle.svelte +1 -1
- package/dist/components/Points.svelte +7 -3
- package/dist/components/Points.svelte.d.ts +1 -0
- package/dist/components/Spline.svelte +12 -6
- package/dist/components/Spline.svelte.d.ts +1 -0
- package/dist/components/Tooltip.svelte +7 -7
- package/dist/components/Tooltip.svelte.d.ts +1 -1
- package/dist/components/Zoom.svelte.d.ts +1 -1
- package/dist/utils/math.d.ts +21 -0
- package/dist/utils/math.js +29 -0
- package/package.json +16 -17
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import { area as d3Area } from 'd3-shape';
|
|
2
|
+
import { area as d3Area, areaRadial } from 'd3-shape';
|
|
3
3
|
import { max } from 'd3-array';
|
|
4
4
|
import { interpolatePath } from 'd3-interpolate-path';
|
|
5
5
|
import { cls } from 'svelte-ux';
|
|
@@ -10,6 +10,8 @@ const { data: contextData, xGet, yGet, yRange } = getContext('LayerCake');
|
|
|
10
10
|
export let data = undefined;
|
|
11
11
|
/** Pass `<path d={...} />` explicitly instead of calculating from data / context */
|
|
12
12
|
export let pathData = undefined;
|
|
13
|
+
/** Use radial instead of cartesian area generator, mapping `x` to `angle` and `y0`/`y1 to `innerRadius`/`outerRadius. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
|
|
14
|
+
export let radial = false;
|
|
13
15
|
/** Override x accessor */
|
|
14
16
|
export let x = undefined; // TODO: Update Type
|
|
15
17
|
/** Override y0 accessor. Defaults to max($yRange) */
|
|
@@ -26,10 +28,15 @@ export let line = false;
|
|
|
26
28
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
27
29
|
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
28
30
|
$: {
|
|
29
|
-
const path =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const path = radial
|
|
32
|
+
? areaRadial()
|
|
33
|
+
.angle(x ?? $xGet)
|
|
34
|
+
.innerRadius(y0 ?? max($yRange))
|
|
35
|
+
.outerRadius(y1 ?? $yGet)
|
|
36
|
+
: d3Area()
|
|
37
|
+
.x(x ?? $xGet)
|
|
38
|
+
.y0(y0 ?? max($yRange))
|
|
39
|
+
.y1(y1 ?? $yGet);
|
|
33
40
|
if (curve)
|
|
34
41
|
path.curve(curve);
|
|
35
42
|
if (defined)
|
|
@@ -7,6 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
[x: string]: any;
|
|
8
8
|
data?: any;
|
|
9
9
|
pathData?: string | undefined | null;
|
|
10
|
+
radial?: boolean | undefined;
|
|
10
11
|
x?: any;
|
|
11
12
|
y0?: any;
|
|
12
13
|
y1?: any;
|
|
@@ -18,6 +19,7 @@ declare const __propDef: {
|
|
|
18
19
|
[x: string]: any;
|
|
19
20
|
data?: any;
|
|
20
21
|
pathData?: string | null | undefined;
|
|
22
|
+
radial?: boolean | undefined;
|
|
21
23
|
x?: any;
|
|
22
24
|
y?: any;
|
|
23
25
|
tweened?: boolean | import("svelte/motion").TweenedOptions<unknown> | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import { format as formatValue, cls } from 'svelte-ux';
|
|
3
3
|
import { extent } from 'd3-array';
|
|
4
|
+
import { pointRadial } from 'd3-shape';
|
|
4
5
|
import Text from './Text.svelte';
|
|
5
6
|
import { isScaleBand } from '../utils/scales';
|
|
6
7
|
const { xScale, yScale, xRange, yRange, width } = getContext('LayerCake');
|
|
@@ -16,8 +17,15 @@ export let ticks = placement === 'left' || placement === 'right' ? 4 : undefined
|
|
|
16
17
|
export let tickSize = 4;
|
|
17
18
|
export let format = undefined;
|
|
18
19
|
export let labelProps = undefined;
|
|
19
|
-
$: orientation =
|
|
20
|
-
|
|
20
|
+
$: orientation =
|
|
21
|
+
placement === 'angle'
|
|
22
|
+
? 'angle'
|
|
23
|
+
: placement === 'radius'
|
|
24
|
+
? 'radius'
|
|
25
|
+
: ['top', 'bottom'].includes(placement)
|
|
26
|
+
? 'horizontal'
|
|
27
|
+
: 'vertical';
|
|
28
|
+
$: scale = ['horizontal', 'angle'].includes(orientation) ? $xScale : $yScale;
|
|
21
29
|
$: [xRangeMin, xRangeMax] = extent($xRange);
|
|
22
30
|
$: [yRangeMin, yRangeMax] = extent($yRange);
|
|
23
31
|
$: tickVals = Array.isArray(ticks)
|
|
@@ -47,9 +55,19 @@ function getCoords(tick) {
|
|
|
47
55
|
x: xRangeMax,
|
|
48
56
|
y: $yScale(tick) + (isScaleBand($yScale) ? $yScale.bandwidth() / 2 : 0),
|
|
49
57
|
};
|
|
58
|
+
case 'angle':
|
|
59
|
+
return {
|
|
60
|
+
x: $xScale(tick),
|
|
61
|
+
y: yRangeMax,
|
|
62
|
+
};
|
|
63
|
+
case 'radius':
|
|
64
|
+
return {
|
|
65
|
+
x: xRangeMin,
|
|
66
|
+
y: $yScale(tick),
|
|
67
|
+
};
|
|
50
68
|
}
|
|
51
69
|
}
|
|
52
|
-
function getDefaultLabelProps() {
|
|
70
|
+
function getDefaultLabelProps(tick) {
|
|
53
71
|
switch (placement) {
|
|
54
72
|
case 'top':
|
|
55
73
|
return {
|
|
@@ -77,6 +95,21 @@ function getDefaultLabelProps() {
|
|
|
77
95
|
dx: 4,
|
|
78
96
|
dy: -2, // manually adjusted until Text supports custom styles
|
|
79
97
|
};
|
|
98
|
+
case 'angle':
|
|
99
|
+
const xValue = $xScale(tick);
|
|
100
|
+
return {
|
|
101
|
+
textAnchor: xValue === 0 || xValue === Math.PI ? 'middle' : xValue > Math.PI ? 'end' : 'start',
|
|
102
|
+
verticalAnchor: 'middle',
|
|
103
|
+
dx: 0,
|
|
104
|
+
dy: -2, // manually adjusted until Text supports custom styles
|
|
105
|
+
};
|
|
106
|
+
case 'radius':
|
|
107
|
+
return {
|
|
108
|
+
textAnchor: 'middle',
|
|
109
|
+
verticalAnchor: 'middle',
|
|
110
|
+
dx: 2,
|
|
111
|
+
dy: -2, // manually adjusted until Text supports custom styles
|
|
112
|
+
};
|
|
80
113
|
}
|
|
81
114
|
}
|
|
82
115
|
</script>
|
|
@@ -105,10 +138,22 @@ function getDefaultLabelProps() {
|
|
|
105
138
|
class={cls('rule stroke-surface-content/50', lineProps?.class)}
|
|
106
139
|
/>
|
|
107
140
|
{/if}
|
|
141
|
+
|
|
142
|
+
<!-- TODO: angle rule? -->
|
|
143
|
+
|
|
144
|
+
{#if orientation === 'radius'}
|
|
145
|
+
<circle
|
|
146
|
+
r={$yRange[0] || 0}
|
|
147
|
+
{...lineProps}
|
|
148
|
+
class={cls('rule stroke-surface-content/20 fill-none', lineProps?.class)}
|
|
149
|
+
/>
|
|
150
|
+
{/if}
|
|
108
151
|
{/if}
|
|
109
152
|
|
|
110
153
|
{#each tickVals as tick, i}
|
|
111
154
|
{@const tickCoords = getCoords(tick)}
|
|
155
|
+
{@const radialTickCoords = pointRadial(tickCoords.x, tickCoords.y)}
|
|
156
|
+
|
|
112
157
|
<g>
|
|
113
158
|
{#if grid !== false}
|
|
114
159
|
{@const lineProps = typeof grid === 'object' ? grid : null}
|
|
@@ -130,6 +175,24 @@ function getDefaultLabelProps() {
|
|
|
130
175
|
{...lineProps}
|
|
131
176
|
class={cls('grid stroke-surface-content/10', lineProps?.class)}
|
|
132
177
|
/>
|
|
178
|
+
{:else if orientation === 'angle'}
|
|
179
|
+
{@const [x1, y1] = pointRadial(tickCoords.x, yRangeMin)}
|
|
180
|
+
{@const [x2, y2] = pointRadial(tickCoords.x, yRangeMax)}
|
|
181
|
+
|
|
182
|
+
<line
|
|
183
|
+
{x1}
|
|
184
|
+
{y1}
|
|
185
|
+
{x2}
|
|
186
|
+
{y2}
|
|
187
|
+
{...lineProps}
|
|
188
|
+
class={cls('test grid stroke-surface-content/10', lineProps?.class)}
|
|
189
|
+
/>
|
|
190
|
+
{:else if orientation === 'radius'}
|
|
191
|
+
<circle
|
|
192
|
+
r={tickCoords.y}
|
|
193
|
+
{...lineProps}
|
|
194
|
+
class={cls('grid stroke-surface-content/10 fill-none', lineProps?.class)}
|
|
195
|
+
/>
|
|
133
196
|
{/if}
|
|
134
197
|
{/if}
|
|
135
198
|
|
|
@@ -153,10 +216,10 @@ function getDefaultLabelProps() {
|
|
|
153
216
|
{/if}
|
|
154
217
|
|
|
155
218
|
<Text
|
|
156
|
-
x={tickCoords.x}
|
|
157
|
-
y={tickCoords.y}
|
|
158
|
-
value={formatValue(tick, format ?? scale.tickFormat?.())}
|
|
159
|
-
{...getDefaultLabelProps()}
|
|
219
|
+
x={orientation === 'angle' ? radialTickCoords[0] : tickCoords.x}
|
|
220
|
+
y={orientation === 'angle' ? radialTickCoords[1] : tickCoords.y}
|
|
221
|
+
value={formatValue(tick, format ?? scale.tickFormat?.() ?? ((v) => v))}
|
|
222
|
+
{...getDefaultLabelProps(tick)}
|
|
160
223
|
{...labelProps}
|
|
161
224
|
class={cls(
|
|
162
225
|
'label text-[10px] stroke-surface-100 [stroke-width:2px] font-light',
|
|
@@ -4,7 +4,7 @@ import type { SVGAttributes } from 'svelte/elements';
|
|
|
4
4
|
import Text from './Text.svelte';
|
|
5
5
|
declare const __propDef: {
|
|
6
6
|
props: {
|
|
7
|
-
/** Location of axis */ placement: 'top' | 'bottom' | 'left' | 'right';
|
|
7
|
+
/** Location of axis */ placement: 'top' | 'bottom' | 'left' | 'right' | 'angle' | 'radius';
|
|
8
8
|
/** Draw a rule line. Use Rule component for greater rendering order control */ rule?: boolean | SVGAttributes<SVGLineElement> | undefined;
|
|
9
9
|
/** Draw a grid lines */ grid?: boolean | SVGAttributes<SVGLineElement> | undefined;
|
|
10
10
|
/** Control the number of ticks*/ ticks?: number | any[] | Function | undefined;
|
|
@@ -79,9 +79,13 @@ export let geo = undefined;
|
|
|
79
79
|
let:width
|
|
80
80
|
let:element
|
|
81
81
|
let:xScale
|
|
82
|
+
let:xGet
|
|
82
83
|
let:yScale
|
|
84
|
+
let:yGet
|
|
83
85
|
let:zScale
|
|
86
|
+
let:zGet
|
|
84
87
|
let:rScale
|
|
88
|
+
let:rGet
|
|
85
89
|
let:padding
|
|
86
90
|
let:data
|
|
87
91
|
let:flatData
|
|
@@ -100,9 +104,13 @@ export let geo = undefined;
|
|
|
100
104
|
{projection}
|
|
101
105
|
{tooltip}
|
|
102
106
|
{xScale}
|
|
107
|
+
{xGet}
|
|
103
108
|
{yScale}
|
|
109
|
+
{yGet}
|
|
104
110
|
{zScale}
|
|
111
|
+
{zGet}
|
|
105
112
|
{rScale}
|
|
113
|
+
{rGet}
|
|
106
114
|
{padding}
|
|
107
115
|
{data}
|
|
108
116
|
{flatData}
|
|
@@ -118,9 +126,13 @@ export let geo = undefined;
|
|
|
118
126
|
{element}
|
|
119
127
|
{projection}
|
|
120
128
|
{xScale}
|
|
129
|
+
{xGet}
|
|
121
130
|
{yScale}
|
|
131
|
+
{yGet}
|
|
122
132
|
{zScale}
|
|
133
|
+
{zGet}
|
|
123
134
|
{rScale}
|
|
135
|
+
{rGet}
|
|
124
136
|
{padding}
|
|
125
137
|
{data}
|
|
126
138
|
{flatData}
|
|
@@ -32,9 +32,13 @@ declare const __propDef: {
|
|
|
32
32
|
element: Element;
|
|
33
33
|
projection: import("d3-geo").GeoProjection | import("d3-geo").GeoIdentityTransform;
|
|
34
34
|
xScale: any;
|
|
35
|
+
xGet: any;
|
|
35
36
|
yScale: any;
|
|
37
|
+
yGet: any;
|
|
36
38
|
zScale: any;
|
|
39
|
+
zGet: any;
|
|
37
40
|
rScale: any;
|
|
41
|
+
rGet: any;
|
|
38
42
|
padding: {
|
|
39
43
|
top: number;
|
|
40
44
|
right: number;
|
|
@@ -6,7 +6,7 @@ export let radius = 90;
|
|
|
6
6
|
export let center = [0, 0];
|
|
7
7
|
/** sets the circle precision to the specified angle in degrees */
|
|
8
8
|
export let precision = 6;
|
|
9
|
-
$: geojson = geoCircle().radius(radius).center(center)();
|
|
9
|
+
$: geojson = geoCircle().radius(radius).center(center).precision(precision)();
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<GeoPath {geojson} {...$$restProps} />
|
|
@@ -4,11 +4,14 @@ import { notNull } from 'svelte-ux';
|
|
|
4
4
|
import Circle from './Circle.svelte';
|
|
5
5
|
import Link from './Link.svelte';
|
|
6
6
|
import { isScaleBand } from '../utils/scales';
|
|
7
|
+
import { pointRadial } from 'd3-shape';
|
|
7
8
|
const context = getContext('LayerCake');
|
|
8
9
|
const { data, xGet, y, yGet, xScale, yScale, rGet, config } = context;
|
|
9
10
|
export let r = 5;
|
|
10
11
|
export let offsetX = undefined;
|
|
11
12
|
export let offsetY = undefined;
|
|
13
|
+
/** Use radial instead of cartesian line generator, mapping `x` to `angle` and `y` to `radius`. Radial points are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
|
|
14
|
+
export let radial = false;
|
|
12
15
|
/** Enable showing links between related points (array x/y accessors) */
|
|
13
16
|
export let links = false;
|
|
14
17
|
function getOffset(value, offset, scale) {
|
|
@@ -18,7 +21,7 @@ function getOffset(value, offset, scale) {
|
|
|
18
21
|
else if (offset != null) {
|
|
19
22
|
return offset;
|
|
20
23
|
}
|
|
21
|
-
else if (isScaleBand(scale)) {
|
|
24
|
+
else if (isScaleBand(scale) && !radial) {
|
|
22
25
|
return scale.bandwidth() / 2;
|
|
23
26
|
}
|
|
24
27
|
else {
|
|
@@ -123,9 +126,10 @@ $: _links = $data.flatMap((d) => {
|
|
|
123
126
|
|
|
124
127
|
<g class="point-group">
|
|
125
128
|
{#each points as point}
|
|
129
|
+
{@const radialPoint = pointRadial(point.x, point.y)}
|
|
126
130
|
<Circle
|
|
127
|
-
cx={point.x}
|
|
128
|
-
cy={point.y}
|
|
131
|
+
cx={radial ? radialPoint[0] : point.x}
|
|
132
|
+
cy={radial ? radialPoint[1] : point.y}
|
|
129
133
|
{r}
|
|
130
134
|
fill={$config.r ? $rGet(point.data) : null}
|
|
131
135
|
{...$$restProps}
|
|
@@ -5,6 +5,7 @@ declare const __propDef: {
|
|
|
5
5
|
r?: number | undefined;
|
|
6
6
|
offsetX?: number | ((value: number, context: any) => number) | undefined;
|
|
7
7
|
offsetY?: number | ((value: number, context: any) => number) | undefined;
|
|
8
|
+
radial?: boolean | undefined;
|
|
8
9
|
links?: boolean | Partial<{
|
|
9
10
|
[x: string]: any;
|
|
10
11
|
data?: any;
|
|
@@ -3,7 +3,7 @@ import { writable } from 'svelte/store';
|
|
|
3
3
|
import { tweened as tweenedStore } from 'svelte/motion';
|
|
4
4
|
import { draw as _drawTransition } from 'svelte/transition';
|
|
5
5
|
import { cubicInOut } from 'svelte/easing';
|
|
6
|
-
import { line as d3Line } from 'd3-shape';
|
|
6
|
+
import { line as d3Line, lineRadial } from 'd3-shape';
|
|
7
7
|
// import { interpolateString } from 'd3-interpolate';
|
|
8
8
|
import { interpolatePath } from 'd3-interpolate-path';
|
|
9
9
|
import { cls } from 'svelte-ux';
|
|
@@ -14,9 +14,11 @@ const { data: contextData, xGet, yGet } = getContext('LayerCake');
|
|
|
14
14
|
export let data = undefined;
|
|
15
15
|
/** Pass `<path d={...} />` explicitly instead of calculating from data / context */
|
|
16
16
|
export let pathData = undefined;
|
|
17
|
-
/**
|
|
17
|
+
/** Use radial instead of cartesian line generator, mapping `x` to `angle` and `y` to `radius`. Radial lines are positioned relative to the origin, use transform (ex. `<Group center>`) to change the origin */
|
|
18
|
+
export let radial = false;
|
|
19
|
+
/** Override `x` accessor from Chart context. Applies to `angle` when `radial=true` */
|
|
18
20
|
export let x = undefined; // TODO: Update Type
|
|
19
|
-
/** Override y accessor */
|
|
21
|
+
/** Override `y` accessor from Chart context. Applies to `radius` when `radial=true` */
|
|
20
22
|
export let y = undefined; // TODO: Update Type
|
|
21
23
|
/** Interpolate path data using d3-interpolate-path. Works best without `draw` enabled */
|
|
22
24
|
export let tweened = undefined;
|
|
@@ -37,9 +39,13 @@ let d = '';
|
|
|
37
39
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
38
40
|
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
39
41
|
$: {
|
|
40
|
-
const path =
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const path = radial
|
|
43
|
+
? lineRadial()
|
|
44
|
+
.angle(x ?? $xGet)
|
|
45
|
+
.radius(y ?? $yGet)
|
|
46
|
+
: d3Line()
|
|
47
|
+
.x(x ?? $xGet)
|
|
48
|
+
.y(y ?? $yGet);
|
|
43
49
|
if (curve)
|
|
44
50
|
path.curve(curve);
|
|
45
51
|
if (defined)
|
|
@@ -15,7 +15,7 @@ export let yOffset = typeof x === 'number' || typeof y === 'number' ? 0 : 10;
|
|
|
15
15
|
export let anchor = 'top-left';
|
|
16
16
|
export let contained = 'container'; // TODO: Support 'window' using getBoundingClientRect()
|
|
17
17
|
export let animate = true;
|
|
18
|
-
export let variant = '
|
|
18
|
+
export let variant = 'default';
|
|
19
19
|
export let header = undefined;
|
|
20
20
|
export let classes = {};
|
|
21
21
|
const { padding, xGet, yGet, containerWidth, containerHeight } = getContext('LayerCake');
|
|
@@ -115,13 +115,13 @@ $: if ($tooltip?.data) {
|
|
|
115
115
|
['[&_.value]:text-sm [&_.value]:tabular-nums'],
|
|
116
116
|
],
|
|
117
117
|
{
|
|
118
|
-
|
|
119
|
-
'bg-
|
|
120
|
-
'[&_.label]:text-
|
|
118
|
+
default: [
|
|
119
|
+
'bg-surface-100/90 dark:bg-surface-300/90 backdrop-filter backdrop-blur-[2px] text-surface-content',
|
|
120
|
+
'[&_.label]:text-surface-content/75',
|
|
121
121
|
],
|
|
122
|
-
|
|
123
|
-
'bg-
|
|
124
|
-
'[&_.label]:text-surface-
|
|
122
|
+
invert: [
|
|
123
|
+
'bg-surface-content/90 backdrop-filter backdrop-blur-[2px] text-surface-100 border border-surface-content',
|
|
124
|
+
'[&_.label]:text-surface-100/50',
|
|
125
125
|
],
|
|
126
126
|
none: '',
|
|
127
127
|
}[variant],
|
|
@@ -9,7 +9,7 @@ declare const __propDef: {
|
|
|
9
9
|
anchor?: ("center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
10
10
|
contained?: false | "container" | undefined;
|
|
11
11
|
animate?: boolean | undefined;
|
|
12
|
-
variant?: "
|
|
12
|
+
variant?: "default" | "none" | "invert" | undefined;
|
|
13
13
|
header?: ((data: any) => any) | undefined;
|
|
14
14
|
classes?: {
|
|
15
15
|
root?: string | undefined;
|
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
spring?: boolean | Parameters<typeof motionStore>[1]['spring'];
|
|
8
8
|
tweened?: boolean | Parameters<typeof motionStore>[1]['tweened'];
|
|
9
9
|
disablePointer?: boolean | undefined;
|
|
10
|
-
scroll?: "
|
|
10
|
+
scroll?: "scale" | "translate" | "none" | undefined;
|
|
11
11
|
clickDistance?: number | undefined;
|
|
12
12
|
initialTranslate?: {
|
|
13
13
|
x: number;
|
package/dist/utils/math.d.ts
CHANGED
|
@@ -6,3 +6,24 @@ export declare function degreesToRadians(degrees: number): number;
|
|
|
6
6
|
* Convert radians to degrees
|
|
7
7
|
*/
|
|
8
8
|
export declare function radiansToDegrees(radians: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Convert polar to cartesian coordinate system.
|
|
11
|
+
* see also: https://d3js.org/d3-shape/symbol#pointRadial
|
|
12
|
+
* @param angle - Angle in radians
|
|
13
|
+
* @param radius - Radius
|
|
14
|
+
*/
|
|
15
|
+
export declare function polarToCartesian(angle: number, radius: number): {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Convert cartesian to polar coordinate system. Angle in radians
|
|
21
|
+
*/
|
|
22
|
+
export declare function cartesianToPolar(x: number, y: number): {
|
|
23
|
+
radius: number;
|
|
24
|
+
angle: number;
|
|
25
|
+
};
|
|
26
|
+
/** Convert celsius temperature to fahrenheit */
|
|
27
|
+
export declare function celsiusToFahrenheit(temperature: number): number;
|
|
28
|
+
/** Convert fahrenheit temperature to celsius */
|
|
29
|
+
export declare function fahrenheitToCelsius(temperature: number): number;
|
package/dist/utils/math.js
CHANGED
|
@@ -10,3 +10,32 @@ export function degreesToRadians(degrees) {
|
|
|
10
10
|
export function radiansToDegrees(radians) {
|
|
11
11
|
return radians * (180 / Math.PI);
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Convert polar to cartesian coordinate system.
|
|
15
|
+
* see also: https://d3js.org/d3-shape/symbol#pointRadial
|
|
16
|
+
* @param angle - Angle in radians
|
|
17
|
+
* @param radius - Radius
|
|
18
|
+
*/
|
|
19
|
+
export function polarToCartesian(angle, radius) {
|
|
20
|
+
return {
|
|
21
|
+
x: radius * Math.cos(angle),
|
|
22
|
+
y: radius * Math.sin(angle),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert cartesian to polar coordinate system. Angle in radians
|
|
27
|
+
*/
|
|
28
|
+
export function cartesianToPolar(x, y) {
|
|
29
|
+
return {
|
|
30
|
+
radius: Math.sqrt(x ** 2 + y ** 2),
|
|
31
|
+
angle: Math.atan(y / x),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Convert celsius temperature to fahrenheit */
|
|
35
|
+
export function celsiusToFahrenheit(temperature) {
|
|
36
|
+
return temperature * (9 / 5) + 32;
|
|
37
|
+
}
|
|
38
|
+
/** Convert fahrenheit temperature to celsius */
|
|
39
|
+
export function fahrenheitToCelsius(temperature) {
|
|
40
|
+
return (temperature - 32) * (5 / 9);
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "techniq/layerchart",
|
|
7
|
-
"version": "0.30.
|
|
7
|
+
"version": "0.30.2",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@changesets/cli": "^2.27.1",
|
|
10
10
|
"@mdi/js": "^7.4.47",
|
|
11
11
|
"@rollup/plugin-dsv": "^3.0.4",
|
|
12
|
-
"@sveltejs/adapter-auto": "^3.1.
|
|
13
|
-
"@sveltejs/kit": "^2.
|
|
14
|
-
"@sveltejs/package": "^2.2.
|
|
12
|
+
"@sveltejs/adapter-auto": "^3.1.1",
|
|
13
|
+
"@sveltejs/kit": "^2.5.0",
|
|
14
|
+
"@sveltejs/package": "^2.2.6",
|
|
15
15
|
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
|
|
16
16
|
"@tailwindcss/typography": "^0.5.10",
|
|
17
17
|
"@types/d3-array": "^3.2.1",
|
|
@@ -29,40 +29,39 @@
|
|
|
29
29
|
"@types/d3-shape": "^3.1.6",
|
|
30
30
|
"@types/d3-time": "^3.0.2",
|
|
31
31
|
"@types/lodash-es": "^4.17.12",
|
|
32
|
-
"@types/marked": "^6.0.0",
|
|
33
32
|
"@types/prismjs": "^1.26.3",
|
|
34
33
|
"@types/shapefile": "^0.6.4",
|
|
35
34
|
"@types/topojson-client": "^3.1.4",
|
|
36
|
-
"autoprefixer": "^10.4.
|
|
35
|
+
"autoprefixer": "^10.4.17",
|
|
37
36
|
"d3-color": "^3.1.0",
|
|
38
37
|
"execa": "^8.0.1",
|
|
39
|
-
"marked": "^
|
|
38
|
+
"marked": "^12.0.0",
|
|
40
39
|
"mdsvex": "^0.11.0",
|
|
41
40
|
"posthog-js": "^1.95.1",
|
|
42
|
-
"prettier": "^3.2.
|
|
43
|
-
"prettier-plugin-svelte": "^3.1
|
|
41
|
+
"prettier": "^3.2.5",
|
|
42
|
+
"prettier-plugin-svelte": "^3.2.1",
|
|
44
43
|
"prism-svelte": "^0.5.0",
|
|
45
44
|
"prism-themes": "^1.9.0",
|
|
46
45
|
"prismjs": "^1.29.0",
|
|
47
46
|
"rehype-slug": "^6.0.0",
|
|
48
47
|
"shapefile": "^0.6.6",
|
|
49
48
|
"solar-calculator": "^0.3.0",
|
|
50
|
-
"svelte": "^4.2.
|
|
51
|
-
"svelte-check": "^3.6.
|
|
49
|
+
"svelte": "^4.2.10",
|
|
50
|
+
"svelte-check": "^3.6.4",
|
|
52
51
|
"svelte-json-tree": "^2.2.0",
|
|
53
52
|
"svelte-preprocess": "^5.1.3",
|
|
54
|
-
"svelte2tsx": "^0.7.
|
|
53
|
+
"svelte2tsx": "^0.7.1",
|
|
55
54
|
"tailwindcss": "^3.4.1",
|
|
56
55
|
"topojson-client": "^3.1.0",
|
|
57
56
|
"tslib": "^2.6.2",
|
|
58
57
|
"typescript": "^5.3.3",
|
|
59
58
|
"unist-util-visit": "^5.0.0",
|
|
60
59
|
"us-atlas": "^3.0.1",
|
|
61
|
-
"vite": "^5.
|
|
60
|
+
"vite": "^5.1.1"
|
|
62
61
|
},
|
|
63
62
|
"type": "module",
|
|
64
63
|
"dependencies": {
|
|
65
|
-
"@sveltejs/vite-plugin-svelte": "^3.0.
|
|
64
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
|
66
65
|
"d3-array": "^3.2.4",
|
|
67
66
|
"d3-color": "^3.1.0",
|
|
68
67
|
"d3-delaunay": "^6.0.4",
|
|
@@ -79,12 +78,12 @@
|
|
|
79
78
|
"d3-shape": "^3.2.0",
|
|
80
79
|
"d3-tile": "^1.0.0",
|
|
81
80
|
"d3-time": "^3.1.0",
|
|
82
|
-
"date-fns": "^3.
|
|
81
|
+
"date-fns": "^3.3.1",
|
|
83
82
|
"layercake": "^8.0.2",
|
|
84
83
|
"lodash-es": "^4.17.21",
|
|
85
|
-
"posthog-js": "^1.
|
|
84
|
+
"posthog-js": "^1.105.8",
|
|
86
85
|
"shapefile": "^0.6.6",
|
|
87
|
-
"svelte-ux": "0.60
|
|
86
|
+
"svelte-ux": ">=0.60",
|
|
88
87
|
"topojson-client": "^3.1.0"
|
|
89
88
|
},
|
|
90
89
|
"peerDependencies": {
|