layerchart 0.91.1 → 0.92.0
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/Axis.svelte +16 -7
- package/package.json +1 -1
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
import { cubicIn } from 'svelte/easing';
|
|
5
5
|
import type { SVGAttributes } from 'svelte/elements';
|
|
6
6
|
import type { spring as springStore, tweened as tweenedStore } from 'svelte/motion';
|
|
7
|
+
import type { TimeInterval } from 'd3-time';
|
|
7
8
|
|
|
8
9
|
import { extent } from 'd3-array';
|
|
9
10
|
import { pointRadial } from 'd3-shape';
|
|
10
11
|
|
|
11
|
-
import { format as formatValue, type FormatType } from '@layerstack/utils';
|
|
12
|
+
import { format as formatValue, isLiteralObject, type FormatType } from '@layerstack/utils';
|
|
12
13
|
import { cls } from '@layerstack/tailwind';
|
|
13
14
|
import type { TransitionParams } from 'svelte-ux'; // TODO: Replace with `@layerstack/svelte-types` or similar
|
|
14
15
|
|
|
@@ -39,7 +40,13 @@
|
|
|
39
40
|
export let grid: boolean | Pick<SVGAttributes<SVGElement>, 'class' | 'style'> = false;
|
|
40
41
|
|
|
41
42
|
/** Control the number of ticks*/
|
|
42
|
-
export let ticks:
|
|
43
|
+
export let ticks:
|
|
44
|
+
| number
|
|
45
|
+
| any[]
|
|
46
|
+
| ((scale: AnyScale) => any)
|
|
47
|
+
| { interval: TimeInterval | null }
|
|
48
|
+
| null
|
|
49
|
+
| undefined = undefined;
|
|
43
50
|
|
|
44
51
|
/** Length of the tick line */
|
|
45
52
|
export let tickLength = 4;
|
|
@@ -87,11 +94,13 @@
|
|
|
87
94
|
? ticks
|
|
88
95
|
: typeof ticks === 'function'
|
|
89
96
|
? ticks(_scale)
|
|
90
|
-
:
|
|
91
|
-
? ticks
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
: isLiteralObject(ticks)
|
|
98
|
+
? _scale.ticks(ticks.interval) // d3-time interval such as `timeDay.every(1)`
|
|
99
|
+
: isScaleBand(_scale)
|
|
100
|
+
? ticks
|
|
101
|
+
? _scale.domain().filter((v: any, i: number) => i % ticks === 0)
|
|
102
|
+
: _scale.domain()
|
|
103
|
+
: _scale.ticks(ticks ?? (placement === 'left' || placement === 'right' ? 4 : undefined));
|
|
95
104
|
|
|
96
105
|
function getCoords(tick: any) {
|
|
97
106
|
switch (placement) {
|