layerchart 2.0.0-next.37 → 2.0.0-next.39
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/AnnotationLine.svelte +15 -2
- package/dist/components/AnnotationPoint.svelte +13 -2
- package/dist/components/AnnotationRange.svelte +16 -2
- package/dist/components/Arc.svelte +3 -3
- package/dist/components/Area.svelte +10 -2
- package/dist/components/Axis.svelte +43 -26
- package/dist/components/Axis.svelte.d.ts +10 -3
- package/dist/components/Bar.svelte +6 -5
- package/dist/components/Bar.svelte.d.ts +2 -2
- package/dist/components/Bars.svelte +3 -3
- package/dist/components/Blur.svelte +2 -3
- package/dist/components/BrushContext.svelte +44 -44
- package/dist/components/Calendar.svelte +21 -4
- package/dist/components/Chart.svelte +1 -2
- package/dist/components/Chart.svelte.d.ts +10 -3
- package/dist/components/ChartClipPath.svelte +1 -1
- package/dist/components/Circle.svelte +44 -3
- package/dist/components/CircleClipPath.svelte +8 -1
- package/dist/components/ClipPath.svelte +1 -2
- package/dist/components/ColorRamp.svelte +1 -1
- package/dist/components/ComputedStyles.svelte +9 -2
- package/dist/components/Connector.svelte +1 -1
- package/dist/components/Ellipse.svelte +44 -3
- package/dist/components/ForceSimulation.svelte.d.ts +10 -3
- package/dist/components/Frame.svelte +1 -1
- package/dist/components/GeoCircle.svelte +1 -1
- package/dist/components/GeoEdgeFade.svelte +1 -1
- package/dist/components/GeoPath.svelte +18 -3
- package/dist/components/GeoPoint.svelte +3 -3
- package/dist/components/GeoSpline.svelte +1 -1
- package/dist/components/GeoTile.svelte +1 -1
- package/dist/components/Graticule.svelte +5 -5
- package/dist/components/Grid.svelte +57 -60
- package/dist/components/Group.svelte +11 -6
- package/dist/components/Group.svelte.d.ts +10 -3
- package/dist/components/Highlight.svelte +46 -22
- package/dist/components/Highlight.svelte.d.ts +4 -0
- package/dist/components/Hull.svelte +11 -4
- package/dist/components/Labels.svelte +21 -11
- package/dist/components/Labels.svelte.d.ts +10 -3
- package/dist/components/Legend.svelte +133 -67
- package/dist/components/Legend.svelte.d.ts +7 -3
- package/dist/components/Line.svelte +40 -3
- package/dist/components/LinearGradient.svelte +35 -4
- package/dist/components/Link.svelte +1 -1
- package/dist/components/Marker.svelte +37 -26
- package/dist/components/MonthPath.svelte +14 -3
- package/dist/components/MotionPath.svelte +1 -1
- package/dist/components/Pack.svelte.d.ts +10 -3
- package/dist/components/Partition.svelte.d.ts +10 -3
- package/dist/components/Pattern.svelte +5 -5
- package/dist/components/Pie.svelte +1 -2
- package/dist/components/Points.svelte +1 -3
- package/dist/components/Polygon.svelte +27 -3
- package/dist/components/RadialGradient.svelte +3 -3
- package/dist/components/Rect.svelte +55 -5
- package/dist/components/Rect.svelte.d.ts +2 -2
- package/dist/components/RectClipPath.svelte +4 -3
- package/dist/components/RectClipPath.svelte.d.ts +2 -2
- package/dist/components/Rule.svelte +30 -23
- package/dist/components/Spline.svelte +29 -10
- package/dist/components/Text.svelte +59 -13
- package/dist/components/TileImage.svelte +19 -4
- package/dist/components/TransformContext.svelte +9 -3
- package/dist/components/TransformControls.svelte +72 -17
- package/dist/components/Tree.svelte.d.ts +10 -3
- package/dist/components/Treemap.svelte.d.ts +10 -3
- package/dist/components/Voronoi.svelte +12 -13
- package/dist/components/charts/ArcChart.svelte +40 -69
- package/dist/components/charts/ArcChart.svelte.d.ts +10 -3
- package/dist/components/charts/AreaChart.svelte +19 -42
- package/dist/components/charts/AreaChart.svelte.d.ts +10 -3
- package/dist/components/charts/BarChart.svelte +7 -18
- package/dist/components/charts/BarChart.svelte.d.ts +10 -3
- package/dist/components/charts/DefaultTooltip.svelte +2 -2
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +1 -1
- package/dist/components/charts/LineChart.svelte +61 -66
- package/dist/components/charts/LineChart.svelte.d.ts +21 -8
- package/dist/components/charts/PieChart.svelte +41 -69
- package/dist/components/charts/PieChart.svelte.d.ts +10 -3
- package/dist/components/charts/ScatterChart.svelte +8 -19
- package/dist/components/charts/ScatterChart.svelte.d.ts +10 -3
- package/dist/components/charts/utils.svelte.d.ts +1 -19
- package/dist/components/charts/utils.svelte.js +7 -39
- package/dist/components/layout/Canvas.svelte +29 -20
- package/dist/components/layout/Html.svelte +15 -9
- package/dist/components/layout/Svg.svelte +19 -11
- package/dist/components/layout/WebGL.svelte +26 -6
- package/dist/components/layout/WebGL.svelte.d.ts +5 -2
- package/dist/components/tooltip/Tooltip.svelte +60 -29
- package/dist/components/tooltip/Tooltip.svelte.d.ts +10 -3
- package/dist/components/tooltip/TooltipContext.svelte +73 -36
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +17 -3
- package/dist/components/tooltip/TooltipHeader.svelte +27 -14
- package/dist/components/tooltip/TooltipItem.svelte +41 -33
- package/dist/components/tooltip/TooltipList.svelte +12 -10
- package/dist/components/tooltip/TooltipSeparator.svelte +18 -10
- package/dist/states/series.svelte.d.ts +30 -0
- package/dist/states/series.svelte.js +54 -0
- package/dist/styles/daisyui-5.css +6 -0
- package/dist/styles/shadcn-svelte.css +11 -0
- package/dist/styles/skeleton-3.css +15 -0
- package/dist/utils/attributes.d.ts +3 -13
- package/dist/utils/attributes.js +4 -18
- package/dist/utils/common.d.ts +9 -0
- package/dist/utils/common.js +18 -1
- package/dist/utils/common.test.js +26 -1
- package/dist/utils/graph/dagre.d.ts +4 -4
- package/dist/utils/graph/dagre.js +5 -7
- package/dist/utils/math.d.ts +17 -0
- package/dist/utils/math.js +17 -0
- package/dist/utils/scales.svelte.js +3 -3
- package/dist/utils/stack.js +1 -1
- package/dist/utils/types.d.ts +15 -2
- package/package.json +25 -22
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SelectionState } from '@layerstack/svelte-state';
|
|
2
|
+
class HighlightKey {
|
|
3
|
+
current = $state(null);
|
|
4
|
+
set = (seriesKey) => {
|
|
5
|
+
this.current = seriesKey;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export class SeriesState {
|
|
9
|
+
#series = $state.raw([]);
|
|
10
|
+
selectedKeys = new SelectionState();
|
|
11
|
+
highlightKey = new HighlightKey();
|
|
12
|
+
constructor(getSeries) {
|
|
13
|
+
this.#series = getSeries();
|
|
14
|
+
$effect.pre(() => {
|
|
15
|
+
// keep series state in sync with the prop
|
|
16
|
+
this.#series = getSeries();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
get series() {
|
|
20
|
+
return this.#series;
|
|
21
|
+
}
|
|
22
|
+
get isDefaultSeries() {
|
|
23
|
+
return this.#series.length === 1 && this.#series[0].key === 'default';
|
|
24
|
+
}
|
|
25
|
+
get visibleSeries() {
|
|
26
|
+
return this.#series.filter((s) => this.isVisible(s.key));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if series is visible
|
|
30
|
+
*/
|
|
31
|
+
isVisible(seriesKey) {
|
|
32
|
+
return this.selectedKeys.isEmpty() || this.selectedKeys.isSelected(seriesKey);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check if series is highlighted
|
|
36
|
+
* Changing default to `true` is useful to determine if series should be faded
|
|
37
|
+
*/
|
|
38
|
+
isHighlighted(seriesKey, defaultValue = false) {
|
|
39
|
+
if (this.highlightKey.current === null) {
|
|
40
|
+
return defaultValue;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return this.highlightKey.current === seriesKey;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
get allSeriesData() {
|
|
47
|
+
return this.#series
|
|
48
|
+
.flatMap((s) => s.data?.map((d) => ({ seriesKey: s.key, ...d })))
|
|
49
|
+
.filter((d) => d);
|
|
50
|
+
}
|
|
51
|
+
get allSeriesColors() {
|
|
52
|
+
return this.#series.map((s) => s.color).filter((c) => c != null);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
When NOT using shadcn-svelte Chart component.
|
|
3
|
+
Not typically needed even when using built-in Chart, as defaults typically are sufficient
|
|
4
|
+
*/
|
|
5
|
+
.lc-root-container {
|
|
6
|
+
--color-primary: var(--primary);
|
|
7
|
+
--color-surface-100: var(--card-background);
|
|
8
|
+
--color-surface-200: var(--card-muted);
|
|
9
|
+
/* No direct mapping, should add explicit color (light and dark mode) */
|
|
10
|
+
--color-surface-content: var(--card-foreground);
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.lc-root-container {
|
|
2
|
+
--color-primary: var(--color-primary-500);
|
|
3
|
+
|
|
4
|
+
--color-surface-100: var(--color-surface-50);
|
|
5
|
+
--color-surface-200: var(--color-surface-100);
|
|
6
|
+
--color-surface-300: var(--color-surface-200);
|
|
7
|
+
--color-surface-content: var(--base-font-color);
|
|
8
|
+
|
|
9
|
+
html.dark & {
|
|
10
|
+
--color-surface-100: var(--color-surface-700);
|
|
11
|
+
--color-surface-200: var(--color-surface-800);
|
|
12
|
+
--color-surface-300: var(--color-surface-900);
|
|
13
|
+
--color-surface-content: var(--base-font-color-dark);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Creates a string containing a class name that can be used by
|
|
3
|
-
* developers to target a specific layer/element within a LayerChart.
|
|
4
|
-
*
|
|
5
|
-
* This is a function so that the class names remain consistent and the
|
|
6
|
-
* prefix/structure can be changed in the future if needed
|
|
7
|
-
*
|
|
8
|
-
* @param layerName - the name of the layer to be appended to the generated class name
|
|
9
|
-
* @returns a string to be used as a class on an element
|
|
10
|
-
*/
|
|
11
|
-
export declare function layerClass(layerName: string): string;
|
|
1
|
+
import type { ClassValue } from 'svelte/elements';
|
|
12
2
|
type ExtractObjectType<T> = T extends object ? (T extends Function ? never : T) : never;
|
|
13
3
|
type WithClass<T> = T & {
|
|
14
4
|
class?: string;
|
|
@@ -21,9 +11,9 @@ type DefaultProps = WithClass<{
|
|
|
21
11
|
* a class name to its class property to identify the layer for CSS targeting.
|
|
22
12
|
*
|
|
23
13
|
* @param props The props to be extracted, can be an object, function or any other type
|
|
24
|
-
* @param
|
|
14
|
+
* @param className The class name to be applied to the layer for targeting styling (e.g. 'lc-layer')
|
|
25
15
|
* @param extraClasses Additional classes to be applied to the layer if they don't exist in the props already
|
|
26
16
|
* @returns a typed spreadable object with props for the layer
|
|
27
17
|
*/
|
|
28
|
-
export declare function extractLayerProps<T>(props: T,
|
|
18
|
+
export declare function extractLayerProps<T>(props: T, className: string, ...extraClasses: ClassValue[]): WithClass<ExtractObjectType<T> extends never ? DefaultProps : ExtractObjectType<T>>;
|
|
29
19
|
export {};
|
package/dist/utils/attributes.js
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
import { cls } from '@layerstack/tailwind';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a string containing a class name that can be used by
|
|
4
|
-
* developers to target a specific layer/element within a LayerChart.
|
|
5
|
-
*
|
|
6
|
-
* This is a function so that the class names remain consistent and the
|
|
7
|
-
* prefix/structure can be changed in the future if needed
|
|
8
|
-
*
|
|
9
|
-
* @param layerName - the name of the layer to be appended to the generated class name
|
|
10
|
-
* @returns a string to be used as a class on an element
|
|
11
|
-
*/
|
|
12
|
-
export function layerClass(layerName) {
|
|
13
|
-
return `lc-${layerName}`;
|
|
14
|
-
}
|
|
15
2
|
// type guard to narrow props to an object with optional class
|
|
16
3
|
// for extractLayerProps
|
|
17
4
|
function isObjectWithClass(val) {
|
|
@@ -22,19 +9,18 @@ function isObjectWithClass(val) {
|
|
|
22
9
|
* a class name to its class property to identify the layer for CSS targeting.
|
|
23
10
|
*
|
|
24
11
|
* @param props The props to be extracted, can be an object, function or any other type
|
|
25
|
-
* @param
|
|
12
|
+
* @param className The class name to be applied to the layer for targeting styling (e.g. 'lc-layer')
|
|
26
13
|
* @param extraClasses Additional classes to be applied to the layer if they don't exist in the props already
|
|
27
14
|
* @returns a typed spreadable object with props for the layer
|
|
28
15
|
*/
|
|
29
|
-
export function extractLayerProps(props,
|
|
30
|
-
const className = layerClass(layerName);
|
|
16
|
+
export function extractLayerProps(props, className, ...extraClasses) {
|
|
31
17
|
if (isObjectWithClass(props)) {
|
|
32
18
|
return {
|
|
33
19
|
...props,
|
|
34
|
-
class: cls(className, props.class
|
|
20
|
+
class: cls(className, ...extraClasses, props.class),
|
|
35
21
|
};
|
|
36
22
|
}
|
|
37
23
|
return {
|
|
38
|
-
class: cls(className, extraClasses),
|
|
24
|
+
class: cls(className, ...extraClasses),
|
|
39
25
|
};
|
|
40
26
|
}
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -16,3 +16,12 @@ export declare function defaultChartPadding<TData, SeriesComponent extends Compo
|
|
|
16
16
|
* Handles complex objects such as `Date` by invoking `.valueOf()`
|
|
17
17
|
*/
|
|
18
18
|
export declare function findRelatedData(data: any[], original: any, accessor: Function): any;
|
|
19
|
+
/**
|
|
20
|
+
* Return the object if the value is an object, otherwise return null.
|
|
21
|
+
* Functions (including Snippet types) are treated as non-objects and return null.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getObjectOrNull<T>(value: T): T extends object ? T extends Function ? null : T : T extends null ? null : T extends undefined ? undefined : null;
|
|
24
|
+
/**
|
|
25
|
+
* Call with args if function, otherwise return the value.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveMaybeFn<T>(value: T | ((...args: any[]) => T), ...args: any[]): any;
|
package/dist/utils/common.js
CHANGED
|
@@ -40,7 +40,7 @@ export function defaultChartPadding(axis = true, legend = false) {
|
|
|
40
40
|
return {
|
|
41
41
|
top: axis === true || axis === 'y' ? 4 : 0,
|
|
42
42
|
left: axis === true || axis === 'y' ? 20 : 0,
|
|
43
|
-
bottom: (axis === true || axis === 'x' ? 20 : 0) + (legend
|
|
43
|
+
bottom: (axis === true || axis === 'x' ? 20 : 0) + (legend ? 32 : 0),
|
|
44
44
|
right: axis === true || axis === 'x' ? 4 : 0,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
@@ -54,3 +54,20 @@ export function findRelatedData(data, original, accessor) {
|
|
|
54
54
|
return accessor(d)?.valueOf() === accessor(original)?.valueOf();
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Return the object if the value is an object, otherwise return null.
|
|
59
|
+
* Functions (including Snippet types) are treated as non-objects and return null.
|
|
60
|
+
*/
|
|
61
|
+
export function getObjectOrNull(value) {
|
|
62
|
+
if (typeof value === 'object')
|
|
63
|
+
return value;
|
|
64
|
+
if (value === undefined)
|
|
65
|
+
return undefined;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Call with args if function, otherwise return the value.
|
|
70
|
+
*/
|
|
71
|
+
export function resolveMaybeFn(value, ...args) {
|
|
72
|
+
return typeof value === 'function' ? value(...args) : value;
|
|
73
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { accessor } from './common.js';
|
|
2
|
+
import { accessor, resolveMaybeFn, getObjectOrNull } from './common.js';
|
|
3
3
|
export const testData = {
|
|
4
4
|
one: 1,
|
|
5
5
|
two: 2,
|
|
@@ -36,3 +36,28 @@ describe('accessor', () => {
|
|
|
36
36
|
expect(actual).toEqual(testData);
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
describe('getObjectOrNull', () => {
|
|
40
|
+
it('returns null for non-object values', () => {
|
|
41
|
+
expect(getObjectOrNull(5)).toBeNull();
|
|
42
|
+
expect(getObjectOrNull('string')).toBeNull();
|
|
43
|
+
expect(getObjectOrNull(null)).toBeNull();
|
|
44
|
+
expect(getObjectOrNull(undefined)).toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
it('returns null for functions', () => {
|
|
47
|
+
const fn = () => { };
|
|
48
|
+
expect(getObjectOrNull(fn)).toBeNull();
|
|
49
|
+
});
|
|
50
|
+
it('returns the object if value is an object', () => {
|
|
51
|
+
const obj = { a: 1 };
|
|
52
|
+
expect(getObjectOrNull(obj)).toBe(obj);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('resolveMaybeFn', () => {
|
|
56
|
+
it('returns value if not a function', () => {
|
|
57
|
+
expect(resolveMaybeFn(5)).toBe(5);
|
|
58
|
+
});
|
|
59
|
+
it('calls function with args', () => {
|
|
60
|
+
const fn = (a, b) => a + b;
|
|
61
|
+
expect(resolveMaybeFn(fn, 2, 3)).toBe(5);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -25,10 +25,10 @@ export declare function dagreGraph(data: DagreProps['data'], { nodes, nodeId, ed
|
|
|
25
25
|
filterNodes?: DagreProps['filterNodes'];
|
|
26
26
|
}): dagre.graphlib.Graph<{}>;
|
|
27
27
|
/**
|
|
28
|
-
* Get all upstream predecessors for dagre nodeId
|
|
28
|
+
* Get all upstream predecessors ids for dagre nodeId
|
|
29
29
|
*/
|
|
30
|
-
export declare function dagreAncestors(graph: dagre.graphlib.Graph, nodeId: string, maxDepth?: number, currentDepth?: number):
|
|
30
|
+
export declare function dagreAncestors(graph: dagre.graphlib.Graph, nodeId: string, maxDepth?: number, currentDepth?: number): string[];
|
|
31
31
|
/**
|
|
32
|
-
* Get all downstream descendants for dagre nodeId
|
|
32
|
+
* Get all downstream descendants ids for dagre nodeId
|
|
33
33
|
*/
|
|
34
|
-
export declare function dagreDescendants(graph: dagre.graphlib.Graph, nodeId: string, maxDepth?: number, currentDepth?: number):
|
|
34
|
+
export declare function dagreDescendants(graph: dagre.graphlib.Graph, nodeId: string, maxDepth?: number, currentDepth?: number): string[];
|
|
@@ -49,7 +49,7 @@ export function dagreGraph(data, { nodes = (d) => d.nodes, nodeId = (d) => d.id,
|
|
|
49
49
|
return g;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
* Get all upstream predecessors for dagre nodeId
|
|
52
|
+
* Get all upstream predecessors ids for dagre nodeId
|
|
53
53
|
*/
|
|
54
54
|
export function dagreAncestors(graph, nodeId, maxDepth = Infinity, currentDepth = 0) {
|
|
55
55
|
if (currentDepth === maxDepth) {
|
|
@@ -58,21 +58,19 @@ export function dagreAncestors(graph, nodeId, maxDepth = Infinity, currentDepth
|
|
|
58
58
|
const predecessors = graph.predecessors(nodeId) ?? [];
|
|
59
59
|
return [
|
|
60
60
|
...predecessors,
|
|
61
|
-
// @ts-expect-error: Types from dagre appear incorrect
|
|
62
61
|
...predecessors.flatMap((pId) => dagreAncestors(graph, pId, maxDepth, currentDepth + 1)),
|
|
63
62
|
];
|
|
64
63
|
}
|
|
65
64
|
/**
|
|
66
|
-
* Get all downstream descendants for dagre nodeId
|
|
65
|
+
* Get all downstream descendants ids for dagre nodeId
|
|
67
66
|
*/
|
|
68
67
|
export function dagreDescendants(graph, nodeId, maxDepth = Infinity, currentDepth = 0) {
|
|
69
68
|
if (currentDepth === maxDepth) {
|
|
70
69
|
return [];
|
|
71
70
|
}
|
|
72
|
-
const
|
|
71
|
+
const successors = graph.successors(nodeId) ?? [];
|
|
73
72
|
return [
|
|
74
|
-
...
|
|
75
|
-
|
|
76
|
-
...predecessors.flatMap((pId) => dagreDescendants(graph, pId, maxDepth, currentDepth + 1)),
|
|
73
|
+
...successors,
|
|
74
|
+
...successors.flatMap((pId) => dagreDescendants(graph, pId, maxDepth, currentDepth + 1)),
|
|
77
75
|
];
|
|
78
76
|
}
|
package/dist/utils/math.d.ts
CHANGED
|
@@ -23,6 +23,23 @@ export declare function cartesianToPolar(x: number, y: number): {
|
|
|
23
23
|
radius: number;
|
|
24
24
|
radians: number;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Calculate the angle and length between two points
|
|
28
|
+
* @param point1 - First point
|
|
29
|
+
* @param point2 - Second point
|
|
30
|
+
* @returns Angle in degrees and length
|
|
31
|
+
*/
|
|
32
|
+
export declare function pointsToAngleAndLength(point1: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}, point2: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}): {
|
|
39
|
+
radians: number;
|
|
40
|
+
angle: number;
|
|
41
|
+
length: number;
|
|
42
|
+
};
|
|
26
43
|
/** Convert celsius temperature to fahrenheit */
|
|
27
44
|
export declare function celsiusToFahrenheit(temperature: number): number;
|
|
28
45
|
/** Convert fahrenheit temperature to celsius */
|
package/dist/utils/math.js
CHANGED
|
@@ -37,6 +37,23 @@ export function cartesianToPolar(x, y) {
|
|
|
37
37
|
radians,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Calculate the angle and length between two points
|
|
42
|
+
* @param point1 - First point
|
|
43
|
+
* @param point2 - Second point
|
|
44
|
+
* @returns Angle in degrees and length
|
|
45
|
+
*/
|
|
46
|
+
export function pointsToAngleAndLength(point1, point2) {
|
|
47
|
+
const dx = point2.x - point1.x;
|
|
48
|
+
const dy = point2.y - point1.y;
|
|
49
|
+
const radians = Math.atan2(dy, dx);
|
|
50
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
51
|
+
return {
|
|
52
|
+
radians,
|
|
53
|
+
angle: radiansToDegrees(radians),
|
|
54
|
+
length,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
40
57
|
/** Convert celsius temperature to fahrenheit */
|
|
41
58
|
export function celsiusToFahrenheit(temperature) {
|
|
42
59
|
return temperature * (9 / 5) + 32;
|
|
@@ -97,9 +97,9 @@ export function createScale(scale, domain, range, context) {
|
|
|
97
97
|
*/
|
|
98
98
|
export function autoScale(domain, data, propAccessor) {
|
|
99
99
|
let values = null;
|
|
100
|
-
if (domain && domain.length > 0) {
|
|
101
|
-
// Determine based on domain values
|
|
102
|
-
values = domain;
|
|
100
|
+
if (domain && domain.length > 0 && domain.some((d) => d != null)) {
|
|
101
|
+
// Determine based on non-null domain values
|
|
102
|
+
values = domain.filter((d) => d != null);
|
|
103
103
|
}
|
|
104
104
|
else if (data && data.length > 0 && propAccessor) {
|
|
105
105
|
// Determine based on data values
|
package/dist/utils/stack.js
CHANGED
|
@@ -91,7 +91,7 @@ export function stackOffsetSeparated(series, order) {
|
|
|
91
91
|
return;
|
|
92
92
|
// Standard series
|
|
93
93
|
for (var i = 1, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
|
|
94
|
-
(s0 = s1), (s1 = series[order[i]]);
|
|
94
|
+
((s0 = s1), (s1 = series[order[i]]));
|
|
95
95
|
// @ts-expect-error
|
|
96
96
|
let base = max(s0, (d) => d[1]) + gap; // here is where you calculate the maximum of the previous layer
|
|
97
97
|
for (var j = 0; j < m; ++j) {
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { MouseEventHandler, PointerEventHandler } from 'svelte/elements';
|
|
2
|
+
import type { TransitionConfig } from 'svelte/transition';
|
|
1
3
|
import type { HierarchyNode } from 'd3-hierarchy';
|
|
2
|
-
import type { AnyScale } from './scales.svelte.js';
|
|
3
4
|
import type { SankeyGraph } from 'd3-sankey';
|
|
4
|
-
import type {
|
|
5
|
+
import type { AnyScale } from './scales.svelte.js';
|
|
5
6
|
/**
|
|
6
7
|
* Useful to workaround Svelte 3/4 markup type issues
|
|
7
8
|
* TODO: Remove usage after migrating to Svelte 5
|
|
@@ -79,6 +80,18 @@ export type CommonStyleProps = {
|
|
|
79
80
|
*/
|
|
80
81
|
opacity?: number;
|
|
81
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Events for primatives which support `SVGRectElement` and `HTMLDivElement` elements based on render context
|
|
85
|
+
*/
|
|
86
|
+
export type CommonEvents = {
|
|
87
|
+
onclick?: MouseEventHandler<Element> | null;
|
|
88
|
+
ondblclick?: MouseEventHandler<Element> | null;
|
|
89
|
+
onpointerenter?: PointerEventHandler<Element> | null;
|
|
90
|
+
onpointermove?: PointerEventHandler<Element> | null;
|
|
91
|
+
onpointerleave?: PointerEventHandler<Element> | null;
|
|
92
|
+
onpointerover?: PointerEventHandler<Element> | null;
|
|
93
|
+
onpointerout?: PointerEventHandler<Element> | null;
|
|
94
|
+
};
|
|
82
95
|
export type OnlyObjects<T> = T extends object ? T : never;
|
|
83
96
|
export type Getter<T> = () => T;
|
|
84
97
|
export type GetterValues<T> = {
|
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.39",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@changesets/cli": "^2.29.
|
|
10
|
-
"@iconify-json/lucide": "^1.2.
|
|
9
|
+
"@changesets/cli": "^2.29.6",
|
|
10
|
+
"@iconify-json/lucide": "^1.2.62",
|
|
11
11
|
"@rollup/plugin-dsv": "^3.0.5",
|
|
12
|
-
"@sveltejs/adapter-cloudflare": "^7.
|
|
13
|
-
"@sveltejs/kit": "^2.
|
|
14
|
-
"@sveltejs/package": "^2.
|
|
15
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
12
|
+
"@sveltejs/adapter-cloudflare": "^7.2.1",
|
|
13
|
+
"@sveltejs/kit": "^2.31.1",
|
|
14
|
+
"@sveltejs/package": "^2.4.1",
|
|
15
|
+
"@sveltejs/vite-plugin-svelte": "^6.1.2",
|
|
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.12",
|
|
19
19
|
"@types/d3": "^7.4.3",
|
|
20
20
|
"@types/d3-array": "^3.2.1",
|
|
21
21
|
"@types/d3-color": "^3.1.3",
|
|
@@ -39,36 +39,35 @@
|
|
|
39
39
|
"@types/topojson-client": "^3.1.5",
|
|
40
40
|
"@types/topojson-simplify": "^3.0.3",
|
|
41
41
|
"@types/topojson-specification": "^1.0.5",
|
|
42
|
-
"marked": "^15.0.12",
|
|
43
42
|
"mdsvex": "^0.12.3",
|
|
44
|
-
"posthog-js": "^1.
|
|
45
|
-
"prettier": "^3.
|
|
43
|
+
"posthog-js": "^1.260.1",
|
|
44
|
+
"prettier": "^3.6.2",
|
|
46
45
|
"prettier-plugin-svelte": "^3.4.0",
|
|
47
46
|
"rehype-slug": "^6.0.0",
|
|
48
47
|
"rollup-plugin-visualizer": "^6.0.3",
|
|
49
48
|
"shapefile": "^0.6.6",
|
|
50
49
|
"shiki": "^3.9.2",
|
|
51
50
|
"solar-calculator": "^0.3.0",
|
|
52
|
-
"svelte": "5.
|
|
53
|
-
"svelte-check": "^4.
|
|
51
|
+
"svelte": "^5.38.2",
|
|
52
|
+
"svelte-check": "^4.3.1",
|
|
54
53
|
"svelte-json-tree": "^2.2.0",
|
|
55
54
|
"svelte-ux": "2.0.0-next.17",
|
|
56
|
-
"svelte2tsx": "^0.7.
|
|
57
|
-
"tailwindcss": "^4.1.
|
|
55
|
+
"svelte2tsx": "^0.7.42",
|
|
56
|
+
"tailwindcss": "^4.1.12",
|
|
58
57
|
"topojson-client": "^3.1.0",
|
|
59
58
|
"topojson-simplify": "^3.0.3",
|
|
60
59
|
"tslib": "^2.8.1",
|
|
61
|
-
"typescript": "^5.
|
|
60
|
+
"typescript": "^5.9.2",
|
|
62
61
|
"unist-util-visit": "^5.0.0",
|
|
63
|
-
"unplugin-icons": "^22.
|
|
62
|
+
"unplugin-icons": "^22.2.0",
|
|
64
63
|
"us-atlas": "^3.0.1",
|
|
65
|
-
"vite": "^
|
|
66
|
-
"vite-plugin-devtools-json": "^0.
|
|
67
|
-
"vitest": "^3.2.
|
|
64
|
+
"vite": "^7.1.2",
|
|
65
|
+
"vite-plugin-devtools-json": "^1.0.0",
|
|
66
|
+
"vitest": "^3.2.4"
|
|
68
67
|
},
|
|
69
68
|
"type": "module",
|
|
70
69
|
"dependencies": {
|
|
71
|
-
"@dagrejs/dagre": "^1.1.
|
|
70
|
+
"@dagrejs/dagre": "^1.1.5",
|
|
72
71
|
"@layerstack/svelte-actions": "1.0.1-next.14",
|
|
73
72
|
"@layerstack/svelte-state": "0.1.0-next.19",
|
|
74
73
|
"@layerstack/tailwind": "2.0.0-next.17",
|
|
@@ -94,7 +93,7 @@
|
|
|
94
93
|
"d3-time": "^3.1.0",
|
|
95
94
|
"lodash-es": "^4.17.21",
|
|
96
95
|
"memoize": "^10.1.0",
|
|
97
|
-
"runed": "^0.
|
|
96
|
+
"runed": "^0.31.1"
|
|
98
97
|
},
|
|
99
98
|
"peerDependencies": {
|
|
100
99
|
"svelte": "^5.0.0"
|
|
@@ -110,6 +109,10 @@
|
|
|
110
109
|
"types": "./dist/utils/*.d.ts",
|
|
111
110
|
"svelte": "./dist/utils/*.js",
|
|
112
111
|
"default": "./dist/utils/*.js"
|
|
112
|
+
},
|
|
113
|
+
"./*.css": {
|
|
114
|
+
"style": "./dist/styles/*.css",
|
|
115
|
+
"default": "./dist/styles/*.css"
|
|
113
116
|
}
|
|
114
117
|
},
|
|
115
118
|
"files": [
|