layerchart 0.8.0 → 0.9.1
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/components/AxisX.svelte +4 -14
- package/components/AxisX.svelte.d.ts +3 -0
- package/components/AxisY.svelte +4 -13
- package/components/AxisY.svelte.d.ts +3 -0
- package/components/Chart.svelte +3 -3
- package/components/Chart.svelte.d.ts +3 -3
- package/components/TooltipContainer.svelte +18 -0
- package/components/TooltipContainer.svelte.d.ts +19 -0
- package/components/TooltipItem.svelte +18 -0
- package/components/TooltipItem.svelte.d.ts +21 -0
- package/components/TooltipSeparator.svelte +1 -0
- package/components/TooltipSeparator.svelte.d.ts +19 -0
- package/components/index.d.ts +3 -0
- package/components/index.js +3 -0
- package/package.json +5 -2
package/components/AxisX.svelte
CHANGED
|
@@ -11,6 +11,7 @@ export let xTick = undefined;
|
|
|
11
11
|
export let yTick = 8;
|
|
12
12
|
export let dxTick = 0;
|
|
13
13
|
export let dyTick = 0;
|
|
14
|
+
export let labelProps = undefined;
|
|
14
15
|
$: isBand = isScaleBand($xScale);
|
|
15
16
|
$: tickVals = Array.isArray(ticks)
|
|
16
17
|
? ticks
|
|
@@ -23,7 +24,7 @@ $: tickVals = Array.isArray(ticks)
|
|
|
23
24
|
{#each tickVals as tick, i}
|
|
24
25
|
<g class="tick tick-{tick}" transform="translate({$xScale(tick)},{max($yRange)})">
|
|
25
26
|
{#if gridlines !== false}
|
|
26
|
-
<line y1={$height * -1} y2="0" x1="0" x2="0" {...gridlines} />
|
|
27
|
+
<line y1={$height * -1} y2="0" x1="0" x2="0" class="stroke-gray-200" {...gridlines} />
|
|
27
28
|
{/if}
|
|
28
29
|
<Text
|
|
29
30
|
x={xTick || isBand ? $xScale.bandwidth() / 2 : 0}
|
|
@@ -33,21 +34,10 @@ $: tickVals = Array.isArray(ticks)
|
|
|
33
34
|
rotate={315}
|
|
34
35
|
textAnchor="end"
|
|
35
36
|
verticalAnchor="middle"
|
|
36
|
-
|
|
37
|
+
class="text-[10px] stroke-white [stroke-width: 2px] font-light"
|
|
37
38
|
value={format(tick, formatTick ?? $xScale.tickFormat?.())}
|
|
39
|
+
{...labelProps}
|
|
38
40
|
/>
|
|
39
41
|
</g>
|
|
40
42
|
{/each}
|
|
41
43
|
</g>
|
|
42
|
-
|
|
43
|
-
<style>
|
|
44
|
-
.tick {
|
|
45
|
-
font-size: 0.725em;
|
|
46
|
-
font-weight: 200;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
line,
|
|
50
|
-
.tick line {
|
|
51
|
-
stroke: #e0e0e0;
|
|
52
|
-
}
|
|
53
|
-
</style>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { FormatType } from 'svelte-ux/utils/format';
|
|
3
|
+
import Text from './Text.svelte';
|
|
4
|
+
import type { ComponentProps } from 'svelte-ux';
|
|
3
5
|
declare const __propDef: {
|
|
4
6
|
props: {
|
|
5
7
|
gridlines?: boolean | svelte.JSX.SVGProps<SVGLineElement>;
|
|
@@ -9,6 +11,7 @@ declare const __propDef: {
|
|
|
9
11
|
yTick?: number;
|
|
10
12
|
dxTick?: number;
|
|
11
13
|
dyTick?: number;
|
|
14
|
+
labelProps?: ComponentProps<Text>;
|
|
12
15
|
};
|
|
13
16
|
events: {
|
|
14
17
|
[evt: string]: CustomEvent<any>;
|
package/components/AxisY.svelte
CHANGED
|
@@ -11,6 +11,7 @@ export let xTick = 0;
|
|
|
11
11
|
export let yTick = 0;
|
|
12
12
|
export let dxTick = 0;
|
|
13
13
|
export let dyTick = -3; // TODO: Maualliy tweak based on font-size until <Text /> handles custom styles
|
|
14
|
+
export let labelProps = undefined;
|
|
14
15
|
$: isBand = isScaleBand($yScale);
|
|
15
16
|
$: tickVals = Array.isArray(ticks)
|
|
16
17
|
? ticks
|
|
@@ -28,6 +29,7 @@ $: tickVals = Array.isArray(ticks)
|
|
|
28
29
|
x2={$width + $padding.left}
|
|
29
30
|
y1={yTick + (isBand ? $yScale.bandwidth() / 2 : 0)}
|
|
30
31
|
y2={yTick + (isBand ? $yScale.bandwidth() / 2 : 0)}
|
|
32
|
+
class="stroke-gray-200"
|
|
31
33
|
{...gridlines}
|
|
32
34
|
/>
|
|
33
35
|
{/if}
|
|
@@ -44,21 +46,10 @@ $: tickVals = Array.isArray(ticks)
|
|
|
44
46
|
dy={dyTick}
|
|
45
47
|
textAnchor="end"
|
|
46
48
|
verticalAnchor="middle"
|
|
47
|
-
style="font-size: 10px; stroke: white; stroke-width: 2px;"
|
|
48
49
|
value={format(tick, formatTick ?? $yScale.tickFormat?.())}
|
|
50
|
+
class="text-[10px] stroke-white [stroke-width: 2px] font-light"
|
|
51
|
+
{...labelProps}
|
|
49
52
|
/>
|
|
50
53
|
</g>
|
|
51
54
|
{/each}
|
|
52
55
|
</g>
|
|
53
|
-
|
|
54
|
-
<style>
|
|
55
|
-
.tick {
|
|
56
|
-
font-size: 0.725em;
|
|
57
|
-
font-weight: 200;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.tick line {
|
|
61
|
-
stroke: #e0e0e0;
|
|
62
|
-
/* stroke-dasharray: 2; */
|
|
63
|
-
}
|
|
64
|
-
</style>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { FormatType } from 'svelte-ux/utils/format';
|
|
3
|
+
import Text from './Text.svelte';
|
|
4
|
+
import type { ComponentProps } from 'svelte-ux';
|
|
3
5
|
declare const __propDef: {
|
|
4
6
|
props: {
|
|
5
7
|
gridlines?: boolean | svelte.JSX.SVGProps<SVGLineElement>;
|
|
@@ -9,6 +11,7 @@ declare const __propDef: {
|
|
|
9
11
|
yTick?: number;
|
|
10
12
|
dxTick?: number;
|
|
11
13
|
dyTick?: number;
|
|
14
|
+
labelProps?: ComponentProps<Text>;
|
|
12
15
|
};
|
|
13
16
|
events: {
|
|
14
17
|
[evt: string]: CustomEvent<any>;
|
package/components/Chart.svelte
CHANGED
|
@@ -23,9 +23,9 @@ function getValue(accessor, d) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
export let data = [];
|
|
26
|
-
export let x;
|
|
27
|
-
export let y;
|
|
28
|
-
export let yScale;
|
|
26
|
+
export let x = undefined;
|
|
27
|
+
export let y = undefined;
|
|
28
|
+
export let yScale = undefined;
|
|
29
29
|
/**
|
|
30
30
|
* xBaseline guaranteed to be visible in xDomain
|
|
31
31
|
*/
|
|
@@ -5,9 +5,9 @@ declare const __propDef: {
|
|
|
5
5
|
props: {
|
|
6
6
|
[x: string]: any;
|
|
7
7
|
data?: any[];
|
|
8
|
-
x
|
|
9
|
-
y
|
|
10
|
-
yScale
|
|
8
|
+
x?: (string | ((d: any) => number)) | (string | ((d: any) => number))[];
|
|
9
|
+
y?: (string | ((d: any) => number)) | (string | ((d: any) => number))[];
|
|
10
|
+
yScale?: Function;
|
|
11
11
|
xBaseline?: number | null;
|
|
12
12
|
yBaseline?: number | null;
|
|
13
13
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>export let header = undefined;
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<div
|
|
5
|
+
class="bg-gray-900/90 backdrop-filter backdrop-blur-[2px] text-white rounded elevation-1 px-2 py-1"
|
|
6
|
+
>
|
|
7
|
+
{#if header || $$slots.header}
|
|
8
|
+
<div class="text-center font-semibold pb-1 whitespace-nowrap">
|
|
9
|
+
<slot name="header">
|
|
10
|
+
{header}
|
|
11
|
+
</slot>
|
|
12
|
+
</div>
|
|
13
|
+
{/if}
|
|
14
|
+
|
|
15
|
+
<div class="grid grid-cols-[1fr,auto] gap-x-2 gap-y-1 items-center">
|
|
16
|
+
<slot />
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
header?: any;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
header: {};
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare type TooltipContainerProps = typeof __propDef.props;
|
|
15
|
+
export declare type TooltipContainerEvents = typeof __propDef.events;
|
|
16
|
+
export declare type TooltipContainerSlots = typeof __propDef.slots;
|
|
17
|
+
export default class TooltipContainer extends SvelteComponentTyped<TooltipContainerProps, TooltipContainerEvents, TooltipContainerSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>import clsx from 'clsx';
|
|
2
|
+
export let label;
|
|
3
|
+
export let value;
|
|
4
|
+
export let valueAlign = 'left';
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="text-xs text-white/75 text-right whitespace-nowrap">
|
|
8
|
+
<slot name="label">{label}:</slot>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div
|
|
12
|
+
class={clsx('text-sm tabular-nums', {
|
|
13
|
+
'text-right': valueAlign === 'right',
|
|
14
|
+
'text-center': valueAlign === 'center'
|
|
15
|
+
})}
|
|
16
|
+
>
|
|
17
|
+
<slot>{value}</slot>
|
|
18
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
label: any;
|
|
5
|
+
value: any;
|
|
6
|
+
valueAlign?: 'left' | 'right' | 'center';
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {
|
|
12
|
+
label: {};
|
|
13
|
+
default: {};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare type TooltipItemProps = typeof __propDef.props;
|
|
17
|
+
export declare type TooltipItemEvents = typeof __propDef.events;
|
|
18
|
+
export declare type TooltipItemSlots = typeof __propDef.slots;
|
|
19
|
+
export default class TooltipItem extends SvelteComponentTyped<TooltipItemProps, TooltipItemEvents, TooltipItemSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="rounded bg-white/50 my-1 col-span-full h-px" />
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TooltipSeparatorProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TooltipSeparatorEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TooltipSeparatorSlots */
|
|
4
|
+
export default class TooltipSeparator extends SvelteComponentTyped<{}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> {
|
|
7
|
+
}
|
|
8
|
+
export type TooltipSeparatorProps = typeof __propDef.props;
|
|
9
|
+
export type TooltipSeparatorEvents = typeof __propDef.events;
|
|
10
|
+
export type TooltipSeparatorSlots = typeof __propDef.slots;
|
|
11
|
+
import { SvelteComponentTyped } from "svelte";
|
|
12
|
+
declare const __propDef: {
|
|
13
|
+
props: {};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
export {};
|
package/components/index.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export { default as Sankey } from './Sankey.svelte';
|
|
|
32
32
|
export { default as Text } from './Text.svelte';
|
|
33
33
|
export { default as Threshold } from './Threshold.svelte';
|
|
34
34
|
export { default as Tooltip } from './Tooltip.svelte';
|
|
35
|
+
export { default as TooltipContainer } from './TooltipContainer.svelte';
|
|
36
|
+
export { default as TooltipItem } from './TooltipItem.svelte';
|
|
37
|
+
export { default as TooltipSeparator } from './TooltipSeparator.svelte';
|
|
35
38
|
export { default as Tree } from './Tree.svelte';
|
|
36
39
|
export { default as Treemap } from './Treemap.svelte';
|
|
37
40
|
export { default as Zoom } from './Zoom.svelte';
|
package/components/index.js
CHANGED
|
@@ -32,6 +32,9 @@ export { default as Sankey } from './Sankey.svelte';
|
|
|
32
32
|
export { default as Text } from './Text.svelte';
|
|
33
33
|
export { default as Threshold } from './Threshold.svelte';
|
|
34
34
|
export { default as Tooltip } from './Tooltip.svelte';
|
|
35
|
+
export { default as TooltipContainer } from './TooltipContainer.svelte';
|
|
36
|
+
export { default as TooltipItem } from './TooltipItem.svelte';
|
|
37
|
+
export { default as TooltipSeparator } from './TooltipSeparator.svelte';
|
|
35
38
|
export { default as Tree } from './Tree.svelte';
|
|
36
39
|
export { default as Treemap } from './Treemap.svelte';
|
|
37
40
|
export { default as Zoom } from './Zoom.svelte';
|
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.
|
|
6
|
+
"version": "0.9.1",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@rollup/plugin-dsv": "^2.0.3",
|
|
9
9
|
"@sveltejs/adapter-vercel": "^1.0.0-next.59",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"date-fns": "^2.28.0",
|
|
50
50
|
"layercake": "^6.1.0",
|
|
51
51
|
"lodash-es": "^4.17.21",
|
|
52
|
-
"svelte-ux": "^0.
|
|
52
|
+
"svelte-ux": "^0.8.8"
|
|
53
53
|
},
|
|
54
54
|
"exports": {
|
|
55
55
|
"./package.json": "./package.json",
|
|
@@ -87,6 +87,9 @@
|
|
|
87
87
|
"./components/Text.svelte": "./components/Text.svelte",
|
|
88
88
|
"./components/Threshold.svelte": "./components/Threshold.svelte",
|
|
89
89
|
"./components/Tooltip.svelte": "./components/Tooltip.svelte",
|
|
90
|
+
"./components/TooltipContainer.svelte": "./components/TooltipContainer.svelte",
|
|
91
|
+
"./components/TooltipItem.svelte": "./components/TooltipItem.svelte",
|
|
92
|
+
"./components/TooltipSeparator.svelte": "./components/TooltipSeparator.svelte",
|
|
90
93
|
"./components/Tree.svelte": "./components/Tree.svelte",
|
|
91
94
|
"./components/Treemap.svelte": "./components/Treemap.svelte",
|
|
92
95
|
"./components/Zoom.svelte": "./components/Zoom.svelte",
|