layerchart 2.0.0-next.26 → 2.0.0-next.28
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.
|
@@ -400,7 +400,7 @@
|
|
|
400
400
|
<Text {...resolvedLabelProps} />
|
|
401
401
|
{/if}
|
|
402
402
|
|
|
403
|
-
{#each tickVals as tick, index (tick)}
|
|
403
|
+
{#each tickVals as tick, index (tick.valueOf())}
|
|
404
404
|
{@const tickCoords = getCoords(tick)}
|
|
405
405
|
{@const [radialTickCoordsX, radialTickCoordsY] = pointRadial(tickCoords.x, tickCoords.y)}
|
|
406
406
|
{@const [radialTickMarkCoordsX, radialTickMarkCoordsY] = pointRadial(
|
package/dist/utils/array.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Numeric } from 'd3-array';
|
|
2
2
|
import { extent as d3extent } from 'd3-array';
|
|
3
|
+
import { type Accessor } from './common.js';
|
|
3
4
|
/**
|
|
4
5
|
* Wrapper around d3-array's `extent()` but remove [undefined, undefined] return type
|
|
5
6
|
*/
|
|
@@ -16,8 +17,8 @@ export declare function arraysEqual(arr1: unknown[], arr2: unknown[]): boolean;
|
|
|
16
17
|
* This is useful for visualizing overlapping events in a timeline / Gantt chart.
|
|
17
18
|
*/
|
|
18
19
|
export declare function applyLanes<T extends Record<string, any>>(data: T[], options?: {
|
|
19
|
-
start:
|
|
20
|
-
end:
|
|
20
|
+
start: Accessor<T>;
|
|
21
|
+
end: Accessor<T>;
|
|
21
22
|
}): (T & {
|
|
22
23
|
lane: number;
|
|
23
24
|
})[];
|
package/dist/utils/array.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extent as d3extent } from 'd3-array';
|
|
2
|
+
import { accessor } from './common.js';
|
|
2
3
|
/**
|
|
3
4
|
* Wrapper around d3-array's `extent()` but remove [undefined, undefined] return type
|
|
4
5
|
*/
|
|
@@ -22,11 +23,16 @@ export function arraysEqual(arr1, arr2) {
|
|
|
22
23
|
* Add `lanes` property to each element in the data array support densely packing.
|
|
23
24
|
* This is useful for visualizing overlapping events in a timeline / Gantt chart.
|
|
24
25
|
*/
|
|
25
|
-
export function applyLanes(data, options = {
|
|
26
|
+
export function applyLanes(data, options = {
|
|
27
|
+
start: 'start',
|
|
28
|
+
end: 'end',
|
|
29
|
+
}) {
|
|
26
30
|
const result = [];
|
|
27
31
|
let stack = [];
|
|
32
|
+
const startAccessor = accessor(options.start);
|
|
33
|
+
const endAccessor = accessor(options.end);
|
|
28
34
|
for (const d of data) {
|
|
29
|
-
let lane = stack.findIndex((s) => s
|
|
35
|
+
let lane = stack.findIndex((s) => endAccessor(s) <= startAccessor(d) && startAccessor(s) < startAccessor(d));
|
|
30
36
|
if (lane === -1) {
|
|
31
37
|
lane = stack.length;
|
|
32
38
|
}
|
package/dist/utils/array.test.js
CHANGED
|
@@ -76,6 +76,44 @@ describe('applyLanes', () => {
|
|
|
76
76
|
},
|
|
77
77
|
]);
|
|
78
78
|
});
|
|
79
|
+
it('should work with nested string keys for start and end', () => {
|
|
80
|
+
const data = [
|
|
81
|
+
{ name: 'Task 1', duration: { start: new Date('2023-01-01'), end: new Date('2023-01-02') } },
|
|
82
|
+
{ name: 'Task 2', duration: { start: new Date('2023-01-03'), end: new Date('2023-01-04') } },
|
|
83
|
+
];
|
|
84
|
+
const result = applyLanes(data, { start: 'duration.start', end: 'duration.end' });
|
|
85
|
+
expect(result).toEqual([
|
|
86
|
+
{
|
|
87
|
+
name: 'Task 1',
|
|
88
|
+
duration: { start: new Date('2023-01-01'), end: new Date('2023-01-02') },
|
|
89
|
+
lane: 0,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'Task 2',
|
|
93
|
+
duration: { start: new Date('2023-01-03'), end: new Date('2023-01-04') },
|
|
94
|
+
lane: 0,
|
|
95
|
+
},
|
|
96
|
+
]);
|
|
97
|
+
});
|
|
98
|
+
it('should work with function accessors for start and end', () => {
|
|
99
|
+
const data = [
|
|
100
|
+
{ name: 'Task 1', duration: { start: new Date('2023-01-01'), end: new Date('2023-01-02') } },
|
|
101
|
+
{ name: 'Task 2', duration: { start: new Date('2023-01-03'), end: new Date('2023-01-04') } },
|
|
102
|
+
];
|
|
103
|
+
const result = applyLanes(data, { start: (d) => d.duration.start, end: (d) => d.duration.end });
|
|
104
|
+
expect(result).toEqual([
|
|
105
|
+
{
|
|
106
|
+
name: 'Task 1',
|
|
107
|
+
duration: { start: new Date('2023-01-01'), end: new Date('2023-01-02') },
|
|
108
|
+
lane: 0,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'Task 2',
|
|
112
|
+
duration: { start: new Date('2023-01-03'), end: new Date('2023-01-04') },
|
|
113
|
+
lane: 0,
|
|
114
|
+
},
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
79
117
|
it('should handle empty array', () => {
|
|
80
118
|
const data = [];
|
|
81
119
|
const result = applyLanes(data);
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED