layerchart 2.0.0-next.1 → 2.0.0-next.3
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/actions/movable.d.ts +28 -0
- package/dist/actions/movable.js +91 -0
- package/dist/components/AnnotationLine.svelte +143 -0
- package/dist/components/AnnotationLine.svelte.d.ts +30 -0
- package/dist/components/AnnotationPoint.svelte +119 -0
- package/dist/components/AnnotationPoint.svelte.d.ts +34 -0
- package/dist/components/AnnotationRange.svelte +147 -0
- package/dist/components/AnnotationRange.svelte.d.ts +40 -0
- package/dist/components/Arc.svelte +344 -151
- package/dist/components/Arc.svelte.d.ts +138 -0
- package/dist/components/Area.svelte +165 -149
- package/dist/components/Area.svelte.d.ts +45 -0
- package/dist/components/Axis.svelte +283 -180
- package/dist/components/Axis.svelte.d.ts +117 -0
- package/dist/components/Bar.svelte +166 -107
- package/dist/components/Bar.svelte.d.ts +51 -0
- package/dist/components/Bars.svelte +56 -67
- package/dist/components/Bars.svelte.d.ts +27 -0
- package/dist/components/Blur.svelte +42 -12
- package/dist/components/Blur.svelte.d.ts +23 -21
- package/dist/components/Bounds.svelte +49 -19
- package/dist/components/Bounds.svelte.d.ts +24 -50
- package/dist/components/BrushContext.svelte +296 -168
- package/dist/components/BrushContext.svelte.d.ts +97 -65
- package/dist/components/Calendar.svelte +116 -59
- package/dist/components/Calendar.svelte.d.ts +50 -31
- package/dist/components/Chart.svelte +1289 -398
- package/dist/components/Chart.svelte.d.ts +535 -410
- package/dist/components/ChartClipPath.svelte +37 -15
- package/dist/components/ChartClipPath.svelte.d.ts +21 -19
- package/dist/components/Circle.svelte +124 -85
- package/dist/components/Circle.svelte.d.ts +52 -0
- package/dist/components/CircleClipPath.svelte +76 -16
- package/dist/components/CircleClipPath.svelte.d.ts +46 -0
- package/dist/components/ClipPath.svelte +71 -21
- package/dist/components/ClipPath.svelte.d.ts +40 -27
- package/dist/components/ColorRamp.svelte +75 -9
- package/dist/components/ColorRamp.svelte.d.ts +37 -19
- package/dist/components/ComputedStyles.svelte +17 -5
- package/dist/components/ComputedStyles.svelte.d.ts +11 -19
- package/dist/components/Connector.svelte +149 -0
- package/dist/components/Connector.svelte.d.ts +51 -0
- package/dist/components/Dagre.svelte +211 -122
- package/dist/components/Dagre.svelte.d.ts +119 -56
- package/dist/components/ForceSimulation.svelte +215 -90
- package/dist/components/ForceSimulation.svelte.d.ts +82 -35
- package/dist/components/Frame.svelte +33 -13
- package/dist/components/Frame.svelte.d.ts +13 -17
- package/dist/components/GeoCircle.svelte +29 -16
- package/dist/components/GeoCircle.svelte.d.ts +22 -24
- package/dist/components/GeoContext.svelte +113 -72
- package/dist/components/GeoContext.svelte.d.ts +49 -41
- package/dist/components/GeoEdgeFade.svelte +49 -13
- package/dist/components/GeoEdgeFade.svelte.d.ts +17 -19
- package/dist/components/GeoPath.svelte +157 -127
- package/dist/components/GeoPath.svelte.d.ts +48 -36
- package/dist/components/GeoPoint.svelte +52 -20
- package/dist/components/GeoPoint.svelte.d.ts +25 -22
- package/dist/components/GeoSpline.svelte +75 -26
- package/dist/components/GeoSpline.svelte.d.ts +29 -20
- package/dist/components/GeoTile.svelte +100 -49
- package/dist/components/GeoTile.svelte.d.ts +38 -23
- package/dist/components/GeoVisible.svelte +17 -9
- package/dist/components/GeoVisible.svelte.d.ts +10 -18
- package/dist/components/Graticule.svelte +30 -14
- package/dist/components/Graticule.svelte.d.ts +11 -52
- package/dist/components/Grid.svelte +230 -117
- package/dist/components/Grid.svelte.d.ts +71 -0
- package/dist/components/Group.svelte +173 -106
- package/dist/components/Group.svelte.d.ts +81 -0
- package/dist/components/Highlight.svelte +410 -308
- package/dist/components/Highlight.svelte.d.ts +107 -0
- package/dist/components/Hull.svelte +97 -46
- package/dist/components/Hull.svelte.d.ts +40 -30
- package/dist/components/Labels.svelte +127 -47
- package/dist/components/Labels.svelte.d.ts +70 -27
- package/dist/components/Legend.svelte +374 -190
- package/dist/components/Legend.svelte.d.ts +95 -44
- package/dist/components/Line.svelte +163 -125
- package/dist/components/Line.svelte.d.ts +75 -0
- package/dist/components/LinearGradient.svelte +153 -78
- package/dist/components/LinearGradient.svelte.d.ts +66 -31
- package/dist/components/Link.svelte +160 -104
- package/dist/components/Link.svelte.d.ts +54 -0
- package/dist/components/Marker.svelte +100 -39
- package/dist/components/Marker.svelte.d.ts +59 -27
- package/dist/components/MarkerWrapper.svelte +35 -0
- package/dist/components/MarkerWrapper.svelte.d.ts +18 -0
- package/dist/components/MonthPath.svelte +65 -20
- package/dist/components/MonthPath.svelte.d.ts +23 -17
- package/dist/components/MotionPath.svelte +80 -24
- package/dist/components/MotionPath.svelte.d.ts +46 -27
- package/dist/components/Pack.svelte +53 -17
- package/dist/components/Pack.svelte.d.ts +42 -21
- package/dist/components/Partition.svelte +64 -22
- package/dist/components/Partition.svelte.d.ts +49 -26
- package/dist/components/Pattern.svelte +297 -11
- package/dist/components/Pattern.svelte.d.ts +103 -19
- package/dist/components/Pie.svelte +122 -76
- package/dist/components/Pie.svelte.d.ts +65 -51
- package/dist/components/Point.svelte +20 -9
- package/dist/components/Point.svelte.d.ts +16 -20
- package/dist/components/Points.svelte +148 -137
- package/dist/components/Points.svelte.d.ts +45 -34
- package/dist/components/RadialGradient.svelte +143 -70
- package/dist/components/RadialGradient.svelte.d.ts +69 -31
- package/dist/components/Rect.svelte +121 -102
- package/dist/components/Rect.svelte.d.ts +36 -0
- package/dist/components/RectClipPath.svelte +82 -18
- package/dist/components/RectClipPath.svelte.d.ts +55 -0
- package/dist/components/Rule.svelte +107 -63
- package/dist/components/Rule.svelte.d.ts +40 -19
- package/dist/components/Sankey.svelte +132 -55
- package/dist/components/Sankey.svelte.d.ts +61 -31
- package/dist/components/Spline.svelte +281 -218
- package/dist/components/Spline.svelte.d.ts +95 -0
- package/dist/components/Text.svelte +437 -176
- package/dist/components/Text.svelte.d.ts +130 -0
- package/dist/components/Threshold.svelte +48 -16
- package/dist/components/Threshold.svelte.d.ts +29 -31
- package/dist/components/TileImage.svelte +103 -30
- package/dist/components/TileImage.svelte.d.ts +48 -23
- package/dist/components/TransformContext.svelte +365 -171
- package/dist/components/TransformControls.svelte +50 -26
- package/dist/components/TransformControls.svelte.d.ts +27 -19
- package/dist/components/Tree.svelte +74 -33
- package/dist/components/Tree.svelte.d.ts +42 -30
- package/dist/components/Treemap.svelte +119 -42
- package/dist/components/Treemap.svelte.d.ts +75 -27
- package/dist/components/Voronoi.svelte +108 -76
- package/dist/components/Voronoi.svelte.d.ts +40 -41
- package/dist/components/charts/ArcChart.svelte +464 -0
- package/dist/components/charts/ArcChart.svelte.d.ts +90 -0
- package/dist/components/charts/AreaChart.svelte +450 -393
- package/dist/components/charts/AreaChart.svelte.d.ts +61 -0
- package/dist/components/charts/BarChart.svelte +454 -389
- package/dist/components/charts/BarChart.svelte.d.ts +76 -0
- package/dist/components/charts/ChartAnnotations.svelte +37 -0
- package/dist/components/charts/ChartAnnotations.svelte.d.ts +10 -0
- package/dist/components/charts/DefaultTooltip.svelte +60 -0
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +10 -0
- package/dist/components/charts/LineChart.svelte +369 -314
- package/dist/components/charts/LineChart.svelte.d.ts +53 -0
- package/dist/components/charts/PieChart.svelte +458 -316
- package/dist/components/charts/PieChart.svelte.d.ts +137 -353
- package/dist/components/charts/ScatterChart.svelte +334 -296
- package/dist/components/charts/ScatterChart.svelte.d.ts +39 -0
- package/dist/components/charts/index.d.ts +8 -0
- package/dist/components/charts/index.js +7 -0
- package/dist/components/charts/types.d.ts +253 -0
- package/dist/components/charts/utils.svelte.d.ts +30 -0
- package/dist/components/charts/utils.svelte.js +55 -0
- package/dist/components/index.d.ts +76 -4
- package/dist/components/index.js +76 -5
- package/dist/components/layout/Canvas.svelte +321 -155
- package/dist/components/layout/Canvas.svelte.d.ts +104 -55
- package/dist/components/layout/Html.svelte +82 -42
- package/dist/components/layout/Html.svelte.d.ts +39 -28
- package/dist/components/layout/Layer.svelte +39 -0
- package/dist/components/layout/Layer.svelte.d.ts +17 -0
- package/dist/components/layout/Svg.svelte +122 -70
- package/dist/components/layout/Svg.svelte.d.ts +53 -34
- package/dist/components/layout/WebGL.svelte +135 -0
- package/dist/components/layout/WebGL.svelte.d.ts +50 -0
- package/dist/components/tooltip/Tooltip.svelte +246 -78
- package/dist/components/tooltip/Tooltip.svelte.d.ts +149 -31
- package/dist/components/tooltip/TooltipContext.svelte +409 -271
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +86 -55
- package/dist/components/tooltip/TooltipHeader.svelte +100 -11
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +43 -23
- package/dist/components/tooltip/TooltipItem.svelte +167 -27
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +63 -31
- package/dist/components/tooltip/TooltipList.svelte +22 -3
- package/dist/components/tooltip/TooltipList.svelte.d.ts +6 -17
- package/dist/components/tooltip/TooltipSeparator.svelte +27 -1
- package/dist/components/tooltip/TooltipSeparator.svelte.d.ts +6 -15
- package/dist/components/tooltip/index.d.ts +6 -0
- package/dist/components/tooltip/index.js +6 -0
- package/dist/components/tooltip/tooltipMetaContext.d.ts +79 -0
- package/dist/components/tooltip/tooltipMetaContext.js +139 -0
- package/dist/components/types.d.ts +1 -0
- package/dist/components/types.js +1 -0
- package/dist/docs/Blockquote.svelte.d.ts +18 -14
- package/dist/docs/Code.svelte.d.ts +26 -22
- package/dist/docs/ConnectorSweepMenuField.svelte +17 -0
- package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +7 -0
- package/dist/docs/ConnectorTypeMenuField.svelte +17 -0
- package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +7 -0
- package/dist/docs/CurveMenuField.svelte +14 -3
- package/dist/docs/CurveMenuField.svelte.d.ts +9 -18
- package/dist/docs/GeoDebug.svelte +47 -42
- package/dist/docs/GeoDebug.svelte.d.ts +4 -16
- package/dist/docs/Header1.svelte.d.ts +27 -16
- package/dist/docs/Json.svelte.d.ts +20 -16
- package/dist/docs/Layout.svelte.d.ts +18 -13
- package/dist/docs/Link.svelte.d.ts +33 -21
- package/dist/docs/PathDataMenuField.svelte +14 -10
- package/dist/docs/PathDataMenuField.svelte.d.ts +8 -18
- package/dist/docs/Preview.svelte +20 -7
- package/dist/docs/Preview.svelte.d.ts +12 -22
- package/dist/docs/TilesetField.svelte.d.ts +21 -17
- package/dist/docs/TransformDebug.svelte +5 -6
- package/dist/docs/TransformDebug.svelte.d.ts +18 -14
- package/dist/docs/ViewSourceButton.svelte.d.ts +21 -17
- package/dist/types/d3-shape-extentions.d.ts +7 -0
- package/dist/utils/afterTick.d.ts +5 -0
- package/dist/utils/afterTick.js +8 -0
- package/dist/utils/arcText.svelte.d.ts +57 -0
- package/dist/utils/arcText.svelte.js +262 -0
- package/dist/utils/array.d.ts +9 -1
- package/dist/utils/array.js +13 -0
- package/dist/utils/attributes.d.ts +29 -0
- package/dist/utils/attributes.js +40 -0
- package/dist/utils/canvas.js +47 -10
- package/dist/utils/chart.d.ts +78 -0
- package/dist/utils/chart.js +512 -0
- package/dist/utils/color.d.ts +1 -0
- package/dist/utils/color.js +8 -0
- package/dist/utils/common.d.ts +3 -5
- package/dist/utils/common.js +3 -2
- package/dist/utils/connectorUtils.d.ts +21 -0
- package/dist/utils/connectorUtils.js +111 -0
- package/dist/utils/createId.d.ts +7 -0
- package/dist/utils/createId.js +9 -0
- package/dist/utils/debug.d.ts +1 -0
- package/dist/utils/debug.js +84 -0
- package/dist/utils/filterObject.d.ts +9 -0
- package/dist/utils/filterObject.js +12 -0
- package/dist/utils/graph/dagre.d.ts +34 -0
- package/dist/utils/graph/dagre.js +78 -0
- package/dist/utils/graph/dagre.test.d.ts +1 -0
- package/dist/utils/{graph.test.js → graph/dagre.test.js} +19 -33
- package/dist/utils/graph/sankey.d.ts +28 -0
- package/dist/utils/{graph.js → graph/sankey.js} +13 -41
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/key.svelte.d.ts +3 -0
- package/dist/utils/key.svelte.js +11 -0
- package/dist/utils/legendPayload.d.ts +7 -0
- package/dist/utils/legendPayload.js +8 -0
- package/dist/utils/motion.svelte.d.ts +140 -0
- package/dist/utils/motion.svelte.js +180 -0
- package/dist/utils/motion.test.d.ts +1 -0
- package/dist/utils/motion.test.js +213 -0
- package/dist/utils/{rect.d.ts → rect.svelte.d.ts} +7 -4
- package/dist/utils/rect.svelte.js +105 -0
- package/dist/utils/scales.svelte.d.ts +90 -0
- package/dist/utils/{scales.js → scales.svelte.js} +100 -39
- package/dist/utils/stack.d.ts +2 -3
- package/dist/utils/stack.js +1 -1
- package/dist/utils/string.js +87 -0
- package/dist/utils/ticks.d.ts +8 -2
- package/dist/utils/ticks.js +28 -0
- package/dist/utils/ticks.test.d.ts +1 -0
- package/dist/utils/ticks.test.js +67 -0
- package/dist/utils/types.d.ts +81 -0
- package/package.json +21 -19
- package/dist/components/ChartContext.svelte +0 -295
- package/dist/components/ChartContext.svelte.d.ts +0 -139
- package/dist/components/TransformContext.svelte.d.ts +0 -158
- package/dist/stores/motionStore.d.ts +0 -30
- package/dist/stores/motionStore.js +0 -62
- package/dist/utils/graph.d.ts +0 -37
- package/dist/utils/rect.js +0 -107
- package/dist/utils/scales.d.ts +0 -66
- /package/dist/{utils/graph.test.d.ts → components/charts/types.js} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { Transition, TransitionParams, Without } from '../utils/types.js';
|
|
2
|
+
export type AxisPropsWithoutHTML<In extends Transition = Transition> = {
|
|
3
|
+
/**
|
|
4
|
+
* Location of axis
|
|
5
|
+
*/
|
|
6
|
+
placement: 'top' | 'bottom' | 'left' | 'right' | 'angle' | 'radius';
|
|
7
|
+
/**
|
|
8
|
+
* The label for the axis.
|
|
9
|
+
*
|
|
10
|
+
* Can either be a string or a snippet to render custom content.
|
|
11
|
+
* The snippet receives spreadable props to apply to the label.
|
|
12
|
+
*/
|
|
13
|
+
label?: string | Snippet<[{
|
|
14
|
+
props: ComponentProps<typeof Text>;
|
|
15
|
+
}]>;
|
|
16
|
+
/**
|
|
17
|
+
* Location of axis label
|
|
18
|
+
* @default 'middle'
|
|
19
|
+
*/
|
|
20
|
+
labelPlacement?: 'start' | 'middle' | 'end';
|
|
21
|
+
/**
|
|
22
|
+
* Props applied to label Text
|
|
23
|
+
*/
|
|
24
|
+
labelProps?: Partial<ComponentProps<typeof Text>>;
|
|
25
|
+
/**
|
|
26
|
+
* Draw a rule line. Use Rule component for greater rendering order control
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
rule?: boolean | Partial<ComponentProps<typeof Rule>>;
|
|
30
|
+
/**
|
|
31
|
+
* Draw grid lines
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
grid?: boolean | Pick<SVGAttributes<SVGElement>, 'class' | 'style'>;
|
|
35
|
+
/**
|
|
36
|
+
* Control the number of ticks
|
|
37
|
+
*/
|
|
38
|
+
ticks?: TicksConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Length of the tick line
|
|
41
|
+
* @default 4
|
|
42
|
+
*/
|
|
43
|
+
tickLength?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to render tick marks.
|
|
46
|
+
*
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
tickMarks?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Format tick labels
|
|
52
|
+
*/
|
|
53
|
+
format?: FormatType;
|
|
54
|
+
/**
|
|
55
|
+
* Props to apply to each tick label
|
|
56
|
+
*/
|
|
57
|
+
tickLabelProps?: Partial<ComponentProps<typeof Text>>;
|
|
58
|
+
/**
|
|
59
|
+
* A snippet to render your own custom tick label.
|
|
60
|
+
*/
|
|
61
|
+
tickLabel?: Snippet<[{
|
|
62
|
+
props: ComponentProps<typeof Text>;
|
|
63
|
+
index: number;
|
|
64
|
+
}]>;
|
|
65
|
+
/**
|
|
66
|
+
* Transition function for entering elements
|
|
67
|
+
* @default defaults to fade if the motion prop is set to tweened
|
|
68
|
+
*/
|
|
69
|
+
transitionIn?: In;
|
|
70
|
+
/**
|
|
71
|
+
* Parameters for the transitionIn function
|
|
72
|
+
* @default { easing: cubicIn }
|
|
73
|
+
*/
|
|
74
|
+
transitionInParams?: TransitionParams<In>;
|
|
75
|
+
/**
|
|
76
|
+
* Scale for the axis
|
|
77
|
+
*/
|
|
78
|
+
scale?: any;
|
|
79
|
+
/**
|
|
80
|
+
* Classes for styling various parts of the axis
|
|
81
|
+
* @default {}
|
|
82
|
+
*/
|
|
83
|
+
classes?: {
|
|
84
|
+
root?: string;
|
|
85
|
+
label?: string;
|
|
86
|
+
rule?: string;
|
|
87
|
+
tick?: string;
|
|
88
|
+
tickLabel?: string;
|
|
89
|
+
};
|
|
90
|
+
motion?: MotionProp;
|
|
91
|
+
};
|
|
92
|
+
export type AxisProps<In extends Transition = Transition> = AxisPropsWithoutHTML<In> & Without<GroupProps, AxisPropsWithoutHTML<In>>;
|
|
93
|
+
import { type ComponentProps, type Snippet } from 'svelte';
|
|
94
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
95
|
+
import { type FormatType } from '@layerstack/utils';
|
|
96
|
+
import { type GroupProps } from './Group.svelte';
|
|
97
|
+
import Rule from './Rule.svelte';
|
|
98
|
+
import Text from './Text.svelte';
|
|
99
|
+
import { type MotionProp } from '../utils/motion.svelte.js';
|
|
100
|
+
import { type TicksConfig } from '../utils/ticks.js';
|
|
101
|
+
declare class __sveltets_Render<T extends Transition = Transition> {
|
|
102
|
+
props(): AxisProps<T>;
|
|
103
|
+
events(): {};
|
|
104
|
+
slots(): {};
|
|
105
|
+
bindings(): "";
|
|
106
|
+
exports(): {};
|
|
107
|
+
}
|
|
108
|
+
interface $$IsomorphicComponent {
|
|
109
|
+
new <T extends Transition = Transition>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
110
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
111
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
112
|
+
<T extends Transition = Transition>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
113
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
114
|
+
}
|
|
115
|
+
declare const Axis: $$IsomorphicComponent;
|
|
116
|
+
type Axis<T extends Transition = Transition> = InstanceType<typeof Axis<T>>;
|
|
117
|
+
export default Axis;
|
|
@@ -1,89 +1,140 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { createDimensionGetter, type Insets } from '../utils/rect.svelte.js';
|
|
3
|
+
|
|
4
|
+
export type BarPropsWithoutHTML = {
|
|
5
|
+
/**
|
|
6
|
+
* data to render the bar from
|
|
7
|
+
*/
|
|
8
|
+
data: Object;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Override `x` from context. Useful for multiple Bar instances
|
|
12
|
+
*
|
|
13
|
+
* @default ctx.x
|
|
14
|
+
*/
|
|
15
|
+
x?: Accessor;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Override `y` from context. Useful for multiple Bar instances
|
|
19
|
+
*
|
|
20
|
+
* @default ctx.y
|
|
21
|
+
*/
|
|
22
|
+
y?: Accessor;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Override `x1` from context. Useful for multiple Bar instances
|
|
26
|
+
*
|
|
27
|
+
* @default ctx.x1
|
|
28
|
+
*/
|
|
29
|
+
x1?: Accessor;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Override `y1` from context. Useful for multiple Bar instances
|
|
33
|
+
*
|
|
34
|
+
* @default ctx.y1
|
|
35
|
+
*/
|
|
36
|
+
y1?: Accessor;
|
|
37
|
+
|
|
38
|
+
radius?: number;
|
|
39
|
+
|
|
40
|
+
insets?: Insets;
|
|
41
|
+
|
|
42
|
+
initialX?: number;
|
|
43
|
+
|
|
44
|
+
initialY?: number;
|
|
45
|
+
|
|
46
|
+
initialHeight?: number;
|
|
47
|
+
|
|
48
|
+
initialWidth?: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Control which corners are rounded with radius. Uses <path> instead of <rect> when not set
|
|
52
|
+
* to `all`
|
|
53
|
+
*/
|
|
54
|
+
rounded?:
|
|
55
|
+
| 'all'
|
|
56
|
+
| 'none'
|
|
57
|
+
| 'edge'
|
|
58
|
+
| 'top'
|
|
59
|
+
| 'bottom'
|
|
60
|
+
| 'left'
|
|
61
|
+
| 'right'
|
|
62
|
+
| 'top-left'
|
|
63
|
+
| 'top-right'
|
|
64
|
+
| 'bottom-left'
|
|
65
|
+
| 'bottom-right';
|
|
66
|
+
|
|
67
|
+
motion?: MotionProp<'x' | 'y' | 'width' | 'height'>;
|
|
68
|
+
} & CommonStyleProps;
|
|
69
|
+
|
|
70
|
+
export type BarProps = BarPropsWithoutHTML &
|
|
71
|
+
Without<
|
|
72
|
+
Omit<SVGAttributes<SVGElement>, 'width' | 'height' | 'x' | 'y' | 'offset'>,
|
|
73
|
+
BarPropsWithoutHTML
|
|
74
|
+
>;
|
|
75
|
+
</script>
|
|
76
|
+
|
|
1
77
|
<script lang="ts">
|
|
2
|
-
import {
|
|
78
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
79
|
+
import { greatestAbs } from '@layerstack/utils';
|
|
3
80
|
|
|
4
|
-
import { chartContext } from './ChartContext.svelte';
|
|
5
81
|
import Rect from './Rect.svelte';
|
|
6
82
|
import Spline from './Spline.svelte';
|
|
7
83
|
|
|
8
|
-
import {
|
|
9
|
-
import { isScaleBand } from '../utils/scales.js';
|
|
84
|
+
import { isScaleBand } from '../utils/scales.svelte.js';
|
|
10
85
|
import { accessor, type Accessor } from '../utils/common.js';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* Override `y` from context. Useful for multiple Bar instances
|
|
24
|
-
*/
|
|
25
|
-
export let y: Accessor = $yContext;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Override `x1` from context. Useful for multiple Bar instances
|
|
29
|
-
*/
|
|
30
|
-
export let x1: Accessor = undefined;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Override `y1` from context. Useful for multiple Bar instances
|
|
34
|
-
*/
|
|
35
|
-
export let y1: Accessor = undefined;
|
|
36
|
-
|
|
37
|
-
export let fill: string | undefined = undefined;
|
|
38
|
-
export let fillOpacity: number | undefined = undefined;
|
|
39
|
-
export let stroke = 'black';
|
|
40
|
-
export let strokeWidth = 0;
|
|
41
|
-
export let opacity: number | undefined = undefined;
|
|
42
|
-
export let radius = 0;
|
|
43
|
-
|
|
44
|
-
/** Control which corners are rounded with radius. Uses <path> instead of <rect> when not set to `all` */
|
|
45
|
-
export let rounded:
|
|
46
|
-
| 'all'
|
|
47
|
-
| 'none'
|
|
48
|
-
| 'edge'
|
|
49
|
-
| 'top'
|
|
50
|
-
| 'bottom'
|
|
51
|
-
| 'left'
|
|
52
|
-
| 'right'
|
|
53
|
-
| 'top-left'
|
|
54
|
-
| 'top-right'
|
|
55
|
-
| 'bottom-left'
|
|
56
|
-
| 'bottom-right' = 'all';
|
|
57
|
-
|
|
58
|
-
export let insets: Insets | undefined = undefined;
|
|
59
|
-
|
|
60
|
-
export let onclick: ((e: MouseEvent) => void) | undefined = undefined;
|
|
61
|
-
export let onpointerenter: ((e: PointerEvent) => void) | undefined = undefined;
|
|
62
|
-
export let onpointermove: ((e: PointerEvent) => void) | undefined = undefined;
|
|
63
|
-
export let onpointerleave: ((e: PointerEvent) => void) | undefined = undefined;
|
|
64
|
-
|
|
65
|
-
export let spring: ComponentProps<Rect>['spring'] = undefined;
|
|
66
|
-
export let tweened: ComponentProps<Rect>['tweened'] = undefined;
|
|
67
|
-
|
|
68
|
-
$: if (stroke === null || stroke === undefined) stroke = 'black';
|
|
69
|
-
|
|
70
|
-
$: getDimensions = createDimensionGetter(chartContext(), {
|
|
71
|
-
x,
|
|
72
|
-
y,
|
|
86
|
+
import { getChartContext } from './Chart.svelte';
|
|
87
|
+
import type { CommonStyleProps, Without } from '../utils/types.js';
|
|
88
|
+
import { extractLayerProps } from '../utils/attributes.js';
|
|
89
|
+
import { extractTweenConfig, type MotionProp } from '../utils/motion.svelte.js';
|
|
90
|
+
import Arc from './Arc.svelte';
|
|
91
|
+
|
|
92
|
+
const ctx = getChartContext();
|
|
93
|
+
|
|
94
|
+
let {
|
|
95
|
+
data,
|
|
96
|
+
x = ctx.x,
|
|
97
|
+
y = ctx.y,
|
|
73
98
|
x1,
|
|
74
99
|
y1,
|
|
100
|
+
fill,
|
|
101
|
+
fillOpacity,
|
|
102
|
+
stroke: strokeProp = 'black',
|
|
103
|
+
strokeWidth = 0,
|
|
104
|
+
opacity,
|
|
105
|
+
radius = 0,
|
|
106
|
+
rounded: roundedProp = 'all',
|
|
107
|
+
motion,
|
|
75
108
|
insets,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
109
|
+
initialX,
|
|
110
|
+
initialY,
|
|
111
|
+
initialHeight,
|
|
112
|
+
initialWidth,
|
|
113
|
+
...restProps
|
|
114
|
+
}: BarProps = $props();
|
|
115
|
+
|
|
116
|
+
const stroke = $derived(strokeProp === null || strokeProp === undefined ? 'black' : strokeProp);
|
|
117
|
+
|
|
118
|
+
const getDimensions = $derived(
|
|
119
|
+
createDimensionGetter(ctx, () => ({
|
|
120
|
+
x,
|
|
121
|
+
y,
|
|
122
|
+
x1,
|
|
123
|
+
y1,
|
|
124
|
+
insets,
|
|
125
|
+
}))
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const dimensions = $derived(getDimensions(data) ?? { x: 0, y: 0, width: 0, height: 0 });
|
|
129
|
+
|
|
130
|
+
const isVertical = $derived(isScaleBand(ctx.xScale));
|
|
131
|
+
const valueAccessor = $derived(accessor(isVertical ? y : x));
|
|
132
|
+
const value = $derived(valueAccessor(data));
|
|
133
|
+
const resolvedValue = $derived(Array.isArray(value) ? greatestAbs(value) : value);
|
|
83
134
|
|
|
84
135
|
// Resolved `rounded="edge"` based on orientation and value
|
|
85
|
-
|
|
86
|
-
|
|
136
|
+
const rounded = $derived(
|
|
137
|
+
roundedProp === 'edge'
|
|
87
138
|
? isVertical
|
|
88
139
|
? resolvedValue >= 0
|
|
89
140
|
? 'top'
|
|
@@ -91,18 +142,18 @@
|
|
|
91
142
|
: resolvedValue >= 0
|
|
92
143
|
? 'right'
|
|
93
144
|
: 'left'
|
|
94
|
-
:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
145
|
+
: roundedProp
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const topLeft = $derived(['all', 'top', 'left', 'top-left'].includes(rounded));
|
|
149
|
+
const topRight = $derived(['all', 'top', 'right', 'top-right'].includes(rounded));
|
|
150
|
+
const bottomLeft = $derived(['all', 'bottom', 'left', 'bottom-left'].includes(rounded));
|
|
151
|
+
const bottomRight = $derived(['all', 'bottom', 'right', 'bottom-right'].includes(rounded));
|
|
152
|
+
const width = $derived(dimensions.width);
|
|
153
|
+
const height = $derived(dimensions.height);
|
|
154
|
+
const diameter = $derived(2 * radius);
|
|
155
|
+
const pathData = $derived(
|
|
156
|
+
`M${dimensions.x + radius},${dimensions.y} h${width - diameter}
|
|
106
157
|
${topRight ? `a${radius},${radius} 0 0 1 ${radius},${radius}` : `h${radius}v${radius}`}
|
|
107
158
|
v${height - diameter}
|
|
108
159
|
${bottomRight ? `a${radius},${radius} 0 0 1 ${-radius},${radius}` : `v${radius}h${-radius}`}
|
|
@@ -111,29 +162,43 @@
|
|
|
111
162
|
v${diameter - height}
|
|
112
163
|
${topLeft ? `a${radius},${radius} 0 0 1 ${radius},${-radius}` : `v${-radius}h${radius}`}
|
|
113
164
|
z`
|
|
114
|
-
|
|
115
|
-
|
|
165
|
+
.split('\n')
|
|
166
|
+
.join('')
|
|
167
|
+
);
|
|
116
168
|
</script>
|
|
117
169
|
|
|
118
|
-
{#if
|
|
170
|
+
{#if ctx.radial}
|
|
171
|
+
<Arc
|
|
172
|
+
innerRadius={dimensions.y}
|
|
173
|
+
outerRadius={dimensions.y + dimensions.height}
|
|
174
|
+
startAngle={dimensions.x}
|
|
175
|
+
endAngle={dimensions.x + dimensions.width}
|
|
176
|
+
{fill}
|
|
177
|
+
{fillOpacity}
|
|
178
|
+
{stroke}
|
|
179
|
+
{strokeWidth}
|
|
180
|
+
{opacity}
|
|
181
|
+
cornerRadius={radius}
|
|
182
|
+
{...extractLayerProps(restProps, 'bar')}
|
|
183
|
+
/>
|
|
184
|
+
{:else if rounded === 'all' || rounded === 'none' || radius === 0}
|
|
119
185
|
<Rect
|
|
120
186
|
{fill}
|
|
121
187
|
{fillOpacity}
|
|
122
188
|
{stroke}
|
|
123
189
|
{strokeWidth}
|
|
124
190
|
{opacity}
|
|
125
|
-
rx={
|
|
126
|
-
{
|
|
127
|
-
{
|
|
128
|
-
{
|
|
129
|
-
{
|
|
130
|
-
{
|
|
131
|
-
{onpointerleave}
|
|
132
|
-
on:touchmove
|
|
191
|
+
rx={rounded === 'none' ? 0 : radius}
|
|
192
|
+
{motion}
|
|
193
|
+
{initialX}
|
|
194
|
+
{initialY}
|
|
195
|
+
{initialHeight}
|
|
196
|
+
{initialWidth}
|
|
133
197
|
{...dimensions}
|
|
134
|
-
{
|
|
198
|
+
{...extractLayerProps(restProps, 'bar')}
|
|
135
199
|
/>
|
|
136
200
|
{:else}
|
|
201
|
+
{@const tweenMotion = extractTweenConfig(motion)}
|
|
137
202
|
<Spline
|
|
138
203
|
{pathData}
|
|
139
204
|
{fill}
|
|
@@ -141,13 +206,7 @@
|
|
|
141
206
|
{stroke}
|
|
142
207
|
{strokeWidth}
|
|
143
208
|
{opacity}
|
|
144
|
-
{
|
|
145
|
-
{
|
|
146
|
-
{onclick}
|
|
147
|
-
{onpointerenter}
|
|
148
|
-
{onpointermove}
|
|
149
|
-
{onpointerleave}
|
|
150
|
-
on:touchmove
|
|
151
|
-
{...$$restProps}
|
|
209
|
+
motion={tweenMotion}
|
|
210
|
+
{...extractLayerProps(restProps, 'bar')}
|
|
152
211
|
/>
|
|
153
212
|
{/if}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Insets } from '../utils/rect.svelte.js';
|
|
2
|
+
export type BarPropsWithoutHTML = {
|
|
3
|
+
/**
|
|
4
|
+
* data to render the bar from
|
|
5
|
+
*/
|
|
6
|
+
data: Object;
|
|
7
|
+
/**
|
|
8
|
+
* Override `x` from context. Useful for multiple Bar instances
|
|
9
|
+
*
|
|
10
|
+
* @default ctx.x
|
|
11
|
+
*/
|
|
12
|
+
x?: Accessor;
|
|
13
|
+
/**
|
|
14
|
+
* Override `y` from context. Useful for multiple Bar instances
|
|
15
|
+
*
|
|
16
|
+
* @default ctx.y
|
|
17
|
+
*/
|
|
18
|
+
y?: Accessor;
|
|
19
|
+
/**
|
|
20
|
+
* Override `x1` from context. Useful for multiple Bar instances
|
|
21
|
+
*
|
|
22
|
+
* @default ctx.x1
|
|
23
|
+
*/
|
|
24
|
+
x1?: Accessor;
|
|
25
|
+
/**
|
|
26
|
+
* Override `y1` from context. Useful for multiple Bar instances
|
|
27
|
+
*
|
|
28
|
+
* @default ctx.y1
|
|
29
|
+
*/
|
|
30
|
+
y1?: Accessor;
|
|
31
|
+
radius?: number;
|
|
32
|
+
insets?: Insets;
|
|
33
|
+
initialX?: number;
|
|
34
|
+
initialY?: number;
|
|
35
|
+
initialHeight?: number;
|
|
36
|
+
initialWidth?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Control which corners are rounded with radius. Uses <path> instead of <rect> when not set
|
|
39
|
+
* to `all`
|
|
40
|
+
*/
|
|
41
|
+
rounded?: 'all' | 'none' | 'edge' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
42
|
+
motion?: MotionProp<'x' | 'y' | 'width' | 'height'>;
|
|
43
|
+
} & CommonStyleProps;
|
|
44
|
+
export type BarProps = BarPropsWithoutHTML & Without<Omit<SVGAttributes<SVGElement>, 'width' | 'height' | 'x' | 'y' | 'offset'>, BarPropsWithoutHTML>;
|
|
45
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
46
|
+
import { type Accessor } from '../utils/common.js';
|
|
47
|
+
import type { CommonStyleProps, Without } from '../utils/types.js';
|
|
48
|
+
import { type MotionProp } from '../utils/motion.svelte.js';
|
|
49
|
+
declare const Bar: import("svelte").Component<BarProps, {}, "">;
|
|
50
|
+
type Bar = ReturnType<typeof Bar>;
|
|
51
|
+
export default Bar;
|
|
@@ -1,82 +1,71 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { chartDataArray, type Accessor } from '../utils/common.js';
|
|
8
|
-
import type { Insets } from '../utils/rect.js';
|
|
9
|
-
|
|
10
|
-
const { data: contextData, cGet, config } = chartContext();
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type BarsPropsWithoutHTML = {
|
|
3
|
+
/**
|
|
4
|
+
* Override the data from the context.
|
|
5
|
+
*/
|
|
6
|
+
data?: any;
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Define unique value for {#each} `(key)` expressions
|
|
10
|
+
* to improve transitions.
|
|
11
|
+
*
|
|
12
|
+
* @default (d, index) => index
|
|
13
|
+
*/
|
|
14
|
+
key?: (d: any, index: number) => any;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Event dispatched when an individual bar is clicked.
|
|
18
|
+
*/
|
|
19
|
+
onBarClick?: (e: MouseEvent, detail: { data: any }) => void;
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
// TODO: investigate
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
} & Omit<BarPropsWithoutHTML, 'data' | 'children'>;
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
export let x1: Accessor = undefined;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Override `y1` from context. Useful for multiple Bar instances
|
|
34
|
-
*/
|
|
35
|
-
export let y1: Accessor = undefined;
|
|
36
|
-
|
|
37
|
-
export let stroke = 'black';
|
|
38
|
-
export let strokeWidth = 0;
|
|
39
|
-
export let radius = 0;
|
|
40
|
-
export let fill: string | undefined = undefined;
|
|
41
|
-
export let fillOpacity: number | undefined = undefined;
|
|
42
|
-
export let opacity: number | undefined = undefined;
|
|
26
|
+
export type BarsProps = BarsPropsWithoutHTML & Omit<BarProps, 'data'>;
|
|
27
|
+
</script>
|
|
43
28
|
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
import type { Snippet } from 'svelte';
|
|
46
31
|
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
import Bar, { type BarProps, type BarPropsWithoutHTML } from './Bar.svelte';
|
|
33
|
+
import Group from './Group.svelte';
|
|
49
34
|
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
import { chartDataArray } from '../utils/common.js';
|
|
36
|
+
import { getChartContext } from './Chart.svelte';
|
|
37
|
+
import { extractLayerProps, layerClass } from '../utils/attributes.js';
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
let {
|
|
40
|
+
fill,
|
|
41
|
+
key = (_, i) => i,
|
|
42
|
+
data: dataProp,
|
|
43
|
+
onBarClick = () => {},
|
|
44
|
+
children,
|
|
45
|
+
radius = 0,
|
|
46
|
+
strokeWidth = 0,
|
|
47
|
+
stroke = 'black',
|
|
48
|
+
...restProps
|
|
49
|
+
}: BarsProps = $props();
|
|
55
50
|
|
|
56
|
-
|
|
51
|
+
const ctx = getChartContext();
|
|
52
|
+
const data = $derived(chartDataArray(dataProp ?? ctx.data));
|
|
57
53
|
</script>
|
|
58
54
|
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
{
|
|
55
|
+
<Group class={layerClass('bars')}>
|
|
56
|
+
{#if children}
|
|
57
|
+
{@render children()}
|
|
58
|
+
{:else}
|
|
59
|
+
{#each data as d, i (key(d, i))}
|
|
62
60
|
<Bar
|
|
63
|
-
|
|
64
|
-
{x}
|
|
65
|
-
{y}
|
|
66
|
-
{x1}
|
|
67
|
-
{y1}
|
|
68
|
-
fill={fill ?? ($config.c ? $cGet(d) : null)}
|
|
69
|
-
{fillOpacity}
|
|
70
|
-
{stroke}
|
|
71
|
-
{strokeWidth}
|
|
72
|
-
{opacity}
|
|
61
|
+
data={d}
|
|
73
62
|
{radius}
|
|
74
|
-
{
|
|
75
|
-
{
|
|
76
|
-
{
|
|
77
|
-
onclick={(e) =>
|
|
78
|
-
{
|
|
63
|
+
{strokeWidth}
|
|
64
|
+
{stroke}
|
|
65
|
+
fill={fill ?? (ctx.config.c ? ctx.cGet(d) : null)}
|
|
66
|
+
onclick={(e) => onBarClick(e, { data: d })}
|
|
67
|
+
{...extractLayerProps(restProps, 'bars-bar')}
|
|
79
68
|
/>
|
|
80
69
|
{/each}
|
|
81
|
-
|
|
82
|
-
</
|
|
70
|
+
{/if}
|
|
71
|
+
</Group>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type BarsPropsWithoutHTML = {
|
|
2
|
+
/**
|
|
3
|
+
* Override the data from the context.
|
|
4
|
+
*/
|
|
5
|
+
data?: any;
|
|
6
|
+
/**
|
|
7
|
+
* Define unique value for {#each} `(key)` expressions
|
|
8
|
+
* to improve transitions.
|
|
9
|
+
*
|
|
10
|
+
* @default (d, index) => index
|
|
11
|
+
*/
|
|
12
|
+
key?: (d: any, index: number) => any;
|
|
13
|
+
/**
|
|
14
|
+
* Event dispatched when an individual bar is clicked.
|
|
15
|
+
*/
|
|
16
|
+
onBarClick?: (e: MouseEvent, detail: {
|
|
17
|
+
data: any;
|
|
18
|
+
}) => void;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
} & Omit<BarPropsWithoutHTML, 'data' | 'children'>;
|
|
22
|
+
export type BarsProps = BarsPropsWithoutHTML & Omit<BarProps, 'data'>;
|
|
23
|
+
import type { Snippet } from 'svelte';
|
|
24
|
+
import { type BarProps, type BarPropsWithoutHTML } from './Bar.svelte';
|
|
25
|
+
declare const Bars: import("svelte").Component<BarsProps, {}, "">;
|
|
26
|
+
type Bars = ReturnType<typeof Bars>;
|
|
27
|
+
export default Bars;
|