layerchart 2.0.0-next.1 → 2.0.0-next.11
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/actions/movable.d.ts +28 -0
- package/dist/actions/movable.js +91 -0
- package/dist/components/AnnotationLine.svelte +143 -0
- package/dist/components/AnnotationLine.svelte.d.ts +30 -0
- package/dist/components/AnnotationPoint.svelte +119 -0
- package/dist/components/AnnotationPoint.svelte.d.ts +34 -0
- package/dist/components/AnnotationRange.svelte +147 -0
- package/dist/components/AnnotationRange.svelte.d.ts +40 -0
- package/dist/components/Arc.svelte +344 -151
- package/dist/components/Arc.svelte.d.ts +138 -0
- package/dist/components/Area.svelte +165 -149
- package/dist/components/Area.svelte.d.ts +45 -0
- package/dist/components/Axis.svelte +320 -179
- package/dist/components/Axis.svelte.d.ts +127 -0
- package/dist/components/Bar.svelte +166 -107
- package/dist/components/Bar.svelte.d.ts +51 -0
- package/dist/components/Bars.svelte +56 -67
- package/dist/components/Bars.svelte.d.ts +27 -0
- package/dist/components/Blur.svelte +42 -12
- package/dist/components/Blur.svelte.d.ts +23 -21
- package/dist/components/Bounds.svelte +49 -19
- package/dist/components/Bounds.svelte.d.ts +24 -50
- package/dist/components/BrushContext.svelte +296 -168
- package/dist/components/BrushContext.svelte.d.ts +97 -65
- package/dist/components/Calendar.svelte +116 -59
- package/dist/components/Calendar.svelte.d.ts +50 -31
- package/dist/components/Chart.svelte +1289 -398
- package/dist/components/Chart.svelte.d.ts +535 -410
- package/dist/components/ChartClipPath.svelte +37 -15
- package/dist/components/ChartClipPath.svelte.d.ts +21 -19
- package/dist/components/Circle.svelte +124 -85
- package/dist/components/Circle.svelte.d.ts +52 -0
- package/dist/components/CircleClipPath.svelte +76 -16
- package/dist/components/CircleClipPath.svelte.d.ts +46 -0
- package/dist/components/ClipPath.svelte +71 -21
- package/dist/components/ClipPath.svelte.d.ts +40 -27
- package/dist/components/ColorRamp.svelte +75 -9
- package/dist/components/ColorRamp.svelte.d.ts +37 -19
- package/dist/components/ComputedStyles.svelte +17 -5
- package/dist/components/ComputedStyles.svelte.d.ts +11 -19
- package/dist/components/Connector.svelte +149 -0
- package/dist/components/Connector.svelte.d.ts +51 -0
- package/dist/components/Dagre.svelte +211 -122
- package/dist/components/Dagre.svelte.d.ts +119 -56
- package/dist/components/ForceSimulation.svelte +215 -90
- package/dist/components/ForceSimulation.svelte.d.ts +82 -35
- package/dist/components/Frame.svelte +33 -13
- package/dist/components/Frame.svelte.d.ts +13 -17
- package/dist/components/GeoCircle.svelte +29 -16
- package/dist/components/GeoCircle.svelte.d.ts +22 -24
- package/dist/components/GeoContext.svelte +113 -72
- package/dist/components/GeoContext.svelte.d.ts +49 -41
- package/dist/components/GeoEdgeFade.svelte +49 -13
- package/dist/components/GeoEdgeFade.svelte.d.ts +17 -19
- package/dist/components/GeoPath.svelte +157 -127
- package/dist/components/GeoPath.svelte.d.ts +48 -36
- package/dist/components/GeoPoint.svelte +52 -20
- package/dist/components/GeoPoint.svelte.d.ts +25 -22
- package/dist/components/GeoSpline.svelte +75 -26
- package/dist/components/GeoSpline.svelte.d.ts +29 -20
- package/dist/components/GeoTile.svelte +100 -49
- package/dist/components/GeoTile.svelte.d.ts +38 -23
- package/dist/components/GeoVisible.svelte +17 -9
- package/dist/components/GeoVisible.svelte.d.ts +10 -18
- package/dist/components/Graticule.svelte +30 -14
- package/dist/components/Graticule.svelte.d.ts +11 -52
- package/dist/components/Grid.svelte +230 -117
- package/dist/components/Grid.svelte.d.ts +71 -0
- package/dist/components/Group.svelte +173 -106
- package/dist/components/Group.svelte.d.ts +81 -0
- package/dist/components/Highlight.svelte +410 -308
- package/dist/components/Highlight.svelte.d.ts +107 -0
- package/dist/components/Hull.svelte +97 -46
- package/dist/components/Hull.svelte.d.ts +40 -30
- package/dist/components/Labels.svelte +127 -47
- package/dist/components/Labels.svelte.d.ts +70 -27
- package/dist/components/Legend.svelte +374 -190
- package/dist/components/Legend.svelte.d.ts +95 -44
- package/dist/components/Line.svelte +163 -125
- package/dist/components/Line.svelte.d.ts +75 -0
- package/dist/components/LinearGradient.svelte +153 -78
- package/dist/components/LinearGradient.svelte.d.ts +66 -31
- package/dist/components/Link.svelte +160 -104
- package/dist/components/Link.svelte.d.ts +54 -0
- package/dist/components/Marker.svelte +100 -39
- package/dist/components/Marker.svelte.d.ts +59 -27
- package/dist/components/MarkerWrapper.svelte +35 -0
- package/dist/components/MarkerWrapper.svelte.d.ts +18 -0
- package/dist/components/MonthPath.svelte +65 -20
- package/dist/components/MonthPath.svelte.d.ts +23 -17
- package/dist/components/MotionPath.svelte +80 -24
- package/dist/components/MotionPath.svelte.d.ts +46 -27
- package/dist/components/Pack.svelte +53 -17
- package/dist/components/Pack.svelte.d.ts +42 -21
- package/dist/components/Partition.svelte +64 -22
- package/dist/components/Partition.svelte.d.ts +49 -26
- package/dist/components/Pattern.svelte +297 -11
- package/dist/components/Pattern.svelte.d.ts +103 -19
- package/dist/components/Pie.svelte +122 -76
- package/dist/components/Pie.svelte.d.ts +65 -51
- package/dist/components/Point.svelte +20 -9
- package/dist/components/Point.svelte.d.ts +16 -20
- package/dist/components/Points.svelte +148 -137
- package/dist/components/Points.svelte.d.ts +45 -34
- package/dist/components/RadialGradient.svelte +148 -77
- package/dist/components/RadialGradient.svelte.d.ts +69 -31
- package/dist/components/Rect.svelte +121 -102
- package/dist/components/Rect.svelte.d.ts +36 -0
- package/dist/components/RectClipPath.svelte +82 -18
- package/dist/components/RectClipPath.svelte.d.ts +55 -0
- package/dist/components/Rule.svelte +107 -63
- package/dist/components/Rule.svelte.d.ts +40 -19
- package/dist/components/Sankey.svelte +132 -55
- package/dist/components/Sankey.svelte.d.ts +61 -31
- package/dist/components/Spline.svelte +281 -218
- package/dist/components/Spline.svelte.d.ts +95 -0
- package/dist/components/Text.svelte +463 -197
- package/dist/components/Text.svelte.d.ts +136 -0
- package/dist/components/Threshold.svelte +48 -16
- package/dist/components/Threshold.svelte.d.ts +29 -31
- package/dist/components/TileImage.svelte +103 -30
- package/dist/components/TileImage.svelte.d.ts +48 -23
- package/dist/components/TransformContext.svelte +365 -171
- package/dist/components/TransformControls.svelte +50 -26
- package/dist/components/TransformControls.svelte.d.ts +27 -19
- package/dist/components/Tree.svelte +74 -33
- package/dist/components/Tree.svelte.d.ts +42 -30
- package/dist/components/Treemap.svelte +119 -42
- package/dist/components/Treemap.svelte.d.ts +75 -27
- package/dist/components/Voronoi.svelte +153 -103
- package/dist/components/Voronoi.svelte.d.ts +42 -41
- package/dist/components/charts/ArcChart.svelte +464 -0
- package/dist/components/charts/ArcChart.svelte.d.ts +90 -0
- package/dist/components/charts/AreaChart.svelte +444 -393
- package/dist/components/charts/AreaChart.svelte.d.ts +61 -0
- package/dist/components/charts/BarChart.svelte +463 -389
- package/dist/components/charts/BarChart.svelte.d.ts +76 -0
- package/dist/components/charts/ChartAnnotations.svelte +37 -0
- package/dist/components/charts/ChartAnnotations.svelte.d.ts +10 -0
- package/dist/components/charts/DefaultTooltip.svelte +60 -0
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +10 -0
- package/dist/components/charts/LineChart.svelte +366 -315
- package/dist/components/charts/LineChart.svelte.d.ts +53 -0
- package/dist/components/charts/PieChart.svelte +458 -316
- package/dist/components/charts/PieChart.svelte.d.ts +137 -353
- package/dist/components/charts/ScatterChart.svelte +332 -296
- package/dist/components/charts/ScatterChart.svelte.d.ts +39 -0
- package/dist/components/charts/index.d.ts +8 -0
- package/dist/components/charts/index.js +7 -0
- package/dist/components/charts/types.d.ts +253 -0
- package/dist/components/charts/utils.svelte.d.ts +30 -0
- package/dist/components/charts/utils.svelte.js +59 -0
- package/dist/components/index.d.ts +76 -4
- package/dist/components/index.js +76 -5
- package/dist/components/layout/Canvas.svelte +347 -171
- package/dist/components/layout/Canvas.svelte.d.ts +110 -55
- package/dist/components/layout/Html.svelte +82 -42
- package/dist/components/layout/Html.svelte.d.ts +39 -28
- package/dist/components/layout/Layer.svelte +39 -0
- package/dist/components/layout/Layer.svelte.d.ts +17 -0
- package/dist/components/layout/Svg.svelte +122 -70
- package/dist/components/layout/Svg.svelte.d.ts +53 -34
- package/dist/components/layout/WebGL.svelte +135 -0
- package/dist/components/layout/WebGL.svelte.d.ts +50 -0
- package/dist/components/tooltip/Tooltip.svelte +253 -78
- package/dist/components/tooltip/Tooltip.svelte.d.ts +149 -31
- package/dist/components/tooltip/TooltipContext.svelte +426 -271
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +86 -55
- package/dist/components/tooltip/TooltipHeader.svelte +100 -11
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +43 -23
- package/dist/components/tooltip/TooltipItem.svelte +167 -27
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +63 -31
- package/dist/components/tooltip/TooltipList.svelte +22 -3
- package/dist/components/tooltip/TooltipList.svelte.d.ts +6 -17
- package/dist/components/tooltip/TooltipSeparator.svelte +27 -1
- package/dist/components/tooltip/TooltipSeparator.svelte.d.ts +6 -15
- package/dist/components/tooltip/index.d.ts +6 -0
- package/dist/components/tooltip/index.js +6 -0
- package/dist/components/tooltip/tooltipMetaContext.d.ts +79 -0
- package/dist/components/tooltip/tooltipMetaContext.js +139 -0
- package/dist/components/types.d.ts +1 -0
- package/dist/components/types.js +1 -0
- package/dist/docs/Blockquote.svelte +3 -1
- package/dist/docs/Blockquote.svelte.d.ts +5 -16
- package/dist/docs/Code.svelte +20 -12
- package/dist/docs/Code.svelte.d.ts +12 -22
- package/dist/docs/ConnectorSweepMenuField.svelte +17 -0
- package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +7 -0
- package/dist/docs/ConnectorTypeMenuField.svelte +17 -0
- package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +7 -0
- package/dist/docs/CurveMenuField.svelte +14 -3
- package/dist/docs/CurveMenuField.svelte.d.ts +9 -18
- package/dist/docs/GeoDebug.svelte +47 -42
- package/dist/docs/GeoDebug.svelte.d.ts +4 -16
- package/dist/docs/Header1.svelte +4 -2
- package/dist/docs/Header1.svelte.d.ts +5 -18
- package/dist/docs/Json.svelte +11 -3
- package/dist/docs/Json.svelte.d.ts +9 -17
- package/dist/docs/Layout.svelte +10 -7
- package/dist/docs/Layout.svelte.d.ts +5 -15
- package/dist/docs/Link.svelte +7 -3
- package/dist/docs/Link.svelte.d.ts +5 -27
- package/dist/docs/PathDataMenuField.svelte +14 -10
- package/dist/docs/PathDataMenuField.svelte.d.ts +8 -18
- package/dist/docs/Preview.svelte +20 -7
- package/dist/docs/Preview.svelte.d.ts +12 -22
- package/dist/docs/TilesetField.svelte +20 -19
- package/dist/docs/TilesetField.svelte.d.ts +6 -19
- package/dist/docs/TransformDebug.svelte +5 -6
- package/dist/docs/TransformDebug.svelte.d.ts +18 -14
- package/dist/docs/ViewSourceButton.svelte +7 -4
- package/dist/docs/ViewSourceButton.svelte.d.ts +8 -18
- package/dist/types/d3-shape-extentions.d.ts +7 -0
- package/dist/utils/afterTick.d.ts +5 -0
- package/dist/utils/afterTick.js +8 -0
- package/dist/utils/arcText.svelte.d.ts +57 -0
- package/dist/utils/arcText.svelte.js +262 -0
- package/dist/utils/array.d.ts +9 -1
- package/dist/utils/array.js +13 -0
- package/dist/utils/attributes.d.ts +29 -0
- package/dist/utils/attributes.js +40 -0
- package/dist/utils/canvas.js +47 -10
- package/dist/utils/chart.d.ts +78 -0
- package/dist/utils/chart.js +512 -0
- package/dist/utils/color.d.ts +1 -0
- package/dist/utils/color.js +8 -0
- package/dist/utils/common.d.ts +3 -5
- package/dist/utils/common.js +3 -2
- package/dist/utils/connectorUtils.d.ts +21 -0
- package/dist/utils/connectorUtils.js +111 -0
- package/dist/utils/createId.d.ts +7 -0
- package/dist/utils/createId.js +9 -0
- package/dist/utils/debug.d.ts +1 -0
- package/dist/utils/debug.js +84 -0
- package/dist/utils/filterObject.d.ts +9 -0
- package/dist/utils/filterObject.js +12 -0
- package/dist/utils/graph/dagre.d.ts +34 -0
- package/dist/utils/graph/dagre.js +78 -0
- package/dist/utils/graph/dagre.test.d.ts +1 -0
- package/dist/utils/{graph.test.js → graph/dagre.test.js} +19 -33
- package/dist/utils/graph/sankey.d.ts +28 -0
- package/dist/utils/{graph.js → graph/sankey.js} +13 -41
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/key.svelte.d.ts +3 -0
- package/dist/utils/key.svelte.js +11 -0
- package/dist/utils/legendPayload.d.ts +7 -0
- package/dist/utils/legendPayload.js +8 -0
- package/dist/utils/motion.svelte.d.ts +140 -0
- package/dist/utils/motion.svelte.js +180 -0
- package/dist/utils/motion.test.d.ts +1 -0
- package/dist/utils/motion.test.js +213 -0
- package/dist/utils/{rect.d.ts → rect.svelte.d.ts} +7 -4
- package/dist/utils/rect.svelte.js +105 -0
- package/dist/utils/scales.svelte.d.ts +91 -0
- package/dist/utils/scales.svelte.js +201 -0
- package/dist/utils/stack.d.ts +2 -3
- package/dist/utils/stack.js +1 -1
- package/dist/utils/string.js +87 -0
- package/dist/utils/ticks.d.ts +9 -3
- package/dist/utils/ticks.js +122 -147
- package/dist/utils/ticks.test.d.ts +1 -0
- package/dist/utils/ticks.test.js +57 -0
- package/dist/utils/types.d.ts +81 -0
- package/package.json +28 -24
- package/dist/components/ChartContext.svelte +0 -295
- package/dist/components/ChartContext.svelte.d.ts +0 -139
- package/dist/components/TransformContext.svelte.d.ts +0 -158
- package/dist/stores/motionStore.d.ts +0 -30
- package/dist/stores/motionStore.js +0 -62
- package/dist/utils/graph.d.ts +0 -37
- package/dist/utils/rect.js +0 -107
- package/dist/utils/scales.d.ts +0 -66
- package/dist/utils/scales.js +0 -136
- /package/dist/{utils/graph.test.d.ts → components/charts/types.js} +0 -0
package/dist/utils/ticks.js
CHANGED
|
@@ -1,155 +1,130 @@
|
|
|
1
|
-
import { timeYear, timeMonth,
|
|
2
|
-
import { format } from '
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
format: (date) => date.toString(),
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
predicate: (duration) => duration.years > 1,
|
|
13
|
-
interval: timeYear.every(1),
|
|
14
|
-
format: (date) => formatDate(date, PeriodType.CalendarYear, { variant: 'short' }),
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
predicate: (duration) => duration.years,
|
|
18
|
-
interval: timeMonth.every(1),
|
|
19
|
-
format: (date) => formatDate(date, PeriodType.Month, { variant: 'short' }),
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
predicate: (duration) => duration.days > 30,
|
|
23
|
-
interval: timeMonth.every(1),
|
|
24
|
-
format: (date) => formatDate(date, PeriodType.Month, { variant: 'short' }),
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
predicate: (duration) => duration.days,
|
|
28
|
-
interval: timeDay.every(1),
|
|
29
|
-
format: (date) => formatDate(date, PeriodType.Day, { variant: 'short' }),
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
predicate: (duration) => duration.hours,
|
|
33
|
-
interval: timeHour.every(1),
|
|
34
|
-
format: (date) => format(date, 'h:mm a'),
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
predicate: (duration) => duration.minutes > 10,
|
|
38
|
-
interval: timeMinute.every(10),
|
|
39
|
-
format: (date) => format(date, 'h:mm a'),
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
predicate: (duration) => duration.minutes,
|
|
43
|
-
interval: timeMinute.every(1),
|
|
44
|
-
format: (date) => format(date, 'h:mm a'),
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
predicate: (duration) => duration.seconds > 10,
|
|
48
|
-
interval: timeSecond.every(10),
|
|
49
|
-
format: (date) => format(date, 'h:mm:ss'),
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
predicate: (duration) => duration.seconds,
|
|
53
|
-
interval: timeSecond.every(1),
|
|
54
|
-
format: (date) => format(date, 'h:mm:ss'),
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
predicate: (duration) => true, // 0 or more milliseconds
|
|
58
|
-
interval: timeMillisecond.every(100),
|
|
59
|
-
format: (date) => format(date, 'h:mm:ss.SSS'),
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
const minorTicks = [
|
|
63
|
-
{
|
|
64
|
-
predicate: (duration) => duration == null, // Unknown
|
|
65
|
-
interval: timeYear.every(1), // Better than rendering a lot of items
|
|
66
|
-
format: (date) => date.toString(),
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
predicate: (duration) => duration.years,
|
|
70
|
-
interval: timeMonth.every(1),
|
|
71
|
-
format: (date) => formatDate(date, PeriodType.Month, { variant: 'short' }),
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
predicate: (duration) => duration.days > 90,
|
|
75
|
-
interval: timeMonth.every(1),
|
|
76
|
-
format: (date) => formatDate(date, PeriodType.Month, { variant: 'short' }),
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
predicate: (duration) => duration.days > 30,
|
|
80
|
-
interval: timeWeek.every(1),
|
|
81
|
-
format: (date) => formatDate(date, PeriodType.WeekSun, { variant: 'short' }),
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
predicate: (duration) => duration.days > 7,
|
|
85
|
-
interval: timeDay.every(1),
|
|
86
|
-
format: (date) => formatDate(date, PeriodType.Day, { variant: 'short' }),
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
predicate: (duration) => duration.days > 3,
|
|
90
|
-
interval: timeHour.every(8),
|
|
91
|
-
format: (date) => format(date, 'h:mm a'),
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
predicate: (duration) => duration.days,
|
|
95
|
-
interval: timeHour.every(1),
|
|
96
|
-
format: (date) => format(date, 'h:mm a'),
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
predicate: (duration) => duration.hours,
|
|
100
|
-
interval: timeMinute.every(15),
|
|
101
|
-
format: (date) => format(date, 'h:mm a'),
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
predicate: (duration) => duration.minutes > 10,
|
|
105
|
-
interval: timeMinute.every(10),
|
|
106
|
-
format: (date) => format(date, 'h:mm a'),
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
predicate: (duration) => duration.minutes > 2,
|
|
110
|
-
interval: timeMinute.every(1),
|
|
111
|
-
format: (date) => format(date, 'h:mm a'),
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
predicate: (duration) => duration.minutes,
|
|
115
|
-
interval: timeSecond.every(10),
|
|
116
|
-
format: (date) => format(date, 'h:mm:ss'),
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
predicate: (duration) => duration.seconds,
|
|
120
|
-
interval: timeSecond.every(1),
|
|
121
|
-
format: (date) => format(date, 'h:mm:ss'),
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
predicate: (duration) => true, // 0 or more milliseconds
|
|
125
|
-
interval: timeMillisecond.every(10),
|
|
126
|
-
format: (date) => format(date, 'h:mm:ss.SSS'),
|
|
127
|
-
},
|
|
128
|
-
];
|
|
129
|
-
export function getMajorTicks(start, end) {
|
|
130
|
-
const duration = getDuration(start, end);
|
|
131
|
-
for (var t of majorTicks) {
|
|
132
|
-
if (t.predicate(duration)) {
|
|
133
|
-
return t.interval;
|
|
1
|
+
import { timeYear, timeMonth, timeDay, timeTicks } from 'd3-time';
|
|
2
|
+
import { format, PeriodType, Duration, isLiteralObject, DateToken, } from '@layerstack/utils';
|
|
3
|
+
import { isScaleBand, isScaleTime } from './scales.svelte.js';
|
|
4
|
+
export function getDurationFormat(duration, multiline = false) {
|
|
5
|
+
return function (date, i) {
|
|
6
|
+
if (+duration >= +new Duration({ duration: { years: 1 } })) {
|
|
7
|
+
// Year
|
|
8
|
+
return format(date, PeriodType.CalendarYear);
|
|
134
9
|
}
|
|
135
|
-
|
|
136
|
-
|
|
10
|
+
else if (+duration >= +new Duration({ duration: { days: 28 } })) {
|
|
11
|
+
// Month
|
|
12
|
+
const isFirst = i === 0 || +timeYear.floor(date) === +date;
|
|
13
|
+
if (multiline) {
|
|
14
|
+
return (format(date, PeriodType.Month, { variant: 'short' }) +
|
|
15
|
+
(isFirst ? `\n${format(date, PeriodType.CalendarYear)}` : ''));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return (format(date, PeriodType.Month, { variant: 'short' }) +
|
|
19
|
+
(isFirst ? ` '${format(date, PeriodType.CalendarYear, { variant: 'short' })}` : ''));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (+duration >= +new Duration({ duration: { days: 1 } })) {
|
|
23
|
+
// Day
|
|
24
|
+
const isFirst = i === 0 || date.getDate() < duration.days;
|
|
25
|
+
if (multiline) {
|
|
26
|
+
return (format(date, PeriodType.Custom, { custom: DateToken.DayOfMonth_numeric }) +
|
|
27
|
+
(isFirst ? `\n${format(date, PeriodType.Month, { variant: 'short' })}` : ''));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return format(date, PeriodType.Day, { variant: 'short' });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (+duration >= +new Duration({ duration: { hours: 1 } })) {
|
|
34
|
+
// Hours
|
|
35
|
+
const isFirst = i === 0 || +timeDay.floor(date) === +date;
|
|
36
|
+
if (multiline) {
|
|
37
|
+
return (format(date, PeriodType.Custom, { custom: DateToken.Hour_numeric }) +
|
|
38
|
+
(isFirst ? `\n${format(date, PeriodType.Day, { variant: 'short' })}` : ''));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return isFirst
|
|
42
|
+
? format(date, PeriodType.Day, { variant: 'short' })
|
|
43
|
+
: format(date, PeriodType.Custom, { custom: DateToken.Hour_numeric });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (+duration >= +new Duration({ duration: { minutes: 1 } })) {
|
|
47
|
+
// Minutes
|
|
48
|
+
const isFirst = i === 0 || +timeDay.floor(date) === +date;
|
|
49
|
+
if (multiline) {
|
|
50
|
+
return (format(date, PeriodType.TimeOnly, { variant: 'short' }) +
|
|
51
|
+
(isFirst ? `\n${format(date, PeriodType.Day, { variant: 'short' })}` : ''));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return format(date, PeriodType.TimeOnly, { variant: 'short' });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (+duration >= +new Duration({ duration: { seconds: 1 } })) {
|
|
58
|
+
// Seconds
|
|
59
|
+
const isFirst = i === 0 || +timeDay.floor(date) === +date;
|
|
60
|
+
return (format(date, PeriodType.TimeOnly) +
|
|
61
|
+
(multiline && isFirst ? `\n${format(date, PeriodType.Day, { variant: 'short' })}` : ''));
|
|
62
|
+
}
|
|
63
|
+
else if (+duration >= +new Duration({ duration: { milliseconds: 1 } })) {
|
|
64
|
+
// Milliseconds
|
|
65
|
+
const isFirst = i === 0 || +timeDay.floor(date) === +date;
|
|
66
|
+
return (format(date, PeriodType.Custom, {
|
|
67
|
+
custom: [
|
|
68
|
+
DateToken.Hour_2Digit,
|
|
69
|
+
DateToken.Minute_2Digit,
|
|
70
|
+
DateToken.Second_2Digit,
|
|
71
|
+
DateToken.MiliSecond_3,
|
|
72
|
+
DateToken.Hour_woAMPM,
|
|
73
|
+
],
|
|
74
|
+
}) + (multiline && isFirst ? `\n${format(date, PeriodType.Day, { variant: 'short' })}` : ''));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return date.toString();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
137
80
|
}
|
|
138
|
-
export function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
81
|
+
export function resolveTickVals(scale, ticks, count) {
|
|
82
|
+
// Explicit ticks
|
|
83
|
+
if (Array.isArray(ticks))
|
|
84
|
+
return ticks;
|
|
85
|
+
// Function
|
|
86
|
+
if (typeof ticks === 'function')
|
|
87
|
+
return ticks(scale) ?? [];
|
|
88
|
+
// Interval
|
|
89
|
+
if (isLiteralObject(ticks) && 'interval' in ticks) {
|
|
90
|
+
if (ticks.interval === null || !('ticks' in scale) || typeof scale.ticks !== 'function') {
|
|
91
|
+
return []; // Explicitly return empty array for null interval or invalid scale
|
|
143
92
|
}
|
|
93
|
+
return scale.ticks(ticks.interval);
|
|
94
|
+
}
|
|
95
|
+
// Band (use domain)
|
|
96
|
+
if (isScaleBand(scale)) {
|
|
97
|
+
return ticks && typeof ticks === 'number'
|
|
98
|
+
? scale.domain().filter((_, i) => i % ticks === 0)
|
|
99
|
+
: scale.domain();
|
|
100
|
+
}
|
|
101
|
+
// Ticks from scale
|
|
102
|
+
if (scale.ticks && typeof scale.ticks === 'function') {
|
|
103
|
+
return scale.ticks(count ?? (typeof ticks === 'number' ? ticks : undefined));
|
|
144
104
|
}
|
|
145
|
-
|
|
105
|
+
return [];
|
|
146
106
|
}
|
|
147
|
-
export function
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
107
|
+
export function resolveTickFormat(scale, ticks, count, formatType, multiline = false) {
|
|
108
|
+
// Explicit format
|
|
109
|
+
if (formatType) {
|
|
110
|
+
return (tick) => format(tick, formatType);
|
|
111
|
+
}
|
|
112
|
+
// Time scale
|
|
113
|
+
if (isScaleTime(scale) && count) {
|
|
114
|
+
if (isLiteralObject(ticks) && 'interval' in ticks && ticks.interval != null) {
|
|
115
|
+
const start = ticks.interval.floor(new Date());
|
|
116
|
+
const end = ticks.interval.ceil(new Date());
|
|
117
|
+
return getDurationFormat(new Duration({ start, end }), multiline);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// Compare first 2 ticks to determine duration between ticks for formatting
|
|
121
|
+
const [start, end] = timeTicks(scale.domain()[0], scale.domain()[1], count);
|
|
122
|
+
return getDurationFormat(new Duration({ start, end }), multiline);
|
|
152
123
|
}
|
|
153
124
|
}
|
|
154
|
-
|
|
125
|
+
// Format from scale
|
|
126
|
+
if (scale.tickFormat) {
|
|
127
|
+
return scale.tickFormat(count);
|
|
128
|
+
}
|
|
129
|
+
return (tick) => `${tick}`;
|
|
155
130
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { resolveTickVals } from './ticks.js';
|
|
3
|
+
// Mock helpers
|
|
4
|
+
const mockTicksFn = vi.fn();
|
|
5
|
+
const mockDomain = vi.fn(() => ['a', 'b', 'c', 'd', 'e']);
|
|
6
|
+
describe('resolveTickVals', () => {
|
|
7
|
+
it('returns array ticks directly', () => {
|
|
8
|
+
const ticks = [1, 2, 3];
|
|
9
|
+
const scale = { ticks: mockTicksFn };
|
|
10
|
+
expect(resolveTickVals(scale, ticks)).toEqual([1, 2, 3]);
|
|
11
|
+
});
|
|
12
|
+
it('calls function ticks with scale', () => {
|
|
13
|
+
const fnTicks = vi.fn(() => [4, 5, 6]);
|
|
14
|
+
const scale = { ticks: mockTicksFn };
|
|
15
|
+
expect(resolveTickVals(scale, fnTicks)).toEqual([4, 5, 6]);
|
|
16
|
+
expect(fnTicks).toHaveBeenCalledWith(scale);
|
|
17
|
+
});
|
|
18
|
+
it('uses interval when provided', () => {
|
|
19
|
+
const interval = { every: vi.fn() };
|
|
20
|
+
const ticksConfig = { interval };
|
|
21
|
+
const scale = { ticks: vi.fn(() => [7, 8, 9]) };
|
|
22
|
+
expect(resolveTickVals(scale, ticksConfig)).toEqual([7, 8, 9]);
|
|
23
|
+
expect(scale.ticks).toHaveBeenCalledWith(interval);
|
|
24
|
+
});
|
|
25
|
+
it('returns empty array if interval is null', () => {
|
|
26
|
+
const ticksConfig = { interval: null };
|
|
27
|
+
const scale = { ticks: mockTicksFn };
|
|
28
|
+
expect(resolveTickVals(scale, ticksConfig)).toEqual([]);
|
|
29
|
+
});
|
|
30
|
+
it('filters band scale domain with number ticks', () => {
|
|
31
|
+
const scale = { domain: mockDomain, bandwidth: vi.fn() };
|
|
32
|
+
expect(resolveTickVals(scale, 2)).toEqual(['a', 'c', 'e']);
|
|
33
|
+
});
|
|
34
|
+
it('returns full domain for band scale without ticks', () => {
|
|
35
|
+
const scale = { domain: mockDomain, bandwidth: vi.fn() };
|
|
36
|
+
expect(resolveTickVals(scale)).toEqual(['a', 'b', 'c', 'd', 'e']);
|
|
37
|
+
});
|
|
38
|
+
it('uses undefined for non-left/right placement', () => {
|
|
39
|
+
const scale = { domain: mockDomain, ticks: vi.fn(() => [1, 2]) };
|
|
40
|
+
expect(resolveTickVals(scale, undefined, undefined)).toEqual([1, 2]);
|
|
41
|
+
expect(scale.ticks).toHaveBeenCalledWith(undefined);
|
|
42
|
+
});
|
|
43
|
+
it('passes number ticks to scale.ticks', () => {
|
|
44
|
+
const scale = { domain: mockDomain, ticks: vi.fn(() => [10, 20]) };
|
|
45
|
+
expect(resolveTickVals(scale, 5)).toEqual([10, 20]);
|
|
46
|
+
expect(scale.ticks).toHaveBeenCalledWith(5);
|
|
47
|
+
});
|
|
48
|
+
it('returns empty array for scale without ticks', () => {
|
|
49
|
+
const scale = { domain: mockDomain };
|
|
50
|
+
expect(resolveTickVals(scale, 5)).toEqual([]);
|
|
51
|
+
});
|
|
52
|
+
it('handles null ticks with placement', () => {
|
|
53
|
+
const scale = { domain: mockDomain, ticks: vi.fn(() => [1, 2, 3]) };
|
|
54
|
+
expect(resolveTickVals(scale, null, undefined)).toEqual([1, 2, 3]);
|
|
55
|
+
expect(scale.ticks).toHaveBeenCalledWith(undefined);
|
|
56
|
+
});
|
|
57
|
+
});
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
|
+
import type { HierarchyNode } from 'd3-hierarchy';
|
|
2
|
+
import type { AnyScale } from './scales.svelte.js';
|
|
3
|
+
import type { SankeyGraph } from 'd3-sankey';
|
|
4
|
+
import type { TransitionConfig } from 'svelte/transition';
|
|
1
5
|
/**
|
|
2
6
|
* Useful to workaround Svelte 3/4 markup type issues
|
|
3
7
|
* TODO: Remove usage after migrating to Svelte 5
|
|
4
8
|
*/
|
|
5
9
|
export declare function asAny(x: any): any;
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a new type by omitting properties from type
|
|
12
|
+
* 'T' that exist in type 'U'.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The base object type from which properties will be omitted.
|
|
15
|
+
* @template U - The object type whose properties will be omitted from 'T'.
|
|
16
|
+
* @example
|
|
17
|
+
* type Result = Without<{ a: number; b: string; }, { b: string; }>;
|
|
18
|
+
* // Result type will be { a: number; }
|
|
19
|
+
*/
|
|
20
|
+
export type Without<T extends object, U extends object> = Omit<T, keyof U>;
|
|
21
|
+
export type AxisKey = 'x' | 'y' | 'z' | 'r';
|
|
22
|
+
export type Extents = {
|
|
23
|
+
[K in AxisKey]?: Array<number | string>;
|
|
24
|
+
};
|
|
25
|
+
export type Padding = {
|
|
26
|
+
top: number;
|
|
27
|
+
right: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
left: number;
|
|
30
|
+
};
|
|
31
|
+
export type Nice = boolean | number;
|
|
32
|
+
export type BaseRange = number[] | string[] | ((args: {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
}) => number[] | string[]);
|
|
36
|
+
export type YRangeWithScale<Scale extends AnyScale = AnyScale> = number[] | string[] | ((args: {
|
|
37
|
+
yScale: Scale;
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
}) => number[] | string[]);
|
|
41
|
+
export type XRangeWithScale<Scale extends AnyScale = AnyScale> = number[] | string[] | ((args: {
|
|
42
|
+
xScale: Scale;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
}) => number[] | string[]);
|
|
46
|
+
export type FieldAccessors<T> = {
|
|
47
|
+
x?: (d: T) => number | string | (number | string)[];
|
|
48
|
+
y?: (d: T) => number | string | (number | string)[];
|
|
49
|
+
z?: (d: T) => number | string | (number | string)[];
|
|
50
|
+
r?: (d: T) => number | string | (number | string)[];
|
|
51
|
+
};
|
|
52
|
+
export type PaddingArray = [number, number] | number[] | undefined;
|
|
53
|
+
export type DataType<T> = T[] | HierarchyNode<T> | SankeyGraph<any, any> | readonly T[];
|
|
54
|
+
export type Transition = (node: Element, params?: any) => TransitionConfig;
|
|
55
|
+
export type TransitionParams<T extends Transition> = Parameters<T>[1];
|
|
56
|
+
/**
|
|
57
|
+
* Common style properties that apply to many components.
|
|
58
|
+
* Includes `fill`, `fillOpacity`, `stroke`, `strokeWidth`, and `opacity`.
|
|
59
|
+
*/
|
|
60
|
+
export type CommonStyleProps = {
|
|
61
|
+
/**
|
|
62
|
+
* The fill color of the element.
|
|
63
|
+
*/
|
|
64
|
+
fill?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The fill opacity of the element.
|
|
67
|
+
*/
|
|
68
|
+
fillOpacity?: number;
|
|
69
|
+
/**
|
|
70
|
+
* The stroke color of the element.
|
|
71
|
+
*/
|
|
72
|
+
stroke?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The stroke width of the element.
|
|
75
|
+
*/
|
|
76
|
+
strokeWidth?: number;
|
|
77
|
+
/**
|
|
78
|
+
* The opacity of the element. (0 to 1)
|
|
79
|
+
*/
|
|
80
|
+
opacity?: number;
|
|
81
|
+
};
|
|
82
|
+
export type OnlyObjects<T> = T extends object ? T : never;
|
|
83
|
+
export type Getter<T> = () => T;
|
|
84
|
+
export type GetterValues<T> = {
|
|
85
|
+
[K in keyof T]: Getter<T[K]>;
|
|
86
|
+
};
|
package/package.json
CHANGED
|
@@ -4,18 +4,20 @@
|
|
|
4
4
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "techniq/layerchart",
|
|
7
|
-
"version": "2.0.0-next.
|
|
7
|
+
"version": "2.0.0-next.11",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@changesets/cli": "^2.
|
|
9
|
+
"@changesets/cli": "^2.29.4",
|
|
10
|
+
"@iconify-json/lucide": "^1.2.44",
|
|
10
11
|
"@mdi/js": "^7.4.47",
|
|
11
12
|
"@rollup/plugin-dsv": "^3.0.5",
|
|
12
|
-
"@sveltejs/adapter-cloudflare": "^
|
|
13
|
-
"@sveltejs/kit": "^2.
|
|
14
|
-
"@sveltejs/package": "^2.3.
|
|
13
|
+
"@sveltejs/adapter-cloudflare": "^7.0.3",
|
|
14
|
+
"@sveltejs/kit": "^2.21.1",
|
|
15
|
+
"@sveltejs/package": "^2.3.11",
|
|
15
16
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
16
17
|
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
|
|
17
18
|
"@tailwindcss/typography": "^0.5.16",
|
|
18
|
-
"@tailwindcss/vite": "^4.
|
|
19
|
+
"@tailwindcss/vite": "^4.1.7",
|
|
20
|
+
"@types/d3": "^7.4.3",
|
|
19
21
|
"@types/d3-array": "^3.2.1",
|
|
20
22
|
"@types/d3-color": "^3.1.3",
|
|
21
23
|
"@types/d3-delaunay": "^6.0.4",
|
|
@@ -39,39 +41,41 @@
|
|
|
39
41
|
"@types/topojson-client": "^3.1.5",
|
|
40
42
|
"@types/topojson-simplify": "^3.0.3",
|
|
41
43
|
"@types/topojson-specification": "^1.0.5",
|
|
42
|
-
"marked": "^15.0.
|
|
44
|
+
"marked": "^15.0.11",
|
|
43
45
|
"mdsvex": "^0.12.3",
|
|
44
|
-
"posthog-js": "^1.
|
|
46
|
+
"posthog-js": "^1.245.1",
|
|
45
47
|
"prettier": "^3.5.3",
|
|
46
|
-
"prettier-plugin-svelte": "^3.
|
|
48
|
+
"prettier-plugin-svelte": "^3.4.0",
|
|
47
49
|
"prism-svelte": "^0.5.0",
|
|
48
50
|
"prism-themes": "^1.9.0",
|
|
49
51
|
"prismjs": "^1.30.0",
|
|
50
52
|
"rehype-slug": "^6.0.0",
|
|
51
53
|
"shapefile": "^0.6.6",
|
|
52
54
|
"solar-calculator": "^0.3.0",
|
|
53
|
-
"svelte": "5.
|
|
54
|
-
"svelte-check": "^4.1
|
|
55
|
+
"svelte": "5.32.1",
|
|
56
|
+
"svelte-check": "^4.2.1",
|
|
55
57
|
"svelte-json-tree": "^2.2.0",
|
|
56
58
|
"svelte-ux": "2.0.0-next.2",
|
|
57
|
-
"svelte2tsx": "^0.7.
|
|
58
|
-
"tailwindcss": "^4.
|
|
59
|
+
"svelte2tsx": "^0.7.39",
|
|
60
|
+
"tailwindcss": "^4.1.7",
|
|
59
61
|
"topojson-client": "^3.1.0",
|
|
60
62
|
"topojson-simplify": "^3.0.3",
|
|
61
63
|
"tslib": "^2.8.1",
|
|
62
|
-
"typescript": "^5.8.
|
|
64
|
+
"typescript": "^5.8.3",
|
|
63
65
|
"unist-util-visit": "^5.0.0",
|
|
66
|
+
"unplugin-icons": "^22.1.0",
|
|
64
67
|
"us-atlas": "^3.0.1",
|
|
65
|
-
"vite": "^6.
|
|
66
|
-
"
|
|
68
|
+
"vite": "^6.3.5",
|
|
69
|
+
"vite-plugin-devtools-json": "^0.1.0",
|
|
70
|
+
"vitest": "^3.1.4"
|
|
67
71
|
},
|
|
68
72
|
"type": "module",
|
|
69
73
|
"dependencies": {
|
|
70
74
|
"@dagrejs/dagre": "^1.1.4",
|
|
71
|
-
"@layerstack/svelte-actions": "1.0.1-next.
|
|
72
|
-
"@layerstack/svelte-
|
|
73
|
-
"@layerstack/tailwind": "2.0.0-next.
|
|
74
|
-
"@layerstack/utils": "
|
|
75
|
+
"@layerstack/svelte-actions": "1.0.1-next.2",
|
|
76
|
+
"@layerstack/svelte-state": "0.1.0-next.7",
|
|
77
|
+
"@layerstack/tailwind": "2.0.0-next.4",
|
|
78
|
+
"@layerstack/utils": "2.0.0-next.3",
|
|
75
79
|
"d3-array": "^3.2.4",
|
|
76
80
|
"d3-color": "^3.1.0",
|
|
77
81
|
"d3-delaunay": "^6.0.4",
|
|
@@ -92,11 +96,11 @@
|
|
|
92
96
|
"d3-tile": "^1.0.0",
|
|
93
97
|
"d3-time": "^3.1.0",
|
|
94
98
|
"date-fns": "^4.1.0",
|
|
95
|
-
"
|
|
96
|
-
"
|
|
99
|
+
"lodash-es": "^4.17.21",
|
|
100
|
+
"runed": "^0.28.0"
|
|
97
101
|
},
|
|
98
102
|
"peerDependencies": {
|
|
99
|
-
"svelte": "^
|
|
103
|
+
"svelte": "^5.0.0"
|
|
100
104
|
},
|
|
101
105
|
"main": "./dist/index.js",
|
|
102
106
|
"exports": {
|
|
@@ -116,7 +120,7 @@
|
|
|
116
120
|
],
|
|
117
121
|
"svelte": "./dist/index.js",
|
|
118
122
|
"scripts": {
|
|
119
|
-
"dev": "vite dev",
|
|
123
|
+
"dev": "vite dev --port 3002",
|
|
120
124
|
"build": "vite build",
|
|
121
125
|
"preview": "vite preview",
|
|
122
126
|
"package": "svelte-package",
|