layerchart 2.0.0-next.41 → 2.0.0-next.43
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/Arc.svelte +1 -1
- package/dist/components/Axis.svelte +1 -9
- package/dist/components/Calendar.svelte +9 -4
- package/dist/components/Highlight.svelte +10 -0
- package/dist/components/MonthPath.svelte +9 -3
- package/dist/components/MonthPath.svelte.d.ts +4 -0
- package/dist/components/tooltip/TooltipContext.svelte +26 -0
- package/dist/docs/ViewSourceButton.svelte +1 -1
- package/dist/utils/ticks.js +1 -1
- package/package.json +1 -1
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
const ctx = getChartContext();
|
|
252
252
|
|
|
253
253
|
const endAngle = $derived(
|
|
254
|
-
endAngleProp ?? degreesToRadians(ctx.
|
|
254
|
+
endAngleProp ?? degreesToRadians(ctx.xRange ? max(ctx.xRange) : max(range))
|
|
255
255
|
);
|
|
256
256
|
|
|
257
257
|
const motionEndAngle = createMotion(initialValue, () => value, motion);
|
|
@@ -125,15 +125,7 @@
|
|
|
125
125
|
|
|
126
126
|
import { extent } from 'd3-array';
|
|
127
127
|
import { pointRadial } from 'd3-shape';
|
|
128
|
-
import {
|
|
129
|
-
timeDay,
|
|
130
|
-
timeHour,
|
|
131
|
-
timeMillisecond,
|
|
132
|
-
timeMinute,
|
|
133
|
-
timeMonth,
|
|
134
|
-
timeSecond,
|
|
135
|
-
timeYear,
|
|
136
|
-
} from 'd3-time';
|
|
128
|
+
import { timeDay, timeHour, timeMillisecond, timeMinute, timeSecond, timeYear } from 'd3-time';
|
|
137
129
|
|
|
138
130
|
import { type FormatType, type FormatConfig, unique, PeriodType } from '@layerstack/utils';
|
|
139
131
|
import { cls } from '@layerstack/tailwind';
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
|
|
56
56
|
<script lang="ts">
|
|
57
57
|
import { type ComponentProps, type Snippet } from 'svelte';
|
|
58
|
-
import { timeDays, timeMonths, timeWeek
|
|
58
|
+
import { timeDays, timeMonths, timeWeek } from 'd3-time';
|
|
59
59
|
import { index } from 'd3-array';
|
|
60
60
|
import { format } from '@layerstack/utils';
|
|
61
61
|
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
yearDays.map((date) => {
|
|
108
108
|
const cellData = dataByDate.get(date) ?? { date };
|
|
109
109
|
return {
|
|
110
|
-
x: timeWeek.count(
|
|
110
|
+
x: timeWeek.count(start, date) * cellSize[0],
|
|
111
111
|
y: date.getDay() * cellSize[1],
|
|
112
112
|
color: ctx.config.c ? ctx.cGet(cellData) : 'transparent',
|
|
113
113
|
data: cellData,
|
|
@@ -136,14 +136,19 @@
|
|
|
136
136
|
|
|
137
137
|
{#if monthPath}
|
|
138
138
|
{#each yearMonths as date}
|
|
139
|
-
<MonthPath
|
|
139
|
+
<MonthPath
|
|
140
|
+
{date}
|
|
141
|
+
startOfRange={start}
|
|
142
|
+
{cellSize}
|
|
143
|
+
{...extractLayerProps(monthPath, 'lc-calendar-month-path')}
|
|
144
|
+
/>
|
|
140
145
|
{/each}
|
|
141
146
|
{/if}
|
|
142
147
|
|
|
143
148
|
{#if monthLabel}
|
|
144
149
|
{#each yearMonths as date}
|
|
145
150
|
<Text
|
|
146
|
-
x={timeWeek.count(
|
|
151
|
+
x={timeWeek.count(start, timeWeek.ceil(date)) * cellSize[0]}
|
|
147
152
|
value={format(date, 'month', { variant: 'short' })}
|
|
148
153
|
capHeight="7px"
|
|
149
154
|
{...extractLayerProps(monthLabel, 'lc-calendar-month-label')}
|
|
@@ -264,6 +264,11 @@
|
|
|
264
264
|
tmpArea.width = max(xCoord) - min(xCoord); // Use first/last values for width
|
|
265
265
|
} else if (isScaleBand(ctx.xScale)) {
|
|
266
266
|
tmpArea.width = ctx.xScale.step();
|
|
267
|
+
} else if (ctx.xInterval) {
|
|
268
|
+
// x-axis time scale with interval
|
|
269
|
+
const start = ctx.xInterval.floor(xValue);
|
|
270
|
+
const end = ctx.xInterval.offset(start);
|
|
271
|
+
tmpArea.width = ctx.xScale(end) - ctx.xScale(start);
|
|
267
272
|
} else {
|
|
268
273
|
// Find width to next data point
|
|
269
274
|
const index = ctx.flatData.findIndex((d) => Number(x(d)) === Number(x(highlightData)));
|
|
@@ -290,6 +295,11 @@
|
|
|
290
295
|
tmpArea.height = max(yCoord) - min(yCoord); // Use first/last values for width
|
|
291
296
|
} else if (isScaleBand(ctx.yScale)) {
|
|
292
297
|
tmpArea.height = ctx.yScale.step();
|
|
298
|
+
} else if (ctx.yInterval) {
|
|
299
|
+
// y-axis time scale with interval
|
|
300
|
+
const start = ctx.yInterval.floor(yValue);
|
|
301
|
+
const end = ctx.yInterval.offset(start);
|
|
302
|
+
tmpArea.height = ctx.yScale(end) - ctx.yScale(start);
|
|
293
303
|
} else {
|
|
294
304
|
// Find width to next data point
|
|
295
305
|
const index = ctx.flatData.findIndex((d) => Number(y(d)) === Number(y(highlightData)));
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
cellSize: number | [number, number];
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The start date of the calendar (used to calculate week offsets).
|
|
20
|
+
*/
|
|
21
|
+
startOfRange: Date;
|
|
22
|
+
|
|
18
23
|
/**
|
|
19
24
|
* A bindable reference to the underlying `<path>` element.
|
|
20
25
|
*
|
|
@@ -30,7 +35,7 @@
|
|
|
30
35
|
</script>
|
|
31
36
|
|
|
32
37
|
<script lang="ts">
|
|
33
|
-
import { timeWeek
|
|
38
|
+
import { timeWeek } from 'd3-time';
|
|
34
39
|
import { cls } from '@layerstack/tailwind';
|
|
35
40
|
import { endOfInterval } from '@layerstack/utils';
|
|
36
41
|
import Spline, { type SplinePropsWithoutHTML } from './Spline.svelte';
|
|
@@ -38,6 +43,7 @@
|
|
|
38
43
|
let {
|
|
39
44
|
date,
|
|
40
45
|
cellSize: cellSizeProp,
|
|
46
|
+
startOfRange,
|
|
41
47
|
pathRef: pathRefProp = $bindable(),
|
|
42
48
|
class: className,
|
|
43
49
|
...restProps
|
|
@@ -54,12 +60,12 @@
|
|
|
54
60
|
|
|
55
61
|
// start of month
|
|
56
62
|
const startDayOfWeek = $derived(date.getDay());
|
|
57
|
-
const startWeek = $derived(timeWeek.count(
|
|
63
|
+
const startWeek = $derived(timeWeek.count(startOfRange, date));
|
|
58
64
|
|
|
59
65
|
// end of month
|
|
60
66
|
const monthEnd = $derived(endOfInterval('month', date));
|
|
61
67
|
const endDayOfWeek = $derived(monthEnd.getDay());
|
|
62
|
-
const endWeek = $derived(timeWeek.count(
|
|
68
|
+
const endWeek = $derived(timeWeek.count(startOfRange, monthEnd));
|
|
63
69
|
|
|
64
70
|
const pathData = $derived(`
|
|
65
71
|
M${(startWeek + 1) * cellSize[0]},${startDayOfWeek * cellSize[1]}
|
|
@@ -11,6 +11,10 @@ export type MonthPathPropsWithoutHTML = {
|
|
|
11
11
|
* - array - sets [width, height].
|
|
12
12
|
*/
|
|
13
13
|
cellSize: number | [number, number];
|
|
14
|
+
/**
|
|
15
|
+
* The start date of the calendar (used to calculate week offsets).
|
|
16
|
+
*/
|
|
17
|
+
startOfRange: Date;
|
|
14
18
|
/**
|
|
15
19
|
* A bindable reference to the underlying `<path>` element.
|
|
16
20
|
*
|
|
@@ -518,6 +518,32 @@
|
|
|
518
518
|
height: ctx.yScale.step(),
|
|
519
519
|
data: d,
|
|
520
520
|
};
|
|
521
|
+
} else if (ctx.xInterval) {
|
|
522
|
+
// x-axis time scale with interval
|
|
523
|
+
const xVal = ctx.x(d);
|
|
524
|
+
const start = ctx.xInterval.floor(xVal);
|
|
525
|
+
const end = ctx.xInterval.offset(start);
|
|
526
|
+
|
|
527
|
+
return {
|
|
528
|
+
x: ctx.xScale(start),
|
|
529
|
+
y: isScaleBand(ctx.yScale) ? y - yOffset : min(ctx.yRange),
|
|
530
|
+
width: ctx.xScale(end) - ctx.xScale(start),
|
|
531
|
+
height: isScaleBand(ctx.yScale) ? ctx.yScale.step() : fullHeight,
|
|
532
|
+
data: d,
|
|
533
|
+
};
|
|
534
|
+
} else if (ctx.yInterval) {
|
|
535
|
+
// y-axis time scale with interval
|
|
536
|
+
const yVal = ctx.y(d);
|
|
537
|
+
const start = ctx.yInterval.floor(yVal);
|
|
538
|
+
const end = ctx.yInterval.offset(start);
|
|
539
|
+
|
|
540
|
+
return {
|
|
541
|
+
x: isScaleBand(ctx.xScale) ? x - xOffset : min(ctx.xRange),
|
|
542
|
+
y: ctx.yScale(start),
|
|
543
|
+
width: isScaleBand(ctx.xScale) ? ctx.xScale.step() : fullWidth,
|
|
544
|
+
height: ctx.yScale(end) - ctx.yScale(start),
|
|
545
|
+
data: d,
|
|
546
|
+
};
|
|
521
547
|
} else if (isScaleTime(ctx.xScale)) {
|
|
522
548
|
// Find width to next data point
|
|
523
549
|
const index = ctx.flatData.findIndex(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { ComponentProps } from 'svelte';
|
|
3
3
|
import { Button, Dialog, Toggle, Tooltip } from 'svelte-ux';
|
|
4
|
-
import LucideGithub from '~icons/lucide/github
|
|
4
|
+
import LucideGithub from '~icons/lucide/github';
|
|
5
5
|
|
|
6
6
|
import Code from './Code.svelte';
|
|
7
7
|
|
package/dist/utils/ticks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { timeYear,
|
|
1
|
+
import { timeYear, timeDay, timeTicks } from 'd3-time';
|
|
2
2
|
import { format, Duration, isLiteralObject, DateToken, } from '@layerstack/utils';
|
|
3
3
|
import { isScaleBand, isScaleTime } from './scales.svelte.js';
|
|
4
4
|
export function getDurationFormat(duration, options = {
|
package/package.json
CHANGED