layerchart 0.17.1 → 0.17.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/Arc.svelte +50 -9
- package/dist/components/Arc.svelte.d.ts +2 -2
- package/dist/components/Axis.svelte +6 -5
- package/dist/components/Chart.svelte.d.ts +1 -1
- package/dist/components/LinearGradient.svelte +1 -1
- package/dist/components/LinearGradient.svelte.d.ts +1 -1
- package/dist/components/Link.svelte +2 -0
- package/dist/components/Link.svelte.d.ts +2 -0
- package/dist/components/Rect.svelte +2 -0
- package/dist/components/RectClipPath.svelte +1 -0
- package/dist/components/Tooltip.svelte +8 -7
- package/dist/components/Tooltip.svelte.d.ts +4 -1
- package/dist/docs/RangeField.svelte +1 -1
- package/package.json +3 -3
|
@@ -46,6 +46,12 @@ export let innerRadius = undefined;
|
|
|
46
46
|
/**
|
|
47
47
|
* Define outerRadius. Defaults to yRange max / 2 (ie. chart height / 2)
|
|
48
48
|
*/
|
|
49
|
+
/**
|
|
50
|
+
* Define outerRadius. Defaults to yRange max (ie. chart height / 2)
|
|
51
|
+
* • value >= 1: discrete value
|
|
52
|
+
* • value < 1: percent of chart height / 2
|
|
53
|
+
* • value < 0: offset of chart height / 2
|
|
54
|
+
*/
|
|
49
55
|
export let outerRadius = undefined;
|
|
50
56
|
export let cornerRadius = 0;
|
|
51
57
|
export let padAngle = 0;
|
|
@@ -53,15 +59,50 @@ export let padAngle = 0;
|
|
|
53
59
|
export let track = false;
|
|
54
60
|
const { yRange } = getContext('LayerCake');
|
|
55
61
|
$: scale = scaleLinear().domain(domain).range(range);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
function getOuterRadius(outerRadius, chartRadius) {
|
|
63
|
+
if (outerRadius == null) {
|
|
64
|
+
return chartRadius;
|
|
65
|
+
}
|
|
66
|
+
else if (outerRadius > 1) {
|
|
67
|
+
// discrete value
|
|
68
|
+
return outerRadius;
|
|
69
|
+
}
|
|
70
|
+
else if (outerRadius > 0) {
|
|
71
|
+
// percent of `chartRadius`
|
|
72
|
+
return chartRadius * outerRadius;
|
|
73
|
+
}
|
|
74
|
+
else if (outerRadius < 0) {
|
|
75
|
+
// offset of `chartRadius`
|
|
76
|
+
return chartRadius + outerRadius;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// 0
|
|
80
|
+
return outerRadius;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
$: _outerRadius = getOuterRadius(outerRadius, max($yRange) / 2);
|
|
84
|
+
function getInnerRadius(innerRadius, outerRadius) {
|
|
85
|
+
if (innerRadius == null) {
|
|
86
|
+
return Math.min(...$yRange);
|
|
87
|
+
}
|
|
88
|
+
else if (innerRadius > 1) {
|
|
89
|
+
// discrete value
|
|
90
|
+
return innerRadius;
|
|
91
|
+
}
|
|
92
|
+
else if (innerRadius > 0) {
|
|
93
|
+
// percent of `outerRadius`
|
|
94
|
+
return outerRadius * innerRadius;
|
|
95
|
+
}
|
|
96
|
+
else if (innerRadius < 0) {
|
|
97
|
+
// offset of `outerRadius`
|
|
98
|
+
return outerRadius + innerRadius;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// 0
|
|
102
|
+
return innerRadius;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
$: _innerRadius = getInnerRadius(innerRadius, _outerRadius);
|
|
65
106
|
$: arc = d3arc()
|
|
66
107
|
.innerRadius(_innerRadius)
|
|
67
108
|
.outerRadius(_outerRadius)
|
|
@@ -11,8 +11,8 @@ declare const __propDef: {
|
|
|
11
11
|
range?: number[] | undefined;
|
|
12
12
|
startAngle?: number | undefined;
|
|
13
13
|
endAngle?: number | undefined;
|
|
14
|
-
innerRadius?: undefined;
|
|
15
|
-
outerRadius?: undefined;
|
|
14
|
+
innerRadius?: number | undefined;
|
|
15
|
+
outerRadius?: number | undefined;
|
|
16
16
|
cornerRadius?: number | undefined;
|
|
17
17
|
padAngle?: number | undefined;
|
|
18
18
|
track?: boolean | SVGAttributes<SVGPathElement> | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
|
-
import { format as formatValue } from 'svelte-ux';
|
|
2
|
+
import { format as formatValue, cls } from 'svelte-ux';
|
|
3
3
|
import { max, min } from 'd3-array';
|
|
4
4
|
import Text from './Text.svelte';
|
|
5
5
|
import { isScaleBand } from '../utils/scales';
|
|
@@ -79,14 +79,15 @@ function getDefaultLabelProps() {
|
|
|
79
79
|
{@const tickCoords = getCoords(tick)}
|
|
80
80
|
<g>
|
|
81
81
|
{#if gridlines !== false}
|
|
82
|
+
{@const lineProps = typeof gridlines === 'object' ? gridlines : null}
|
|
82
83
|
{#if orientation === 'horizontal'}
|
|
83
84
|
<line
|
|
84
85
|
x1={tickCoords.x}
|
|
85
86
|
y1={min($yRange)}
|
|
86
87
|
x2={tickCoords.x}
|
|
87
88
|
y2={max($yRange)}
|
|
88
|
-
|
|
89
|
-
{
|
|
89
|
+
{...lineProps}
|
|
90
|
+
class={cls('gridline stroke-gray-200', lineProps?.class)}
|
|
90
91
|
/>
|
|
91
92
|
{:else if orientation === 'vertical'}
|
|
92
93
|
<line
|
|
@@ -94,8 +95,8 @@ function getDefaultLabelProps() {
|
|
|
94
95
|
y1={tickCoords.y}
|
|
95
96
|
x2={$width}
|
|
96
97
|
y2={tickCoords.y}
|
|
97
|
-
|
|
98
|
-
{
|
|
98
|
+
{...lineProps}
|
|
99
|
+
class={cls('gridline stroke-gray-200', lineProps?.class)}
|
|
99
100
|
/>
|
|
100
101
|
{/if}
|
|
101
102
|
{/if}
|
|
@@ -16,7 +16,7 @@ declare const __propDef: {
|
|
|
16
16
|
yScale?: Function | undefined;
|
|
17
17
|
xBaseline?: number | null | undefined;
|
|
18
18
|
yBaseline?: number | null | undefined;
|
|
19
|
-
tooltip?: ComponentProps<TooltipContext> | undefined;
|
|
19
|
+
tooltip?: ComponentProps<TooltipContext> | boolean | undefined;
|
|
20
20
|
geo?: ComponentProps<GeoContext> | undefined;
|
|
21
21
|
};
|
|
22
22
|
events: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>export let id;
|
|
2
2
|
export let from;
|
|
3
|
-
export let via; // TODO: Currently --tw-gradient-via is not the color but the full stops
|
|
3
|
+
export let via = undefined; // TODO: Currently --tw-gradient-via is not the color but the full stops
|
|
4
4
|
export let to;
|
|
5
5
|
export let vertical = false;
|
|
6
6
|
export let x1 = '0%';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { spring } from 'svelte/motion';
|
|
3
3
|
import { fade } from 'svelte/transition';
|
|
4
4
|
import { writable } from 'svelte/store';
|
|
5
|
+
import { cls } from 'svelte-ux';
|
|
5
6
|
import { tooltipContext } from './TooltipContext.svelte';
|
|
6
7
|
export let topOffset = 10;
|
|
7
8
|
export let leftOffset = 10;
|
|
@@ -15,8 +16,8 @@ let tooltipHeight = 0;
|
|
|
15
16
|
let top = animate ? spring($tooltip.top) : writable($tooltip.top);
|
|
16
17
|
$: if ($tooltip) {
|
|
17
18
|
if (contained === 'container' && $tooltip.top + topOffset + tooltipHeight > $containerHeight) {
|
|
18
|
-
//
|
|
19
|
-
$top = $tooltip.top - (topOffset + tooltipHeight);
|
|
19
|
+
// Change side. Do not allow tooltip to go above the top
|
|
20
|
+
$top = Math.max($tooltip.top - (topOffset + tooltipHeight), 0);
|
|
20
21
|
}
|
|
21
22
|
else {
|
|
22
23
|
$top = $tooltip.top + topOffset;
|
|
@@ -25,8 +26,8 @@ $: if ($tooltip) {
|
|
|
25
26
|
let left = animate ? spring($tooltip.left) : writable($tooltip.left);
|
|
26
27
|
$: if ($tooltip) {
|
|
27
28
|
if (contained === 'container' && $tooltip.left + leftOffset + tooltipWidth > $containerWidth) {
|
|
28
|
-
//
|
|
29
|
-
$left = $tooltip.left - (leftOffset + tooltipWidth);
|
|
29
|
+
// Change side
|
|
30
|
+
$left = Math.max($tooltip.left - (leftOffset + tooltipWidth), 0);
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
33
|
$left = $tooltip.left + leftOffset;
|
|
@@ -36,7 +37,7 @@ $: if ($tooltip) {
|
|
|
36
37
|
|
|
37
38
|
{#if $tooltip.data}
|
|
38
39
|
<div
|
|
39
|
-
class=
|
|
40
|
+
class={cls('absolute pointer-events-none z-50', $$props.class)}
|
|
40
41
|
style:top="{$top}px"
|
|
41
42
|
style:left="{$left}px"
|
|
42
43
|
transition:fade={{ duration: 100 }}
|
|
@@ -44,11 +45,11 @@ $: if ($tooltip) {
|
|
|
44
45
|
bind:clientHeight={tooltipHeight}
|
|
45
46
|
>
|
|
46
47
|
<div
|
|
47
|
-
class="bg-gray-900/90 backdrop-filter backdrop-blur-[2px] text-white rounded elevation-1 px-2 py-1"
|
|
48
|
+
class="bg-gray-900/90 backdrop-filter backdrop-blur-[2px] text-white rounded elevation-1 px-2 py-1 h-full"
|
|
48
49
|
>
|
|
49
50
|
{#if header || $$slots.header}
|
|
50
51
|
<div class="text-center font-semibold whitespace-nowrap">
|
|
51
|
-
<slot name="header">
|
|
52
|
+
<slot name="header" data={$tooltip.data}>
|
|
52
53
|
{header($tooltip.data)}
|
|
53
54
|
</slot>
|
|
54
55
|
</div>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
+
[x: string]: any;
|
|
4
5
|
topOffset?: number | undefined;
|
|
5
6
|
leftOffset?: number | undefined;
|
|
6
7
|
contained?: false | "container" | undefined;
|
|
@@ -11,7 +12,9 @@ declare const __propDef: {
|
|
|
11
12
|
[evt: string]: CustomEvent<any>;
|
|
12
13
|
};
|
|
13
14
|
slots: {
|
|
14
|
-
header: {
|
|
15
|
+
header: {
|
|
16
|
+
data: any;
|
|
17
|
+
};
|
|
15
18
|
default: {
|
|
16
19
|
data: any;
|
|
17
20
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "techniq/layerchart",
|
|
6
|
-
"version": "0.17.
|
|
6
|
+
"version": "0.17.2",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite dev",
|
|
9
9
|
"build": "vite build",
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
"d3-shape": "^3.2.0",
|
|
72
72
|
"d3-tile": "^1.0.0",
|
|
73
73
|
"date-fns": "^2.30.0",
|
|
74
|
-
"layercake": "^7.
|
|
74
|
+
"layercake": "^7.6.0",
|
|
75
75
|
"lodash-es": "^4.17.21",
|
|
76
76
|
"shapefile": "^0.6.6",
|
|
77
77
|
"svelte": "^3.59.1",
|
|
78
|
-
"svelte-ux": "^0.43.
|
|
78
|
+
"svelte-ux": "^0.43.3",
|
|
79
79
|
"topojson-client": "^3.1.0"
|
|
80
80
|
},
|
|
81
81
|
"main": "./dist/index.js",
|