layerchart 2.0.0-next.3 → 2.0.0-next.31
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/AnnotationPoint.svelte +16 -9
- package/dist/components/AnnotationRange.svelte +3 -3
- package/dist/components/Arc.svelte +2 -2
- package/dist/components/Axis.svelte +83 -29
- package/dist/components/Axis.svelte.d.ts +13 -3
- package/dist/components/Bar.svelte +12 -8
- package/dist/components/Blur.svelte +5 -3
- package/dist/components/Blur.svelte.d.ts +2 -5
- package/dist/components/BrushContext.svelte +1 -1
- package/dist/components/Calendar.svelte +10 -6
- package/dist/components/Calendar.svelte.d.ts +2 -1
- package/dist/components/Chart.svelte +39 -3
- package/dist/components/Chart.svelte.d.ts +11 -0
- package/dist/components/Connector.svelte +2 -2
- package/dist/components/Connector.svelte.d.ts +1 -1
- package/dist/components/Ellipse.svelte +187 -0
- package/dist/components/Ellipse.svelte.d.ts +64 -0
- package/dist/components/ForceSimulation.svelte +184 -50
- package/dist/components/ForceSimulation.svelte.d.ts +88 -21
- package/dist/components/GeoPath.svelte +12 -5
- package/dist/components/GeoPoint.svelte +1 -2
- package/dist/components/GeoSpline.svelte +4 -4
- package/dist/components/GeoSpline.svelte.d.ts +1 -1
- package/dist/components/Group.svelte +2 -2
- package/dist/components/Highlight.svelte +9 -6
- package/dist/components/Hull.svelte +1 -1
- package/dist/components/Labels.svelte +3 -2
- package/dist/components/Labels.svelte.d.ts +2 -2
- package/dist/components/Legend.svelte +19 -12
- package/dist/components/Legend.svelte.d.ts +5 -5
- package/dist/components/MonthPath.svelte +14 -11
- package/dist/components/MonthPath.svelte.d.ts +4 -3
- package/dist/components/Polygon.svelte +285 -0
- package/dist/components/Polygon.svelte.d.ts +115 -0
- package/dist/components/RadialGradient.svelte +1 -3
- package/dist/components/Spline.svelte +30 -18
- package/dist/components/Spline.svelte.d.ts +12 -4
- package/dist/components/Text.svelte +62 -60
- package/dist/components/Text.svelte.d.ts +6 -0
- package/dist/components/TransformControls.svelte +16 -20
- package/dist/components/Treemap.svelte +63 -26
- package/dist/components/Treemap.svelte.d.ts +11 -11
- package/dist/components/Voronoi.svelte +51 -33
- package/dist/components/Voronoi.svelte.d.ts +3 -1
- package/dist/components/charts/ArcChart.svelte +5 -3
- package/dist/components/charts/AreaChart.svelte +11 -11
- package/dist/components/charts/BarChart.svelte +72 -53
- package/dist/components/charts/DefaultTooltip.svelte +1 -1
- package/dist/components/charts/LineChart.svelte +10 -6
- package/dist/components/charts/PieChart.svelte +5 -3
- package/dist/components/charts/ScatterChart.svelte +2 -3
- package/dist/components/charts/utils.svelte.d.ts +2 -2
- package/dist/components/charts/utils.svelte.js +5 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +5 -1
- package/dist/components/layout/Canvas.svelte +67 -49
- package/dist/components/layout/Canvas.svelte.d.ts +6 -0
- package/dist/components/layout/Layer.svelte +6 -4
- package/dist/components/layout/Layer.svelte.d.ts +6 -4
- package/dist/components/tooltip/Tooltip.svelte +14 -7
- package/dist/components/tooltip/TooltipContext.svelte +136 -43
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +3 -3
- package/dist/components/tooltip/TooltipHeader.svelte +5 -4
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +3 -3
- package/dist/components/tooltip/TooltipItem.svelte +5 -4
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +3 -3
- package/dist/components/tooltip/TooltipList.svelte +1 -1
- package/dist/components/tooltip/tooltipMetaContext.d.ts +2 -2
- package/dist/docs/Blockquote.svelte +6 -4
- package/dist/docs/Blockquote.svelte.d.ts +4 -19
- package/dist/docs/Code.svelte +20 -12
- package/dist/docs/Code.svelte.d.ts +9 -23
- package/dist/docs/Header1.svelte +4 -2
- package/dist/docs/Header1.svelte.d.ts +4 -28
- package/dist/docs/Json.svelte +11 -3
- package/dist/docs/Json.svelte.d.ts +9 -21
- package/dist/docs/Layout.svelte +10 -7
- package/dist/docs/Layout.svelte.d.ts +4 -19
- package/dist/docs/Link.svelte +7 -3
- package/dist/docs/Link.svelte.d.ts +4 -38
- package/dist/docs/Preview.svelte +6 -3
- package/dist/docs/TilesetField.svelte +20 -19
- package/dist/docs/TilesetField.svelte.d.ts +5 -22
- package/dist/docs/ViewSourceButton.svelte +9 -6
- package/dist/docs/ViewSourceButton.svelte.d.ts +7 -21
- package/dist/utils/arcText.svelte.js +4 -4
- package/dist/utils/array.d.ts +11 -0
- package/dist/utils/array.js +23 -0
- package/dist/utils/array.test.d.ts +1 -0
- package/dist/utils/array.test.js +200 -0
- package/dist/utils/canvas.d.ts +77 -0
- package/dist/utils/canvas.js +105 -41
- package/dist/utils/genData.d.ts +14 -0
- package/dist/utils/genData.js +24 -6
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/path.d.ts +10 -0
- package/dist/utils/path.js +30 -0
- package/dist/utils/rect.svelte.d.ts +2 -2
- package/dist/utils/rect.svelte.js +69 -1
- package/dist/utils/scales.svelte.d.ts +3 -2
- package/dist/utils/scales.svelte.js +7 -3
- package/dist/utils/shape.d.ts +43 -0
- package/dist/utils/shape.js +59 -0
- package/dist/utils/string.d.ts +49 -0
- package/dist/utils/string.js +4 -2
- package/dist/utils/ticks.d.ts +15 -4
- package/dist/utils/ticks.js +144 -158
- package/dist/utils/ticks.test.js +11 -16
- package/dist/utils/treemap.d.ts +1 -1
- package/package.json +27 -25
- package/dist/utils/object.js +0 -2
package/dist/utils/ticks.js
CHANGED
|
@@ -1,183 +1,169 @@
|
|
|
1
|
-
import { timeYear, timeMonth,
|
|
2
|
-
import { format } from '
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
predicate: (duration) => duration.years > 1,
|
|
14
|
-
interval: timeYear.every(1),
|
|
15
|
-
format: (date) => formatDate(date, PeriodType.CalendarYear, { variant: 'short' }),
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
predicate: (duration) => duration.years,
|
|
19
|
-
interval: timeMonth.every(1),
|
|
20
|
-
format: (date) => formatDate(date, PeriodType.Month, { variant: 'short' }),
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
predicate: (duration) => duration.days > 30,
|
|
24
|
-
interval: timeMonth.every(1),
|
|
25
|
-
format: (date) => formatDate(date, PeriodType.Month, { variant: 'short' }),
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
predicate: (duration) => duration.days,
|
|
29
|
-
interval: timeDay.every(1),
|
|
30
|
-
format: (date) => formatDate(date, PeriodType.Day, { variant: 'short' }),
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
predicate: (duration) => duration.hours,
|
|
34
|
-
interval: timeHour.every(1),
|
|
35
|
-
format: (date) => format(date, 'h:mm a'),
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
predicate: (duration) => duration.minutes > 10,
|
|
39
|
-
interval: timeMinute.every(10),
|
|
40
|
-
format: (date) => format(date, 'h:mm a'),
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
predicate: (duration) => duration.minutes,
|
|
44
|
-
interval: timeMinute.every(1),
|
|
45
|
-
format: (date) => format(date, 'h:mm a'),
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
predicate: (duration) => duration.seconds > 10,
|
|
49
|
-
interval: timeSecond.every(10),
|
|
50
|
-
format: (date) => format(date, 'h:mm:ss'),
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
predicate: (duration) => duration.seconds,
|
|
54
|
-
interval: timeSecond.every(1),
|
|
55
|
-
format: (date) => format(date, 'h:mm:ss'),
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
predicate: (duration) => true, // 0 or more milliseconds
|
|
59
|
-
interval: timeMillisecond.every(100),
|
|
60
|
-
format: (date) => format(date, 'h:mm:ss.SSS'),
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
const minorTicks = [
|
|
64
|
-
{
|
|
65
|
-
predicate: (duration) => duration == null, // Unknown
|
|
66
|
-
interval: timeYear.every(1), // Better than rendering a lot of items
|
|
67
|
-
format: (date) => date.toString(),
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
predicate: (duration) => duration.years,
|
|
71
|
-
interval: timeMonth.every(1),
|
|
72
|
-
format: (date) => formatDate(date, PeriodType.Month, { variant: 'short' }),
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
predicate: (duration) => duration.days > 90,
|
|
76
|
-
interval: timeMonth.every(1),
|
|
77
|
-
format: (date) => formatDate(date, PeriodType.Month, { variant: 'short' }),
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
predicate: (duration) => duration.days > 30,
|
|
81
|
-
interval: timeWeek.every(1),
|
|
82
|
-
format: (date) => formatDate(date, PeriodType.WeekSun, { variant: 'short' }),
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
predicate: (duration) => duration.days > 7,
|
|
86
|
-
interval: timeDay.every(1),
|
|
87
|
-
format: (date) => formatDate(date, PeriodType.Day, { variant: 'short' }),
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
predicate: (duration) => duration.days > 3,
|
|
91
|
-
interval: timeHour.every(8),
|
|
92
|
-
format: (date) => format(date, 'h:mm a'),
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
predicate: (duration) => duration.days,
|
|
96
|
-
interval: timeHour.every(1),
|
|
97
|
-
format: (date) => format(date, 'h:mm a'),
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
predicate: (duration) => duration.hours,
|
|
101
|
-
interval: timeMinute.every(15),
|
|
102
|
-
format: (date) => format(date, 'h:mm a'),
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
predicate: (duration) => duration.minutes > 10,
|
|
106
|
-
interval: timeMinute.every(10),
|
|
107
|
-
format: (date) => format(date, 'h:mm a'),
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
predicate: (duration) => duration.minutes > 2,
|
|
111
|
-
interval: timeMinute.every(1),
|
|
112
|
-
format: (date) => format(date, 'h:mm a'),
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
predicate: (duration) => duration.minutes,
|
|
116
|
-
interval: timeSecond.every(10),
|
|
117
|
-
format: (date) => format(date, 'h:mm:ss'),
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
predicate: (duration) => duration.seconds,
|
|
121
|
-
interval: timeSecond.every(1),
|
|
122
|
-
format: (date) => format(date, 'h:mm:ss'),
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
predicate: (duration) => true, // 0 or more milliseconds
|
|
126
|
-
interval: timeMillisecond.every(10),
|
|
127
|
-
format: (date) => format(date, 'h:mm:ss.SSS'),
|
|
128
|
-
},
|
|
129
|
-
];
|
|
130
|
-
export function getMajorTicks(start, end) {
|
|
131
|
-
const duration = getDuration(start, end);
|
|
132
|
-
for (var t of majorTicks) {
|
|
133
|
-
if (t.predicate(duration)) {
|
|
134
|
-
return t.interval;
|
|
1
|
+
import { timeYear, timeMonth, timeDay, timeTicks } from 'd3-time';
|
|
2
|
+
import { format, Duration, isLiteralObject, DateToken, } from '@layerstack/utils';
|
|
3
|
+
import { isScaleBand, isScaleTime } from './scales.svelte.js';
|
|
4
|
+
export function getDurationFormat(duration, options = {
|
|
5
|
+
multiline: false,
|
|
6
|
+
}) {
|
|
7
|
+
const { multiline = false, placement = 'bottom' } = options;
|
|
8
|
+
return function (date, i) {
|
|
9
|
+
let result = '';
|
|
10
|
+
if (+duration >= +new Duration({ duration: { years: 1 } })) {
|
|
11
|
+
// Year
|
|
12
|
+
result = format(date, 'year');
|
|
135
13
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
14
|
+
else if (+duration >= +new Duration({ duration: { days: 28 } })) {
|
|
15
|
+
// Month
|
|
16
|
+
const isFirst = i === 0 || +timeYear.floor(date) === +date;
|
|
17
|
+
if (multiline) {
|
|
18
|
+
result = [format(date, 'month', { variant: 'short' }), isFirst && format(date, 'year')];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
result =
|
|
22
|
+
format(date, 'month', { variant: 'short' }) +
|
|
23
|
+
(isFirst ? ` '${format(date, 'year', { variant: 'short' })}` : '');
|
|
24
|
+
}
|
|
144
25
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
26
|
+
else if (+duration >= +new Duration({ duration: { days: 1 } })) {
|
|
27
|
+
// Day
|
|
28
|
+
const isFirst = i === 0 || date.getDate() <= duration.days;
|
|
29
|
+
if (multiline) {
|
|
30
|
+
result = [
|
|
31
|
+
format(date, 'custom', { custom: DateToken.DayOfMonth_numeric }),
|
|
32
|
+
isFirst && format(date, 'month', { variant: 'short' }),
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
result = format(date, 'day', { variant: 'short' });
|
|
37
|
+
}
|
|
153
38
|
}
|
|
154
|
-
|
|
155
|
-
|
|
39
|
+
else if (+duration >= +new Duration({ duration: { hours: 1 } })) {
|
|
40
|
+
// Hours
|
|
41
|
+
const isFirst = i === 0 || +timeDay.floor(date) === +date;
|
|
42
|
+
if (multiline) {
|
|
43
|
+
result = [
|
|
44
|
+
format(date, 'custom', { custom: DateToken.Hour_numeric }),
|
|
45
|
+
isFirst && format(date, 'day', { variant: 'short' }),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
result = isFirst
|
|
50
|
+
? format(date, 'day', { variant: 'short' })
|
|
51
|
+
: format(date, 'custom', { custom: DateToken.Hour_numeric });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (+duration >= +new Duration({ duration: { minutes: 1 } })) {
|
|
55
|
+
// Minutes
|
|
56
|
+
const isFirst = i === 0 || +timeDay.floor(date) === +date;
|
|
57
|
+
if (multiline) {
|
|
58
|
+
result = [
|
|
59
|
+
format(date, 'time', { variant: 'short' }),
|
|
60
|
+
isFirst && format(date, 'day', { variant: 'short' }),
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
result = format(date, 'time', { variant: 'short' });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (+duration >= +new Duration({ duration: { seconds: 1 } })) {
|
|
68
|
+
// Seconds
|
|
69
|
+
const isFirst = i === 0 || +timeDay.floor(date) === +date;
|
|
70
|
+
result = [
|
|
71
|
+
format(date, 'time'),
|
|
72
|
+
multiline && isFirst && format(date, 'day', { variant: 'short' }),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
else if (+duration >= +new Duration({ duration: { milliseconds: 1 } })) {
|
|
76
|
+
// Milliseconds
|
|
77
|
+
const isFirst = i === 0 || +timeDay.floor(date) === +date;
|
|
78
|
+
result = [
|
|
79
|
+
format(date, 'custom', {
|
|
80
|
+
custom: [
|
|
81
|
+
DateToken.Hour_2Digit,
|
|
82
|
+
DateToken.Minute_2Digit,
|
|
83
|
+
DateToken.Second_2Digit,
|
|
84
|
+
DateToken.MiliSecond_3,
|
|
85
|
+
DateToken.Hour_woAMPM,
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
multiline && isFirst && format(date, 'day', { variant: 'short' }),
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
result = date.toString();
|
|
93
|
+
}
|
|
94
|
+
if (Array.isArray(result)) {
|
|
95
|
+
switch (placement) {
|
|
96
|
+
case 'top':
|
|
97
|
+
return result.filter(Boolean).reverse().join('\n');
|
|
98
|
+
case 'bottom':
|
|
99
|
+
return result.filter(Boolean).join('\n');
|
|
100
|
+
case 'left':
|
|
101
|
+
return result.filter(Boolean).reverse().join(' ');
|
|
102
|
+
case 'right':
|
|
103
|
+
return result.filter(Boolean).join(' ');
|
|
104
|
+
default:
|
|
105
|
+
return result.filter(Boolean).join('\n');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
156
112
|
}
|
|
157
|
-
export function resolveTickVals(scale, ticks,
|
|
113
|
+
export function resolveTickVals(scale, ticks, count, interval) {
|
|
114
|
+
// Explicit ticks
|
|
158
115
|
if (Array.isArray(ticks))
|
|
159
116
|
return ticks;
|
|
117
|
+
// Function
|
|
160
118
|
if (typeof ticks === 'function')
|
|
161
119
|
return ticks(scale) ?? [];
|
|
120
|
+
// Interval
|
|
162
121
|
if (isLiteralObject(ticks) && 'interval' in ticks) {
|
|
163
122
|
if (ticks.interval === null || !('ticks' in scale) || typeof scale.ticks !== 'function') {
|
|
164
123
|
return []; // Explicitly return empty array for null interval or invalid scale
|
|
165
124
|
}
|
|
166
125
|
return scale.ticks(ticks.interval);
|
|
167
126
|
}
|
|
127
|
+
// Band (use domain)
|
|
168
128
|
if (isScaleBand(scale)) {
|
|
169
129
|
return ticks && typeof ticks === 'number'
|
|
170
130
|
? scale.domain().filter((_, i) => i % ticks === 0)
|
|
171
131
|
: scale.domain();
|
|
172
132
|
}
|
|
133
|
+
// Ticks from scale
|
|
173
134
|
if (scale.ticks && typeof scale.ticks === 'function') {
|
|
174
|
-
|
|
175
|
-
|
|
135
|
+
const tickVals = scale.ticks(count ?? (typeof ticks === 'number' ? ticks : undefined));
|
|
136
|
+
if (interval) {
|
|
137
|
+
// Remove last tick when interval is provided (such as for bar charts with center aligned (offset) ticks)
|
|
138
|
+
tickVals.pop();
|
|
176
139
|
}
|
|
177
|
-
return
|
|
140
|
+
return tickVals;
|
|
178
141
|
}
|
|
179
142
|
return [];
|
|
180
143
|
}
|
|
181
|
-
function
|
|
182
|
-
|
|
144
|
+
export function resolveTickFormat(options) {
|
|
145
|
+
const { scale, ticks, count, formatType, multiline, placement } = options;
|
|
146
|
+
// Explicit format
|
|
147
|
+
if (formatType) {
|
|
148
|
+
// @ts-expect-error - improve types
|
|
149
|
+
return (tick) => format(tick, formatType);
|
|
150
|
+
}
|
|
151
|
+
// Time scale
|
|
152
|
+
if (isScaleTime(scale) && count) {
|
|
153
|
+
if (isLiteralObject(ticks) && 'interval' in ticks && ticks.interval != null) {
|
|
154
|
+
const start = ticks.interval.floor(new Date());
|
|
155
|
+
const end = ticks.interval.ceil(new Date());
|
|
156
|
+
return getDurationFormat(new Duration({ start, end }), { multiline, placement });
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// Compare first 2 ticks to determine duration between ticks for formatting
|
|
160
|
+
const [start, end] = timeTicks(scale.domain()[0], scale.domain()[1], count);
|
|
161
|
+
return getDurationFormat(new Duration({ start, end }), { multiline, placement });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Format from scale
|
|
165
|
+
if (scale.tickFormat) {
|
|
166
|
+
return scale.tickFormat(count);
|
|
167
|
+
}
|
|
168
|
+
return (tick) => `${tick}`;
|
|
183
169
|
}
|
package/dist/utils/ticks.test.js
CHANGED
|
@@ -35,33 +35,28 @@ describe('resolveTickVals', () => {
|
|
|
35
35
|
const scale = { domain: mockDomain, bandwidth: vi.fn() };
|
|
36
36
|
expect(resolveTickVals(scale)).toEqual(['a', 'b', 'c', 'd', 'e']);
|
|
37
37
|
});
|
|
38
|
-
it('uses default 4 ticks for left placement', () => {
|
|
39
|
-
const scale = { ticks: vi.fn(() => [1, 2, 3, 4]) };
|
|
40
|
-
expect(resolveTickVals(scale, undefined, 'left')).toEqual([1, 2, 3, 4]);
|
|
41
|
-
expect(scale.ticks).toHaveBeenCalledWith(4);
|
|
42
|
-
});
|
|
43
|
-
it('uses default 4 ticks for right placement', () => {
|
|
44
|
-
const scale = { ticks: vi.fn(() => [1, 2, 3, 4]) };
|
|
45
|
-
expect(resolveTickVals(scale, undefined, 'right')).toEqual([1, 2, 3, 4]);
|
|
46
|
-
expect(scale.ticks).toHaveBeenCalledWith(4);
|
|
47
|
-
});
|
|
48
38
|
it('uses undefined for non-left/right placement', () => {
|
|
49
|
-
const scale = { ticks: vi.fn(() => [1, 2]) };
|
|
50
|
-
expect(resolveTickVals(scale, undefined,
|
|
39
|
+
const scale = { domain: mockDomain, ticks: vi.fn(() => [1, 2]) };
|
|
40
|
+
expect(resolveTickVals(scale, undefined, undefined)).toEqual([1, 2]);
|
|
51
41
|
expect(scale.ticks).toHaveBeenCalledWith(undefined);
|
|
52
42
|
});
|
|
53
43
|
it('passes number ticks to scale.ticks', () => {
|
|
54
|
-
const scale = { ticks: vi.fn(() => [10, 20]) };
|
|
44
|
+
const scale = { domain: mockDomain, ticks: vi.fn(() => [10, 20]) };
|
|
55
45
|
expect(resolveTickVals(scale, 5)).toEqual([10, 20]);
|
|
56
46
|
expect(scale.ticks).toHaveBeenCalledWith(5);
|
|
57
47
|
});
|
|
58
48
|
it('returns empty array for scale without ticks', () => {
|
|
59
|
-
const scale = {};
|
|
49
|
+
const scale = { domain: mockDomain };
|
|
60
50
|
expect(resolveTickVals(scale, 5)).toEqual([]);
|
|
61
51
|
});
|
|
62
52
|
it('handles null ticks with placement', () => {
|
|
63
|
-
const scale = { ticks: vi.fn(() => [1, 2, 3]) };
|
|
64
|
-
expect(resolveTickVals(scale, null,
|
|
53
|
+
const scale = { domain: mockDomain, ticks: vi.fn(() => [1, 2, 3]) };
|
|
54
|
+
expect(resolveTickVals(scale, null, undefined)).toEqual([1, 2, 3]);
|
|
65
55
|
expect(scale.ticks).toHaveBeenCalledWith(undefined);
|
|
66
56
|
});
|
|
57
|
+
it('removes last tick when interval is provided', () => {
|
|
58
|
+
const interval = { every: vi.fn() };
|
|
59
|
+
const scale = { ticks: vi.fn(() => [1, 2, 3, 4]) };
|
|
60
|
+
expect(resolveTickVals(scale, undefined, undefined, interval)).toEqual([1, 2, 3]);
|
|
61
|
+
});
|
|
67
62
|
});
|
package/dist/utils/treemap.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export declare function aspectTile(tile: TileFunc, width: number, height: number
|
|
|
9
9
|
/**
|
|
10
10
|
* Show if the node (a) is a child of the selected (b), or any parent above selected
|
|
11
11
|
*/
|
|
12
|
-
export declare function isNodeVisible(a: HierarchyNode<any>, b: HierarchyNode<any> | null): boolean;
|
|
12
|
+
export declare function isNodeVisible(a: HierarchyNode<any>, b: HierarchyNode<any> | null | undefined): boolean;
|
|
13
13
|
export {};
|
package/package.json
CHANGED
|
@@ -4,18 +4,18 @@
|
|
|
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.31",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@changesets/cli": "^2.29.
|
|
10
|
-
"@
|
|
9
|
+
"@changesets/cli": "^2.29.4",
|
|
10
|
+
"@iconify-json/lucide": "^1.2.48",
|
|
11
11
|
"@rollup/plugin-dsv": "^3.0.5",
|
|
12
|
-
"@sveltejs/adapter-cloudflare": "^
|
|
13
|
-
"@sveltejs/kit": "^2.
|
|
12
|
+
"@sveltejs/adapter-cloudflare": "^7.0.4",
|
|
13
|
+
"@sveltejs/kit": "^2.21.5",
|
|
14
14
|
"@sveltejs/package": "^2.3.11",
|
|
15
|
-
"@sveltejs/vite-plugin-svelte": "^5.0
|
|
15
|
+
"@sveltejs/vite-plugin-svelte": "^5.1.0",
|
|
16
16
|
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
|
|
17
17
|
"@tailwindcss/typography": "^0.5.16",
|
|
18
|
-
"@tailwindcss/vite": "^4.1.
|
|
18
|
+
"@tailwindcss/vite": "^4.1.10",
|
|
19
19
|
"@types/d3": "^7.4.3",
|
|
20
20
|
"@types/d3-array": "^3.2.1",
|
|
21
21
|
"@types/d3-color": "^3.1.3",
|
|
@@ -40,40 +40,42 @@
|
|
|
40
40
|
"@types/topojson-client": "^3.1.5",
|
|
41
41
|
"@types/topojson-simplify": "^3.0.3",
|
|
42
42
|
"@types/topojson-specification": "^1.0.5",
|
|
43
|
-
"marked": "^15.0.
|
|
44
|
-
"mdsvex": "0.12.3",
|
|
45
|
-
"posthog-js": "^1.
|
|
43
|
+
"marked": "^15.0.12",
|
|
44
|
+
"mdsvex": "^0.12.3",
|
|
45
|
+
"posthog-js": "^1.252.0",
|
|
46
46
|
"prettier": "^3.5.3",
|
|
47
|
-
"prettier-plugin-svelte": "^3.
|
|
47
|
+
"prettier-plugin-svelte": "^3.4.0",
|
|
48
48
|
"prism-svelte": "^0.5.0",
|
|
49
49
|
"prism-themes": "^1.9.0",
|
|
50
50
|
"prismjs": "^1.30.0",
|
|
51
51
|
"rehype-slug": "^6.0.0",
|
|
52
|
+
"rollup-plugin-visualizer": "^6.0.3",
|
|
52
53
|
"shapefile": "^0.6.6",
|
|
53
54
|
"solar-calculator": "^0.3.0",
|
|
54
|
-
"svelte": "5.
|
|
55
|
-
"svelte-check": "^4.1
|
|
55
|
+
"svelte": "5.34.1",
|
|
56
|
+
"svelte-check": "^4.2.1",
|
|
56
57
|
"svelte-json-tree": "^2.2.0",
|
|
57
|
-
"svelte-ux": "2.0.0-next.
|
|
58
|
-
"svelte2tsx": "^0.7.
|
|
59
|
-
"tailwindcss": "^4.1.
|
|
58
|
+
"svelte-ux": "2.0.0-next.14",
|
|
59
|
+
"svelte2tsx": "^0.7.39",
|
|
60
|
+
"tailwindcss": "^4.1.10",
|
|
60
61
|
"topojson-client": "^3.1.0",
|
|
61
62
|
"topojson-simplify": "^3.0.3",
|
|
62
63
|
"tslib": "^2.8.1",
|
|
63
64
|
"typescript": "^5.8.3",
|
|
64
65
|
"unist-util-visit": "^5.0.0",
|
|
66
|
+
"unplugin-icons": "^22.1.0",
|
|
65
67
|
"us-atlas": "^3.0.1",
|
|
66
|
-
"vite": "^6.3.
|
|
67
|
-
"
|
|
68
|
+
"vite": "^6.3.5",
|
|
69
|
+
"vite-plugin-devtools-json": "^0.2.0",
|
|
70
|
+
"vitest": "^3.2.3"
|
|
68
71
|
},
|
|
69
72
|
"type": "module",
|
|
70
73
|
"dependencies": {
|
|
71
74
|
"@dagrejs/dagre": "^1.1.4",
|
|
72
|
-
"@layerstack/svelte-actions": "1.0.1-next.
|
|
73
|
-
"@layerstack/svelte-state": "0.1.0-next.
|
|
74
|
-
"@layerstack/
|
|
75
|
-
"@layerstack/
|
|
76
|
-
"@layerstack/utils": "1.1.0-next.0",
|
|
75
|
+
"@layerstack/svelte-actions": "1.0.1-next.12",
|
|
76
|
+
"@layerstack/svelte-state": "0.1.0-next.17",
|
|
77
|
+
"@layerstack/tailwind": "2.0.0-next.15",
|
|
78
|
+
"@layerstack/utils": "2.0.0-next.12",
|
|
77
79
|
"d3-array": "^3.2.4",
|
|
78
80
|
"d3-color": "^3.1.0",
|
|
79
81
|
"d3-delaunay": "^6.0.4",
|
|
@@ -93,9 +95,9 @@
|
|
|
93
95
|
"d3-shape": "^3.2.0",
|
|
94
96
|
"d3-tile": "^1.0.0",
|
|
95
97
|
"d3-time": "^3.1.0",
|
|
96
|
-
"date-fns": "^4.1.0",
|
|
97
98
|
"lodash-es": "^4.17.21",
|
|
98
|
-
"
|
|
99
|
+
"memoize": "^10.1.0",
|
|
100
|
+
"runed": "^0.28.0"
|
|
99
101
|
},
|
|
100
102
|
"peerDependencies": {
|
|
101
103
|
"svelte": "^5.0.0"
|
package/dist/utils/object.js
DELETED