layerchart 2.0.0-next.17 → 2.0.0-next.18
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.
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
</script>
|
|
31
31
|
|
|
32
32
|
<script lang="ts">
|
|
33
|
-
import { timeWeek, timeYear } from 'd3-time';
|
|
34
|
-
import {
|
|
33
|
+
import { timeWeek, timeMonth, timeYear } from 'd3-time';
|
|
34
|
+
import { endOfInterval } from '../utils/date.js';
|
|
35
35
|
import { cls } from '@layerstack/tailwind';
|
|
36
36
|
import { layerClass } from '../utils/attributes.js';
|
|
37
37
|
import Spline, { type SplinePropsWithoutHTML } from './Spline.svelte';
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
const startWeek = $derived(timeWeek.count(timeYear(date), date));
|
|
59
59
|
|
|
60
60
|
// end of month
|
|
61
|
-
const monthEnd = $derived(
|
|
61
|
+
const monthEnd = $derived(endOfInterval(date, timeMonth));
|
|
62
62
|
const endDayOfWeek = $derived(monthEnd.getDay());
|
|
63
63
|
const endWeek = $derived(timeWeek.count(timeYear(monthEnd), monthEnd));
|
|
64
64
|
|
|
@@ -281,27 +281,34 @@
|
|
|
281
281
|
// Split each line into words
|
|
282
282
|
const words = line.split(/(?:(?!\u00A0+)\s+)/);
|
|
283
283
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
currentLine
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
284
|
+
if (width == null) {
|
|
285
|
+
// No width specified, only use explicit line breaks (if used)
|
|
286
|
+
return [{ words }];
|
|
287
|
+
} else {
|
|
288
|
+
// Handle word wrapping within each line
|
|
289
|
+
return words.reduce((result: { words: string[]; width?: number }[], item) => {
|
|
290
|
+
const currentLine = result[result.length - 1];
|
|
291
|
+
const itemWidth = getStringWidth(item, style) || 0;
|
|
292
|
+
|
|
293
|
+
if (
|
|
294
|
+
currentLine &&
|
|
295
|
+
(width == null ||
|
|
296
|
+
scaleToFit ||
|
|
297
|
+
(currentLine.width || 0) + itemWidth + spaceWidth < width)
|
|
298
|
+
) {
|
|
299
|
+
// Word can be added to an existing line
|
|
300
|
+
currentLine.words.push(item);
|
|
301
|
+
currentLine.width = currentLine.width || 0;
|
|
302
|
+
currentLine.width += itemWidth + spaceWidth;
|
|
303
|
+
} else {
|
|
304
|
+
// Add first word to line or word is too long to scaleToFit on existing line
|
|
305
|
+
const newLine = { words: [item], width: itemWidth };
|
|
306
|
+
result.push(newLine);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return result;
|
|
310
|
+
}, []);
|
|
311
|
+
}
|
|
305
312
|
});
|
|
306
313
|
});
|
|
307
314
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TimeInterval } from 'd3-time';
|
|
2
|
+
/**
|
|
3
|
+
* Get the date at the end of the interval
|
|
4
|
+
* Similar to `interval.ceil(date)` except:
|
|
5
|
+
* - returns end of day instead of start of next day
|
|
6
|
+
* - properly handles start of day (i.e. not return same date)
|
|
7
|
+
*/
|
|
8
|
+
export declare function endOfInterval(date: Date, interval: TimeInterval): Date;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {} from 'd3-time';
|
|
2
|
+
/**
|
|
3
|
+
* Get the date at the end of the interval
|
|
4
|
+
* Similar to `interval.ceil(date)` except:
|
|
5
|
+
* - returns end of day instead of start of next day
|
|
6
|
+
* - properly handles start of day (i.e. not return same date)
|
|
7
|
+
*/
|
|
8
|
+
export function endOfInterval(date, interval) {
|
|
9
|
+
// Can not use `new Date(+interval.ceil(date) - 1)`; as `.ceil()` will return same date when start of the day (matching `.floor()`)
|
|
10
|
+
return new Date(interval.offset(interval.floor(date), 1).getTime() - 1);
|
|
11
|
+
}
|
package/dist/utils/genData.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { timeMinute, timeDay } from 'd3-time';
|
|
2
2
|
import { cumsum } from 'd3-array';
|
|
3
3
|
import { randomNormal } from 'd3-random';
|
|
4
4
|
import { degreesToRadians, radiansToDegrees } from './math.js';
|
|
@@ -44,14 +44,14 @@ export function createSeries(options) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
export function createDateSeries(options) {
|
|
47
|
-
const now =
|
|
47
|
+
const now = timeDay.floor(new Date());
|
|
48
48
|
const count = options.count ?? 10;
|
|
49
49
|
const min = options.min;
|
|
50
50
|
const max = options.max;
|
|
51
51
|
const keys = options.keys ?? ['value'];
|
|
52
52
|
return Array.from({ length: count }).map((_, i) => {
|
|
53
53
|
return {
|
|
54
|
-
date:
|
|
54
|
+
date: timeDay.offset(now, -count + i),
|
|
55
55
|
...Object.fromEntries(keys.map((key) => {
|
|
56
56
|
return [
|
|
57
57
|
key,
|
|
@@ -66,10 +66,10 @@ export function createTimeSeries(options) {
|
|
|
66
66
|
const min = options.min;
|
|
67
67
|
const max = options.max;
|
|
68
68
|
const keys = options.keys ?? ['value'];
|
|
69
|
-
let lastStartDate =
|
|
69
|
+
let lastStartDate = timeDay.floor(new Date());
|
|
70
70
|
const timeSeries = Array.from({ length: count }).map((_, i) => {
|
|
71
|
-
const startDate =
|
|
72
|
-
const endDate =
|
|
71
|
+
const startDate = timeMinute.offset(lastStartDate, getRandomInteger(0, 60));
|
|
72
|
+
const endDate = timeMinute.offset(startDate, getRandomInteger(5, 60));
|
|
73
73
|
lastStartDate = startDate;
|
|
74
74
|
return {
|
|
75
75
|
name: `item ${i + 1}`,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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.18",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@changesets/cli": "^2.29.4",
|
|
10
10
|
"@iconify-json/lucide": "^1.2.44",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"svelte": "5.32.1",
|
|
56
56
|
"svelte-check": "^4.2.1",
|
|
57
57
|
"svelte-json-tree": "^2.2.0",
|
|
58
|
-
"svelte-ux": "2.0.0-next.
|
|
58
|
+
"svelte-ux": "2.0.0-next.8",
|
|
59
59
|
"svelte2tsx": "^0.7.39",
|
|
60
60
|
"tailwindcss": "^4.1.7",
|
|
61
61
|
"topojson-client": "^3.1.0",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"type": "module",
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@dagrejs/dagre": "^1.1.4",
|
|
75
|
-
"@layerstack/svelte-actions": "1.0.1-next.
|
|
76
|
-
"@layerstack/svelte-state": "0.1.0-next.
|
|
77
|
-
"@layerstack/tailwind": "2.0.0-next.
|
|
78
|
-
"@layerstack/utils": "2.0.0-next.
|
|
75
|
+
"@layerstack/svelte-actions": "1.0.1-next.11",
|
|
76
|
+
"@layerstack/svelte-state": "0.1.0-next.16",
|
|
77
|
+
"@layerstack/tailwind": "2.0.0-next.13",
|
|
78
|
+
"@layerstack/utils": "2.0.0-next.11",
|
|
79
79
|
"d3-array": "^3.2.4",
|
|
80
80
|
"d3-color": "^3.1.0",
|
|
81
81
|
"d3-delaunay": "^6.0.4",
|
|
@@ -95,7 +95,6 @@
|
|
|
95
95
|
"d3-shape": "^3.2.0",
|
|
96
96
|
"d3-tile": "^1.0.0",
|
|
97
97
|
"d3-time": "^3.1.0",
|
|
98
|
-
"date-fns": "^4.1.0",
|
|
99
98
|
"lodash-es": "^4.17.21",
|
|
100
99
|
"runed": "^0.28.0"
|
|
101
100
|
},
|