reburn-ui 0.2.0 → 0.3.0
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/core/MantineProvider/color-functions/get-contrast-color.svelte.js +1 -1
- package/dist/core/MantineProvider/color-functions/index.d.ts +1 -1
- package/dist/core/MantineProvider/color-functions/index.js +1 -1
- package/dist/core/MantineProvider/color-functions/parse-theme-color.svelte.js +1 -1
- package/dist/core/MantineProvider/theme.types.d.ts +5 -6
- package/dist/core/charts/ChartRoot/ChartContext.svelte.d.ts +64 -0
- package/dist/core/charts/ChartRoot/ChartContext.svelte.js +56 -0
- package/dist/core/charts/ChartRoot/ChartRoot.svelte +238 -0
- package/dist/core/charts/ChartRoot/ChartRoot.svelte.d.ts +87 -0
- package/dist/core/charts/ChartRoot/ChartXGrid.svelte +32 -0
- package/dist/core/charts/ChartRoot/ChartXGrid.svelte.d.ts +18 -0
- package/dist/core/charts/ChartRoot/ChartXLabels.svelte +26 -0
- package/dist/core/charts/ChartRoot/ChartXLabels.svelte.d.ts +18 -0
- package/dist/core/charts/ChartRoot/ChartYGrid.svelte +32 -0
- package/dist/core/charts/ChartRoot/ChartYGrid.svelte.d.ts +18 -0
- package/dist/core/charts/ChartRoot/ChartYLabels.svelte +31 -0
- package/dist/core/charts/ChartRoot/ChartYLabels.svelte.d.ts +18 -0
- package/dist/core/charts/ChartRoot/tickLabels.d.ts +8 -0
- package/dist/core/charts/ChartRoot/tickLabels.js +21 -0
- package/dist/core/charts/ChartTooltip/ChartTooltip.svelte +260 -0
- package/dist/core/charts/ChartTooltip/ChartTooltip.svelte.d.ts +34 -0
- package/dist/core/charts/ChartTooltip/ChartTooltipData.svelte +47 -0
- package/dist/core/charts/ChartTooltip/ChartTooltipData.svelte.d.ts +29 -0
- package/dist/core/charts/ChartTooltip/utils/findClosestElement.d.ts +2 -0
- package/dist/core/charts/ChartTooltip/utils/findClosestElement.js +21 -0
- package/dist/core/charts/ChartTooltip/utils/getTooltipPosition.d.ts +9 -0
- package/dist/core/charts/ChartTooltip/utils/getTooltipPosition.js +6 -0
- package/dist/core/charts/CompositeChart/CompositeChart.svelte +82 -0
- package/dist/core/charts/CompositeChart/CompositeChart.svelte.d.ts +60 -0
- package/dist/core/charts/LineChart/LineChart.svelte +30 -321
- package/dist/core/charts/LineChart/LineChart.svelte.d.ts +16 -64
- package/dist/core/charts/LineChart/LineChartInner.svelte +66 -0
- package/dist/core/charts/LineChart/LineChartInner.svelte.d.ts +34 -0
- package/dist/core/charts/ScatterChart/ScatterChart.svelte +33 -0
- package/dist/core/charts/ScatterChart/ScatterChart.svelte.d.ts +39 -0
- package/dist/core/charts/ScatterChart/ScatterChartInner.svelte +67 -0
- package/dist/core/charts/ScatterChart/ScatterChartInner.svelte.d.ts +32 -0
- package/dist/core/charts/d3/array/tick.d.ts +1 -0
- package/dist/core/charts/d3/array/tick.js +66 -0
- package/dist/core/charts/d3/scale/scaleLinear.d.ts +4 -0
- package/dist/core/charts/d3/scale/scaleLinear.js +14 -0
- package/dist/core/charts/d3/shape/curve/curveLinear.d.ts +2 -0
- package/dist/core/charts/d3/shape/curve/curveLinear.js +16 -0
- package/dist/core/charts/d3/shape/line.d.ts +7 -0
- package/dist/core/charts/d3/shape/line.js +6 -0
- package/dist/core/charts/d3/shape/toFixed.d.ts +1 -0
- package/dist/core/charts/d3/shape/toFixed.js +7 -0
- package/dist/core/charts/d3/shape/withPath.d.ts +1 -0
- package/dist/core/charts/d3/shape/withPath.js +18 -0
- package/dist/core/charts/index.d.ts +5 -0
- package/dist/core/charts/index.js +5 -0
- package/dist/core/charts/types.d.ts +10 -0
- package/dist/core/charts/utils/minMaxObject.d.ts +6 -0
- package/dist/core/charts/utils/minMaxObject.js +26 -0
- package/dist/core/components/Badge/Badge.svelte +1 -1
- package/dist/core/components/Burger/Burger.svelte +1 -1
- package/dist/core/components/Checkbox/Checkbox.svelte +1 -1
- package/dist/core/components/Checkbox/CheckboxCard/CheckboxCard.svelte +8 -6
- package/dist/core/components/Checkbox/CheckboxIndicator.svelte +4 -1
- package/dist/core/components/ColorPicker/ColorSlider.svelte +10 -14
- package/dist/core/components/ColorPicker/Saturation.svelte +8 -4
- package/dist/core/components/ColorPicker/converters/index.d.ts +2 -2
- package/dist/core/components/ColorPicker/converters/index.js +2 -2
- package/dist/core/components/Combobox/ComboboxChevron.svelte +4 -3
- package/dist/core/components/Combobox/ComboboxDropdown.svelte +0 -3
- package/dist/core/components/Dropzone/Dropzone.svelte +396 -0
- package/dist/core/components/Dropzone/Dropzone.svelte.d.ts +104 -0
- package/dist/core/components/Dropzone/DropzoneContext.svelte.js +3 -0
- package/dist/core/components/Dropzone/index.d.ts +3 -0
- package/dist/core/components/Dropzone/index.js +2 -0
- package/dist/core/components/Dropzone/mime-types.d.ts +30 -0
- package/dist/core/components/Dropzone/mime-types.js +41 -0
- package/dist/core/components/Dropzone/utils/acceptPropAsAccaptAttr.d.ts +5 -0
- package/dist/core/components/Dropzone/utils/acceptPropAsAccaptAttr.js +21 -0
- package/dist/core/components/Dropzone/utils/fromEvent.d.ts +6 -0
- package/dist/core/components/Dropzone/utils/fromEvent.js +45 -0
- package/dist/core/components/Dropzone/utils/getAllFilesAccepted.d.ts +35 -0
- package/dist/core/components/Dropzone/utils/getAllFilesAccepted.js +69 -0
- package/dist/core/components/Dropzone/utils/isEvtWithFiles.d.ts +1 -0
- package/dist/core/components/Dropzone/utils/isEvtWithFiles.js +8 -0
- package/dist/core/components/Dropzone/utils/isExt.d.ts +4 -0
- package/dist/core/components/Dropzone/utils/isExt.js +6 -0
- package/dist/core/components/Dropzone/utils/isMIMEType.d.ts +6 -0
- package/dist/core/components/Dropzone/utils/isMIMEType.js +8 -0
- package/dist/core/components/Dropzone/utils/isPropagationStopped.d.ts +1 -0
- package/dist/core/components/Dropzone/utils/isPropagationStopped.js +12 -0
- package/dist/core/components/Fieldset/Fieldset.svelte +76 -0
- package/dist/core/components/Fieldset/Fieldset.svelte.d.ts +15 -0
- package/dist/core/components/Floating/CreateFloating.svelte.js +0 -5
- package/dist/core/components/Group/Group.svelte +4 -9
- package/dist/core/components/Input/Input.svelte.d.ts +2 -2
- package/dist/core/components/InputBase/InputBase.svelte.d.ts +2 -2
- package/dist/core/components/Loader/Loader.svelte +1 -1
- package/dist/core/components/LoadingOverlay/LoadingOverlay.svelte +72 -0
- package/dist/core/components/LoadingOverlay/LoadingOverlay.svelte.d.ts +19 -0
- package/dist/core/components/Modal/ModalContent.svelte +4 -2
- package/dist/core/components/NavLink/NavLink.svelte +4 -3
- package/dist/core/components/Notification/Notification.svelte +5 -4
- package/dist/core/components/Pill/Pill.svelte +172 -0
- package/dist/core/components/Pill/Pill.svelte.d.ts +23 -0
- package/dist/core/components/Pill/PillGroup.svelte +47 -0
- package/dist/core/components/Pill/PillGroup.svelte.d.ts +13 -0
- package/dist/core/components/Pill/PillGroupContext.svelte.d.ts +15 -0
- package/dist/core/components/Pill/PillGroupContext.svelte.js +13 -0
- package/dist/core/components/Pill/index.d.ts +8 -0
- package/dist/core/components/Pill/index.js +5 -0
- package/dist/core/components/Progress/ProgressSection.svelte +3 -1
- package/dist/core/components/SegmentedControl/SegmentedControl.svelte +18 -7
- package/dist/core/components/Select/Select.svelte.d.ts +1 -1
- package/dist/core/components/Slider/SliderRoot.svelte +5 -1
- package/dist/core/components/Slider/Thumb.svelte +5 -1
- package/dist/core/components/Slider/Track.svelte +16 -6
- package/dist/core/components/Switch/Switch.svelte +1 -1
- package/dist/core/components/Table/Table.svelte +158 -0
- package/dist/core/components/Table/Table.svelte.d.ts +51 -0
- package/dist/core/components/Table/TableBodyContext.d.ts +2 -0
- package/dist/core/components/Table/TableBodyContext.js +5 -0
- package/dist/core/components/Table/TableCaption.svelte +30 -0
- package/dist/core/components/Table/TableCaption.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableContext.svelte.d.ts +25 -0
- package/dist/core/components/Table/TableContext.svelte.js +19 -0
- package/dist/core/components/Table/TableDataRenderer.svelte +55 -0
- package/dist/core/components/Table/TableDataRenderer.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableHeaderContext.d.ts +2 -0
- package/dist/core/components/Table/TableHeaderContext.js +5 -0
- package/dist/core/components/Table/TableTbody.svelte +20 -0
- package/dist/core/components/Table/TableTbody.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableTd.svelte +27 -0
- package/dist/core/components/Table/TableTd.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableTfoot.svelte +15 -0
- package/dist/core/components/Table/TableTfoot.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableTh.svelte +45 -0
- package/dist/core/components/Table/TableTh.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableThead.svelte +32 -0
- package/dist/core/components/Table/TableThead.svelte.d.ts +7 -0
- package/dist/core/components/Table/TableTr.svelte +62 -0
- package/dist/core/components/Table/TableTr.svelte.d.ts +7 -0
- package/dist/core/components/Table/getTableDataAttr.d.ts +12 -0
- package/dist/core/components/Table/getTableDataAttr.js +28 -0
- package/dist/core/components/Table/index.d.ts +20 -0
- package/dist/core/components/Table/index.js +17 -0
- package/dist/core/components/index.d.ts +5 -0
- package/dist/core/components/index.js +5 -0
- package/dist/core/hooks/use-id.d.ts +1 -0
- package/dist/core/hooks/use-id.js +4 -0
- package/dist/core/utils/get-default-z-index.d.ts +1 -1
- package/package.json +11 -9
- package/dist/core/charts/LineChart/LineChart.types.js +0 -1
- package/dist/core/charts/LineChart/types.d.ts +0 -68
- /package/dist/core/MantineProvider/color-functions/{get-primary-shade.d.ts → get-primary-shade.svelte.d.ts} +0 -0
- /package/dist/core/MantineProvider/color-functions/{get-primary-shade.js → get-primary-shade.svelte.js} +0 -0
- /package/dist/core/charts/{LineChart/types.js → types.js} +0 -0
- /package/dist/core/{charts/LineChart/LineChart.types.d.ts → components/Dropzone/DropzoneContext.svelte.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { theme } from '../theme.svelte.js';
|
|
2
|
-
import { getPrimaryShade } from './get-primary-shade.js';
|
|
2
|
+
import { getPrimaryShade } from './get-primary-shade.svelte.js';
|
|
3
3
|
import { parseThemeColor } from './parse-theme-color.svelte.js';
|
|
4
4
|
export function getContrastColor({ color, autoContrast }) {
|
|
5
5
|
const _autoContrast = typeof autoContrast === 'boolean' ? autoContrast : theme.autoContrast;
|
|
@@ -4,7 +4,7 @@ export { defaultVariantColorsResolver } from './default-variant-colors-resolver.
|
|
|
4
4
|
export { getAutoContrastValue } from './get-auto-contrast-value.svelte.js';
|
|
5
5
|
export { getContrastColor, getPrimaryContrastColor } from './get-contrast-color.svelte.js';
|
|
6
6
|
export { getGradient } from './get-gradient.svelte.js';
|
|
7
|
-
export { getPrimaryShade } from './get-primary-shade.js';
|
|
7
|
+
export { getPrimaryShade } from './get-primary-shade.svelte.js';
|
|
8
8
|
export { getThemeColor } from './get-theme-color.js';
|
|
9
9
|
export { lighten } from './lighten.js';
|
|
10
10
|
export { isLightColor, luminance } from './luminance.js';
|
|
@@ -4,7 +4,7 @@ export { defaultVariantColorsResolver } from './default-variant-colors-resolver.
|
|
|
4
4
|
export { getAutoContrastValue } from './get-auto-contrast-value.svelte.js';
|
|
5
5
|
export { getContrastColor, getPrimaryContrastColor } from './get-contrast-color.svelte.js';
|
|
6
6
|
export { getGradient } from './get-gradient.svelte.js';
|
|
7
|
-
export { getPrimaryShade } from './get-primary-shade.js';
|
|
7
|
+
export { getPrimaryShade } from './get-primary-shade.svelte.js';
|
|
8
8
|
export { getThemeColor } from './get-theme-color.js';
|
|
9
9
|
export { lighten } from './lighten.js';
|
|
10
10
|
export { isLightColor, luminance } from './luminance.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { theme } from '../theme.svelte.js';
|
|
2
|
-
import { getPrimaryShade } from './get-primary-shade.js';
|
|
2
|
+
import { getPrimaryShade } from './get-primary-shade.svelte.js';
|
|
3
3
|
import { isLightColor } from './luminance.js';
|
|
4
4
|
export function parseThemeColor({ color, colorScheme }) {
|
|
5
5
|
if (typeof color !== 'string') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Properties } from 'csstype';
|
|
2
2
|
import type { PartialDeep } from 'type-fest';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DivElement } from '../element-types.js';
|
|
4
|
+
import type { VariantColorsResolver } from './color-functions/default-variant-colors-resolver.svelte.js';
|
|
4
5
|
export interface MantineTheme {
|
|
5
6
|
/** Controls focus ring styles. Supports the following options:
|
|
6
7
|
* - `auto` – focus ring is displayed only when the user navigates with keyboard (default value)
|
|
@@ -108,10 +109,8 @@ export type MantineColorScheme = 'light' | 'dark' | 'auto';
|
|
|
108
109
|
export type MantineThemeOverride = PartialDeep<MantineTheme>;
|
|
109
110
|
export type MantineStylesRecord = Record<string, Properties>;
|
|
110
111
|
export interface MantineThemeComponent {
|
|
111
|
-
|
|
112
|
-
styles?:
|
|
113
|
-
vars?: any;
|
|
114
|
-
defaultProps?: any;
|
|
112
|
+
class?: DivElement['class'];
|
|
113
|
+
styles?: DivElement['style'];
|
|
115
114
|
}
|
|
116
115
|
export type MantineThemeComponents = Record<string, MantineThemeComponent>;
|
|
117
116
|
export interface HeadingStyle {
|
|
@@ -150,7 +149,7 @@ export type MantineLineHeight = (MantineThemeSizesOverride extends {
|
|
|
150
149
|
} ? CustomLineHeight : MantineSize) | (string & {});
|
|
151
150
|
export type MantineLineHeightValues = Record<MantineLineHeight, string>;
|
|
152
151
|
export interface MantineThemeOther {
|
|
153
|
-
[key: string]:
|
|
152
|
+
[key: string]: unknown;
|
|
154
153
|
}
|
|
155
154
|
export interface MantineGradient {
|
|
156
155
|
from: string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type Getter } from '../../context/extract.js';
|
|
2
|
+
import type { ChartData } from '../types.js';
|
|
3
|
+
import type { ChartRootProps } from './ChartRoot.svelte';
|
|
4
|
+
interface ChartContextProps<T extends ChartData> {
|
|
5
|
+
series: Getter<ChartRootProps<T>['series']>;
|
|
6
|
+
data: Getter<ChartRootProps<T>['data']>;
|
|
7
|
+
dataKey: Getter<ChartRootProps<T>['dataKey']>;
|
|
8
|
+
yAxisProps: Getter<ChartRootProps<T>['yAxisProps']>;
|
|
9
|
+
xAxisProps: Getter<ChartRootProps<T>['xAxisProps']>;
|
|
10
|
+
xScale: Getter<ChartRootProps<T>['xScale']>;
|
|
11
|
+
yScale: Getter<ChartRootProps<T>['yScale']>;
|
|
12
|
+
xGrid: Getter<ChartRootProps<T>['xGrid']>;
|
|
13
|
+
yGrid: Getter<ChartRootProps<T>['yGrid']>;
|
|
14
|
+
}
|
|
15
|
+
export declare class ChartContext<T extends ChartData> {
|
|
16
|
+
#private;
|
|
17
|
+
dataKey: keyof T;
|
|
18
|
+
data: T[];
|
|
19
|
+
series: import("../types.js").ChartSeries<T, keyof T>[];
|
|
20
|
+
xGrid: boolean | "bottom" | "top" | "top-bottom";
|
|
21
|
+
yGrid: boolean | "bottom" | "top" | "top-bottom";
|
|
22
|
+
chartWidth: number;
|
|
23
|
+
chartHeight: number;
|
|
24
|
+
yFormatLabel: (value: number) => string;
|
|
25
|
+
xFormatLabel: (value: number) => string;
|
|
26
|
+
xAccessor: ((value: T) => number) | ((value: T) => T[keyof T]);
|
|
27
|
+
seriesKeys: (keyof T)[];
|
|
28
|
+
yAccessor: {
|
|
29
|
+
name: keyof T;
|
|
30
|
+
accessor: (value: T) => number | T[keyof T];
|
|
31
|
+
}[];
|
|
32
|
+
xDomain: [number, number];
|
|
33
|
+
yDomain: [number, number];
|
|
34
|
+
xRange: [number, number];
|
|
35
|
+
xScale: {
|
|
36
|
+
(value: number): number;
|
|
37
|
+
invert(value: number): number;
|
|
38
|
+
};
|
|
39
|
+
yRange: [number, number];
|
|
40
|
+
yScale: {
|
|
41
|
+
(value: number): number;
|
|
42
|
+
invert(value: number): number;
|
|
43
|
+
};
|
|
44
|
+
rootRef: HTMLDivElement | undefined;
|
|
45
|
+
chartRef: SVGSVGElement | undefined;
|
|
46
|
+
constructor(props: ChartContextProps<T>);
|
|
47
|
+
get xTicks(): {
|
|
48
|
+
labels: {
|
|
49
|
+
label: ReturnType<(value: number) => string>;
|
|
50
|
+
position: number;
|
|
51
|
+
}[];
|
|
52
|
+
maxLength: number;
|
|
53
|
+
};
|
|
54
|
+
get yTicks(): {
|
|
55
|
+
labels: {
|
|
56
|
+
label: ReturnType<(value: number) => string>;
|
|
57
|
+
position: number;
|
|
58
|
+
}[];
|
|
59
|
+
maxLength: number;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export declare const CHART_CONTEXT_KEY: unique symbol;
|
|
63
|
+
export declare function getChartContext<T extends ChartData>(): ChartContext<T>;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { extract } from '../../context/extract.js';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import { scaleLinear } from '../d3/scale/scaleLinear.js';
|
|
4
|
+
import { minMax } from '../utils/minMax.js';
|
|
5
|
+
import { minMaxObject } from '../utils/minMaxObject.js';
|
|
6
|
+
import { tickLabels } from './tickLabels.js';
|
|
7
|
+
const DEFAULT_Y_TICKS = 10;
|
|
8
|
+
const DEFAULT_X_TICKS = 10;
|
|
9
|
+
const DEFAULT_X_FORMAT = (value) => value.toString();
|
|
10
|
+
const DEFAULT_Y_FORMAT = (value) => value.toString();
|
|
11
|
+
export class ChartContext {
|
|
12
|
+
#props;
|
|
13
|
+
dataKey = $derived(extract(this.#props.dataKey));
|
|
14
|
+
data = $derived(extract(this.#props.data));
|
|
15
|
+
series = $derived(extract(this.#props.series));
|
|
16
|
+
#yAxisProps = $derived(extract(this.#props.yAxisProps));
|
|
17
|
+
#xAxisProps = $derived(extract(this.#props.xAxisProps));
|
|
18
|
+
#_xScale = $derived(extract(this.#props.xScale, scaleLinear));
|
|
19
|
+
#_yScale = $derived(extract(this.#props.yScale, scaleLinear));
|
|
20
|
+
xGrid = $derived(extract(this.#props.xGrid, true));
|
|
21
|
+
yGrid = $derived(extract(this.#props.yGrid, true));
|
|
22
|
+
chartWidth = $state(0);
|
|
23
|
+
chartHeight = $state(0);
|
|
24
|
+
yFormatLabel = $derived(this.#yAxisProps?.formatLabel || DEFAULT_Y_FORMAT);
|
|
25
|
+
xFormatLabel = $derived(this.#xAxisProps?.formatLabel || DEFAULT_X_FORMAT);
|
|
26
|
+
xAccessor = $derived.by(() => {
|
|
27
|
+
if (this.#xAxisProps?.accessor)
|
|
28
|
+
return this.#xAxisProps.accessor;
|
|
29
|
+
return (value) => value[this.dataKey];
|
|
30
|
+
});
|
|
31
|
+
seriesKeys = $derived(this.series.map((s) => s.name));
|
|
32
|
+
yAccessor = $derived.by(() => {
|
|
33
|
+
return this.series.map((s) => ({ name: s.name, accessor: (value) => s.accessor?.(value[s.name]) || value[s.name] }));
|
|
34
|
+
});
|
|
35
|
+
xDomain = $derived(this.#xAxisProps?.domain || [0, this.chartWidth]);
|
|
36
|
+
yDomain = $derived(this.#yAxisProps?.domain || [this.chartHeight, 0]);
|
|
37
|
+
xRange = $derived(minMax(this.data, this.xAccessor));
|
|
38
|
+
xScale = $derived(this.#_xScale(this.xRange, this.xDomain));
|
|
39
|
+
yRange = $derived(minMaxObject(this.data, this.yAccessor));
|
|
40
|
+
yScale = $derived(this.#_yScale(this.yRange, this.yDomain));
|
|
41
|
+
rootRef = $state();
|
|
42
|
+
chartRef = $state();
|
|
43
|
+
constructor(props) {
|
|
44
|
+
this.#props = props;
|
|
45
|
+
}
|
|
46
|
+
get xTicks() {
|
|
47
|
+
return tickLabels(this.xRange, this.xScale, this.xFormatLabel, this.#xAxisProps?.ticks || DEFAULT_X_TICKS);
|
|
48
|
+
}
|
|
49
|
+
get yTicks() {
|
|
50
|
+
return tickLabels(this.yRange, this.yScale, this.yFormatLabel, this.#yAxisProps?.ticks || DEFAULT_Y_TICKS);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export const CHART_CONTEXT_KEY = Symbol();
|
|
54
|
+
export function getChartContext() {
|
|
55
|
+
return getContext(CHART_CONTEXT_KEY);
|
|
56
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { DivElement } from '../../element-types.js';
|
|
3
|
+
import { getThemeColor } from '../../MantineProvider/index.js';
|
|
4
|
+
import type { MantineColor } from '../../MantineProvider/theme.types.js';
|
|
5
|
+
import { rem } from '../../utils/index.js';
|
|
6
|
+
import { isBrowser } from 'es-toolkit';
|
|
7
|
+
import NewChartTooltip, { type ChartTooltipProps } from '../ChartTooltip/ChartTooltip.svelte';
|
|
8
|
+
import { scaleLinear } from '../d3/scale/scaleLinear.js';
|
|
9
|
+
import type { ChartSeries } from '../types.js';
|
|
10
|
+
import { CHART_CONTEXT_KEY, ChartContext } from './ChartContext.svelte.js';
|
|
11
|
+
import ChartXGrid from './ChartXGrid.svelte';
|
|
12
|
+
import ChartXLabels from './ChartXLabels.svelte';
|
|
13
|
+
import ChartYGrid from './ChartYGrid.svelte';
|
|
14
|
+
import ChartYLabels from './ChartYLabels.svelte';
|
|
15
|
+
|
|
16
|
+
export interface ChartYAxisProps {
|
|
17
|
+
/** The domain of the y-axis */
|
|
18
|
+
domain?: [number, number];
|
|
19
|
+
|
|
20
|
+
/** The maximum number of ticks to display on the y-axis, `10` or of below 10 elements in data its the amount of elements by default. It will be reduced if there isn't enough space to show all of the ticks */
|
|
21
|
+
ticks?: number;
|
|
22
|
+
|
|
23
|
+
/** The format function for the y-axis labels, `(value: number) => value.toString()` by default */
|
|
24
|
+
formatLabel?: (value: number) => string;
|
|
25
|
+
|
|
26
|
+
/** The padding of the y-axis */
|
|
27
|
+
// padding?: {
|
|
28
|
+
// left?: number;
|
|
29
|
+
// right?: number;
|
|
30
|
+
// };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ChartXAxisProps<T> {
|
|
34
|
+
/** The domain of the y-axis */
|
|
35
|
+
domain?: [number, number];
|
|
36
|
+
|
|
37
|
+
/** The maximum number of ticks to display on the y-axis, `10` or of below 10 elements in data its the amount of elements by default. It will be reduced if there isn't enough space to show all of the ticks */
|
|
38
|
+
ticks?: number;
|
|
39
|
+
|
|
40
|
+
/** The format function for the y-axis labels, `(value: number) => value.toString()` by default */
|
|
41
|
+
formatLabel?: (value: number) => string;
|
|
42
|
+
|
|
43
|
+
/** The accessor function for the y-axis, `(value: number) => value` by default */
|
|
44
|
+
accessor?: (value: T) => number;
|
|
45
|
+
|
|
46
|
+
/** The padding of the x-axis */
|
|
47
|
+
// padding?: {
|
|
48
|
+
// top?: number;
|
|
49
|
+
// bottom?: number;
|
|
50
|
+
// };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ChartRootProps<T extends Record<string, unknown>> extends Omit<DivElement, 'children' | 'color'> {
|
|
54
|
+
/** Data used to display chart */
|
|
55
|
+
data: T[];
|
|
56
|
+
|
|
57
|
+
/** Width of the chart, `100%` by default */
|
|
58
|
+
width?: number | string;
|
|
59
|
+
|
|
60
|
+
/** Height of the chart, `100%` by default */
|
|
61
|
+
height?: number | string;
|
|
62
|
+
|
|
63
|
+
/** Whether to show y-axis, `true` by default */
|
|
64
|
+
withYAxis?: boolean;
|
|
65
|
+
|
|
66
|
+
/** Whether to show x-axis, `true` by default */
|
|
67
|
+
withXAxis?: boolean;
|
|
68
|
+
|
|
69
|
+
/** Props for the tooltip */
|
|
70
|
+
tooltipProps?: ChartTooltipProps<T>;
|
|
71
|
+
|
|
72
|
+
/** Whether to show tooltip, `true` by default */
|
|
73
|
+
withTooltip?: boolean;
|
|
74
|
+
|
|
75
|
+
/** Series of the chart */
|
|
76
|
+
series: ChartSeries<T, keyof T>[];
|
|
77
|
+
|
|
78
|
+
/** Key of the `data` object to be used for the chart */
|
|
79
|
+
dataKey: keyof T;
|
|
80
|
+
|
|
81
|
+
/** Props for the y-axis */
|
|
82
|
+
yAxisProps?: ChartYAxisProps;
|
|
83
|
+
|
|
84
|
+
/** Props for the x-axis */
|
|
85
|
+
xAxisProps?: ChartXAxisProps<T>;
|
|
86
|
+
|
|
87
|
+
/** Color of the grid and cursor lines, by default depends on color scheme */
|
|
88
|
+
gridColor?: MantineColor;
|
|
89
|
+
|
|
90
|
+
/** Scale function for the x-axis */
|
|
91
|
+
xScale?: typeof scaleLinear;
|
|
92
|
+
|
|
93
|
+
/** Scale function for the y-axis */
|
|
94
|
+
yScale?: typeof scaleLinear;
|
|
95
|
+
|
|
96
|
+
/** Children to render inside the chart */
|
|
97
|
+
children: Snippet<[context: ChartContext<T>]>;
|
|
98
|
+
|
|
99
|
+
/** Whether to show x-axis grid lines, `true` by default */
|
|
100
|
+
xGrid?: boolean | 'top' | 'bottom' | 'top-bottom';
|
|
101
|
+
|
|
102
|
+
/** Whether to show y-axis grid lines, `true` by default */
|
|
103
|
+
yGrid?: boolean | 'top' | 'bottom' | 'top-bottom';
|
|
104
|
+
|
|
105
|
+
/** Color of the text displayed inside the chart, `dimmed` by default */
|
|
106
|
+
textColor?: MantineColor;
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<script lang="ts" generics="T extends Record<string, any>">
|
|
111
|
+
import { setContext, type Snippet } from 'svelte';
|
|
112
|
+
|
|
113
|
+
let {
|
|
114
|
+
width = '100%',
|
|
115
|
+
height = '100%',
|
|
116
|
+
withYAxis = true,
|
|
117
|
+
withXAxis = true,
|
|
118
|
+
withTooltip = true,
|
|
119
|
+
data,
|
|
120
|
+
series,
|
|
121
|
+
dataKey,
|
|
122
|
+
yAxisProps,
|
|
123
|
+
xAxisProps,
|
|
124
|
+
gridColor,
|
|
125
|
+
xScale = scaleLinear,
|
|
126
|
+
yScale = scaleLinear,
|
|
127
|
+
xGrid = true,
|
|
128
|
+
yGrid = true,
|
|
129
|
+
textColor,
|
|
130
|
+
children,
|
|
131
|
+
tooltipProps,
|
|
132
|
+
...props
|
|
133
|
+
}: ChartRootProps<T> = $props();
|
|
134
|
+
|
|
135
|
+
const context = new ChartContext({
|
|
136
|
+
data: () => data,
|
|
137
|
+
series: () => series,
|
|
138
|
+
dataKey: () => dataKey,
|
|
139
|
+
yAxisProps: () => yAxisProps,
|
|
140
|
+
xAxisProps: () => xAxisProps,
|
|
141
|
+
xScale: () => scaleLinear,
|
|
142
|
+
yScale: () => scaleLinear,
|
|
143
|
+
xGrid: () => xGrid,
|
|
144
|
+
yGrid: () => yGrid,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
setContext(CHART_CONTEXT_KEY, context);
|
|
148
|
+
</script>
|
|
149
|
+
|
|
150
|
+
<div
|
|
151
|
+
{...props}
|
|
152
|
+
class={['root', props.class]}
|
|
153
|
+
style:width={rem(width)}
|
|
154
|
+
style:height={rem(height)}
|
|
155
|
+
bind:this={context.rootRef}
|
|
156
|
+
style:--chart-grid-color={gridColor ? getThemeColor(gridColor) : undefined}
|
|
157
|
+
style:--chart-text-color={textColor ? getThemeColor(textColor) : undefined}
|
|
158
|
+
>
|
|
159
|
+
<svg
|
|
160
|
+
class="chart"
|
|
161
|
+
width="100%"
|
|
162
|
+
height="100%"
|
|
163
|
+
viewBox="0 0 {context.chartWidth} {context.chartHeight}"
|
|
164
|
+
preserveAspectRatio="none"
|
|
165
|
+
bind:this={context.chartRef}
|
|
166
|
+
bind:clientWidth={context.chartWidth}
|
|
167
|
+
bind:clientHeight={context.chartHeight}
|
|
168
|
+
>
|
|
169
|
+
{@render children(context)}
|
|
170
|
+
|
|
171
|
+
{#if xGrid}
|
|
172
|
+
<ChartXGrid />
|
|
173
|
+
{/if}
|
|
174
|
+
|
|
175
|
+
{#if yGrid}
|
|
176
|
+
<ChartYGrid />
|
|
177
|
+
{/if}
|
|
178
|
+
</svg>
|
|
179
|
+
|
|
180
|
+
{#if isBrowser() && withTooltip && context.chartRef}
|
|
181
|
+
<NewChartTooltip {...tooltipProps} />
|
|
182
|
+
{/if}
|
|
183
|
+
|
|
184
|
+
{#if withYAxis}
|
|
185
|
+
<ChartYLabels />
|
|
186
|
+
{/if}
|
|
187
|
+
|
|
188
|
+
{#if withXAxis}
|
|
189
|
+
<ChartXLabels />
|
|
190
|
+
{/if}
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<style>.root {
|
|
194
|
+
user-select: none;
|
|
195
|
+
display: grid;
|
|
196
|
+
grid-template-columns: max-content 1fr;
|
|
197
|
+
grid-template-rows: 1fr 1.25rem;
|
|
198
|
+
grid-template-areas: "y-axis chart" "empty x-axis";
|
|
199
|
+
position: relative;
|
|
200
|
+
gap: 0.75rem;
|
|
201
|
+
--chart-bar-label-color: var(--mantine-color-dimmed);
|
|
202
|
+
}
|
|
203
|
+
:global(:where([data-mantine-color-scheme="light"])) .root {
|
|
204
|
+
--chart-grid-color: rgba(173, 181, 189, 0.6);
|
|
205
|
+
--chart-cursor-fill: rgba(173, 181, 189, 0.15);
|
|
206
|
+
}
|
|
207
|
+
:global(:where([data-mantine-color-scheme="dark"])) .root {
|
|
208
|
+
--chart-cursor-fill: rgba(105, 105, 105, 0.15);
|
|
209
|
+
--chart-grid-color: rgba(105, 105, 105, 0.6);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.chart {
|
|
213
|
+
grid-area: chart;
|
|
214
|
+
overflow: visible;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.y-axis-container {
|
|
218
|
+
grid-area: y-axis;
|
|
219
|
+
position: relative;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.x-axis-container {
|
|
223
|
+
grid-area: x-axis;
|
|
224
|
+
position: relative;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.x-axis-tick-label {
|
|
228
|
+
transform: translateX(-50%);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.y-axis-tick-label {
|
|
232
|
+
text-align: right;
|
|
233
|
+
transform: translateY(-50%);
|
|
234
|
+
right: 0;
|
|
235
|
+
height: 0;
|
|
236
|
+
line-height: 0;
|
|
237
|
+
width: 100%;
|
|
238
|
+
}</style>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { DivElement } from '../../element-types.js';
|
|
2
|
+
import type { MantineColor } from '../../MantineProvider/theme.types.js';
|
|
3
|
+
import { type ChartTooltipProps } from '../ChartTooltip/ChartTooltip.svelte';
|
|
4
|
+
import { scaleLinear } from '../d3/scale/scaleLinear.js';
|
|
5
|
+
import type { ChartSeries } from '../types.js';
|
|
6
|
+
import { ChartContext } from './ChartContext.svelte.js';
|
|
7
|
+
export interface ChartYAxisProps {
|
|
8
|
+
/** The domain of the y-axis */
|
|
9
|
+
domain?: [number, number];
|
|
10
|
+
/** The maximum number of ticks to display on the y-axis, `10` or of below 10 elements in data its the amount of elements by default. It will be reduced if there isn't enough space to show all of the ticks */
|
|
11
|
+
ticks?: number;
|
|
12
|
+
/** The format function for the y-axis labels, `(value: number) => value.toString()` by default */
|
|
13
|
+
formatLabel?: (value: number) => string;
|
|
14
|
+
}
|
|
15
|
+
export interface ChartXAxisProps<T> {
|
|
16
|
+
/** The domain of the y-axis */
|
|
17
|
+
domain?: [number, number];
|
|
18
|
+
/** The maximum number of ticks to display on the y-axis, `10` or of below 10 elements in data its the amount of elements by default. It will be reduced if there isn't enough space to show all of the ticks */
|
|
19
|
+
ticks?: number;
|
|
20
|
+
/** The format function for the y-axis labels, `(value: number) => value.toString()` by default */
|
|
21
|
+
formatLabel?: (value: number) => string;
|
|
22
|
+
/** The accessor function for the y-axis, `(value: number) => value` by default */
|
|
23
|
+
accessor?: (value: T) => number;
|
|
24
|
+
}
|
|
25
|
+
export interface ChartRootProps<T extends Record<string, unknown>> extends Omit<DivElement, 'children' | 'color'> {
|
|
26
|
+
/** Data used to display chart */
|
|
27
|
+
data: T[];
|
|
28
|
+
/** Width of the chart, `100%` by default */
|
|
29
|
+
width?: number | string;
|
|
30
|
+
/** Height of the chart, `100%` by default */
|
|
31
|
+
height?: number | string;
|
|
32
|
+
/** Whether to show y-axis, `true` by default */
|
|
33
|
+
withYAxis?: boolean;
|
|
34
|
+
/** Whether to show x-axis, `true` by default */
|
|
35
|
+
withXAxis?: boolean;
|
|
36
|
+
/** Props for the tooltip */
|
|
37
|
+
tooltipProps?: ChartTooltipProps<T>;
|
|
38
|
+
/** Whether to show tooltip, `true` by default */
|
|
39
|
+
withTooltip?: boolean;
|
|
40
|
+
/** Series of the chart */
|
|
41
|
+
series: ChartSeries<T, keyof T>[];
|
|
42
|
+
/** Key of the `data` object to be used for the chart */
|
|
43
|
+
dataKey: keyof T;
|
|
44
|
+
/** Props for the y-axis */
|
|
45
|
+
yAxisProps?: ChartYAxisProps;
|
|
46
|
+
/** Props for the x-axis */
|
|
47
|
+
xAxisProps?: ChartXAxisProps<T>;
|
|
48
|
+
/** Color of the grid and cursor lines, by default depends on color scheme */
|
|
49
|
+
gridColor?: MantineColor;
|
|
50
|
+
/** Scale function for the x-axis */
|
|
51
|
+
xScale?: typeof scaleLinear;
|
|
52
|
+
/** Scale function for the y-axis */
|
|
53
|
+
yScale?: typeof scaleLinear;
|
|
54
|
+
/** Children to render inside the chart */
|
|
55
|
+
children: Snippet<[context: ChartContext<T>]>;
|
|
56
|
+
/** Whether to show x-axis grid lines, `true` by default */
|
|
57
|
+
xGrid?: boolean | 'top' | 'bottom' | 'top-bottom';
|
|
58
|
+
/** Whether to show y-axis grid lines, `true` by default */
|
|
59
|
+
yGrid?: boolean | 'top' | 'bottom' | 'top-bottom';
|
|
60
|
+
/** Color of the text displayed inside the chart, `dimmed` by default */
|
|
61
|
+
textColor?: MantineColor;
|
|
62
|
+
}
|
|
63
|
+
import { type Snippet } from 'svelte';
|
|
64
|
+
declare function $$render<T extends Record<string, any>>(): {
|
|
65
|
+
props: ChartRootProps<T>;
|
|
66
|
+
exports: {};
|
|
67
|
+
bindings: "";
|
|
68
|
+
slots: {};
|
|
69
|
+
events: {};
|
|
70
|
+
};
|
|
71
|
+
declare class __sveltets_Render<T extends Record<string, any>> {
|
|
72
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
73
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
74
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
75
|
+
bindings(): "";
|
|
76
|
+
exports(): {};
|
|
77
|
+
}
|
|
78
|
+
interface $$IsomorphicComponent {
|
|
79
|
+
new <T extends Record<string, any>>(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']>> & {
|
|
80
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
81
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
82
|
+
<T extends Record<string, any>>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
83
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
84
|
+
}
|
|
85
|
+
declare const ChartRoot: $$IsomorphicComponent;
|
|
86
|
+
type ChartRoot<T extends Record<string, any>> = InstanceType<typeof ChartRoot<T>>;
|
|
87
|
+
export default ChartRoot;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getChartContext } from './ChartContext.svelte.js';
|
|
3
|
+
|
|
4
|
+
const ctx = getChartContext();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if typeof ctx.xGrid === 'boolean'}
|
|
8
|
+
{#each ctx.xTicks.labels as tick}
|
|
9
|
+
<line class="grid-lines" x1={tick.position} x2={tick.position} y1={0} y2={ctx.chartHeight} />
|
|
10
|
+
{/each}
|
|
11
|
+
{:else if typeof ctx.xGrid === 'string'}
|
|
12
|
+
{#if ctx.xGrid.includes('top')}
|
|
13
|
+
<line class="grid-lines" x1={ctx.xTicks.labels[0].position} x2={ctx.xTicks.labels[0].position} y1={0} y2={ctx.chartHeight} />
|
|
14
|
+
{/if}
|
|
15
|
+
{#if ctx.xGrid.includes('bottom')}
|
|
16
|
+
<line
|
|
17
|
+
class="grid-lines"
|
|
18
|
+
x1={ctx.xTicks.labels[ctx.xTicks.labels.length - 1].position}
|
|
19
|
+
x2={ctx.xTicks.labels[ctx.xTicks.labels.length - 1].position}
|
|
20
|
+
y1={0}
|
|
21
|
+
y2={ctx.chartHeight}
|
|
22
|
+
/>
|
|
23
|
+
{/if}
|
|
24
|
+
{/if}
|
|
25
|
+
|
|
26
|
+
<style>.grid-lines {
|
|
27
|
+
stroke-opacity: 0.25;
|
|
28
|
+
stroke-width: 2;
|
|
29
|
+
stroke: var(--chart-grid-color);
|
|
30
|
+
stroke-dasharray: 2 4;
|
|
31
|
+
vector-effect: non-scaling-stroke;
|
|
32
|
+
}</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const ChartXGrid: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type ChartXGrid = InstanceType<typeof ChartXGrid>;
|
|
18
|
+
export default ChartXGrid;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getChartContext } from './ChartContext.svelte.js';
|
|
3
|
+
|
|
4
|
+
const ctx = getChartContext();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="container">
|
|
8
|
+
{#each ctx.xTicks.labels as tick}
|
|
9
|
+
<span class="label" style:left="{tick.position}px">
|
|
10
|
+
{tick.label}
|
|
11
|
+
</span>
|
|
12
|
+
{/each}
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<style>.container {
|
|
16
|
+
grid-area: x-axis;
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.label {
|
|
21
|
+
position: absolute;
|
|
22
|
+
font-size: 0.75rem;
|
|
23
|
+
font-family: var(--mantine-font-family);
|
|
24
|
+
color: var(--chart-text-color, var(--mantine-color-dimmed));
|
|
25
|
+
transform: translateX(-50%);
|
|
26
|
+
}</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const ChartXLabels: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type ChartXLabels = InstanceType<typeof ChartXLabels>;
|
|
18
|
+
export default ChartXLabels;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getChartContext } from './ChartContext.svelte.js';
|
|
3
|
+
|
|
4
|
+
const ctx = getChartContext();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#if typeof ctx.yGrid === 'boolean'}
|
|
8
|
+
{#each ctx.yTicks.labels as tick, index}
|
|
9
|
+
<line class="grid-lines" x1={0} x2={ctx.chartWidth} y1={tick.position} y2={tick.position} />
|
|
10
|
+
{/each}
|
|
11
|
+
{:else if typeof ctx.yGrid === 'string'}
|
|
12
|
+
{#if ctx.yGrid.includes('top')}
|
|
13
|
+
<line class="grid-lines" x1={0} x2={ctx.chartWidth} y1={ctx.yTicks.labels[0].position} y2={ctx.yTicks.labels[0].position} />
|
|
14
|
+
{/if}
|
|
15
|
+
{#if ctx.yGrid.includes('bottom')}
|
|
16
|
+
<line
|
|
17
|
+
class="grid-lines"
|
|
18
|
+
x1={0}
|
|
19
|
+
x2={ctx.chartWidth}
|
|
20
|
+
y1={ctx.yTicks.labels[ctx.yTicks.labels.length - 1].position}
|
|
21
|
+
y2={ctx.yTicks.labels[ctx.yTicks.labels.length - 1].position}
|
|
22
|
+
/>
|
|
23
|
+
{/if}
|
|
24
|
+
{/if}
|
|
25
|
+
|
|
26
|
+
<style>.grid-lines {
|
|
27
|
+
stroke-opacity: 0.25;
|
|
28
|
+
stroke-width: 2;
|
|
29
|
+
stroke: var(--chart-grid-color);
|
|
30
|
+
stroke-dasharray: 2 4;
|
|
31
|
+
vector-effect: non-scaling-stroke;
|
|
32
|
+
}</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const ChartYGrid: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type ChartYGrid = InstanceType<typeof ChartYGrid>;
|
|
18
|
+
export default ChartYGrid;
|