@communitiesuk/svelte-component-library 0.1.19-beta.3 → 0.1.19-beta.33
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/README.md +7 -0
- package/dist/components/content/Tag.svelte +32 -0
- package/dist/components/content/Tag.svelte.d.ts +13 -0
- package/dist/components/data-vis/Histogram.svelte +302 -0
- package/dist/components/data-vis/Histogram.svelte.d.ts +75 -0
- package/dist/components/data-vis/axis/Axis.svelte +217 -34
- package/dist/components/data-vis/axis/Axis.svelte.d.ts +38 -30
- package/dist/components/data-vis/axis/Ticks.svelte +142 -78
- package/dist/components/data-vis/axis/Ticks.svelte.d.ts +28 -31
- package/dist/components/data-vis/line-chart/LineChart.svelte +51 -21
- package/dist/components/data-vis/line-chart/LineChart.svelte.d.ts +14 -6
- package/dist/components/data-vis/line-chart/ValueLabel.svelte +2 -1
- package/dist/components/data-vis/line-chart/ValueLabel.svelte.d.ts +2 -0
- package/dist/components/data-vis/position-chart/PositionChart.svelte +278 -122
- package/dist/components/data-vis/position-chart/PositionChart.svelte.d.ts +37 -5
- package/dist/components/data-vis/position-chart/PositionChartAxis.svelte +59 -48
- package/dist/components/data-vis/position-chart/PositionChartAxis.svelte.d.ts +4 -4
- package/dist/components/layout/Footer.svelte +9 -0
- package/dist/components/layout/Footer.svelte.d.ts +1 -0
- package/dist/components/layout/PhaseBanner.svelte +10 -1
- package/dist/components/layout/PhaseBanner.svelte.d.ts +1 -0
- package/dist/components/layout/ServiceNavigation.svelte +19 -1
- package/dist/components/layout/ServiceNavigation.svelte.d.ts +2 -0
- package/dist/components/ui/BasicMultiSelect.svelte +716 -0
- package/dist/components/ui/BasicMultiSelect.svelte.d.ts +18 -0
- package/dist/components/ui/Button.svelte +1 -0
- package/dist/components/ui/Card.svelte +48 -60
- package/dist/components/ui/Card.svelte.d.ts +26 -12
- package/dist/components/ui/CardHeader.svelte +46 -0
- package/dist/components/ui/CardHeader.svelte.d.ts +21 -0
- package/dist/components/ui/ChartExporter.svelte +142 -0
- package/dist/components/ui/ChartExporter.svelte.d.ts +16 -0
- package/dist/components/ui/CheckBox.svelte +1 -0
- package/dist/components/ui/Details.svelte +47 -8
- package/dist/components/ui/Details.svelte.d.ts +8 -10
- package/dist/components/ui/Masthead.svelte +44 -6
- package/dist/components/ui/Masthead.svelte.d.ts +6 -0
- package/dist/components/ui/RelatedContent.svelte +4 -1
- package/dist/components/ui/RelatedContent.svelte.d.ts +1 -0
- package/dist/components/ui/SearchAutocomplete.svelte +69 -44
- package/dist/components/ui/SearchAutocomplete.svelte.d.ts +1 -0
- package/dist/components/ui/Select.svelte +18 -7
- package/dist/components/ui/Tabs.svelte +192 -18
- package/dist/components/ui/Tabs.svelte.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/package.json +4 -1
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type ScaleContinuousNumeric } from "d3-scale";
|
|
2
|
+
type AxisName = "x" | "y";
|
|
3
|
+
type AxisPosition = "bottom" | "top" | "left" | "right";
|
|
4
|
+
type Orientation = {
|
|
5
|
+
axis: AxisName;
|
|
6
|
+
position: AxisPosition;
|
|
5
7
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
chartWidth: any;
|
|
9
|
-
numberOfTicks: any;
|
|
10
|
-
ticksArray?: any;
|
|
11
|
-
axisFunction: any;
|
|
12
|
-
values: any;
|
|
13
|
-
orientation: any;
|
|
14
|
-
prefix: any;
|
|
15
|
-
suffix: any;
|
|
16
|
-
floor: any;
|
|
17
|
-
ceiling: any;
|
|
18
|
-
yearsInput: any;
|
|
19
|
-
}, {}, "ticksArray">;
|
|
8
|
+
type LabelFormatter = (tick: number, index: number, ticksArrayLength: number) => string | number;
|
|
9
|
+
type Polarity = "standard" | "reverse";
|
|
20
10
|
type $$ComponentProps = {
|
|
21
|
-
chartHeight
|
|
22
|
-
chartWidth
|
|
23
|
-
numberOfTicks
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
chartHeight?: number;
|
|
12
|
+
chartWidth?: number;
|
|
13
|
+
numberOfTicks?: number;
|
|
14
|
+
axisDomain?: number[];
|
|
15
|
+
ticksArray?: number[];
|
|
16
|
+
min?: number;
|
|
17
|
+
max?: number;
|
|
18
|
+
orientation?: Orientation;
|
|
19
|
+
floor?: number;
|
|
20
|
+
ceiling?: number;
|
|
21
|
+
paddingTop?: number;
|
|
22
|
+
paddingBottom?: number;
|
|
23
|
+
paddingLeft?: number;
|
|
24
|
+
paddingRight?: number;
|
|
25
|
+
labelFormatter?: LabelFormatter;
|
|
26
|
+
scale?: ScaleContinuousNumeric<number, number>;
|
|
27
|
+
domain?: [number, number];
|
|
28
|
+
range?: [number, number];
|
|
29
|
+
fontSize?: number;
|
|
30
|
+
polarity?: Polarity;
|
|
31
|
+
gridlines?: boolean;
|
|
32
|
+
strokeWidth?: number;
|
|
33
|
+
showGridlines?: boolean;
|
|
34
|
+
showTickMarks?: boolean;
|
|
35
|
+
niceTicks?: boolean;
|
|
36
|
+
markerRadius?: number;
|
|
37
|
+
distribution?: number[];
|
|
33
38
|
};
|
|
39
|
+
declare const Axis: import("svelte").Component<$$ComponentProps, {}, "ticksArray" | "axisDomain">;
|
|
40
|
+
type Axis = ReturnType<typeof Axis>;
|
|
41
|
+
export default Axis;
|
|
@@ -1,112 +1,176 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import Decimal from "decimal.js";
|
|
3
|
+
import { ticks, tickStep, range, nice } from "d3-array";
|
|
4
|
+
import { scaleLinear } from "d3-scale";
|
|
5
|
+
import Axis from "./Axis.svelte";
|
|
3
6
|
|
|
7
|
+
// Types
|
|
8
|
+
type Axis = "x" | "y";
|
|
9
|
+
type Position = "left" | "right" | "top" | "bottom";
|
|
10
|
+
|
|
11
|
+
interface Orientation {
|
|
12
|
+
axis: Axis;
|
|
13
|
+
position: Position;
|
|
14
|
+
}
|
|
15
|
+
type Polarity = "standard" | "reverse";
|
|
16
|
+
|
|
17
|
+
type LabelFormatter = (
|
|
18
|
+
tick: number,
|
|
19
|
+
index: number,
|
|
20
|
+
ticksArrayLength: number,
|
|
21
|
+
) => string | number;
|
|
22
|
+
|
|
23
|
+
// Props with defaults (Svelte 5 runes)
|
|
4
24
|
let {
|
|
5
|
-
ticksArray = $bindable(),
|
|
6
|
-
|
|
7
|
-
suffix,
|
|
8
|
-
chartWidth,
|
|
25
|
+
ticksArray = $bindable<number[]>(),
|
|
26
|
+
tickWidth,
|
|
9
27
|
chartHeight,
|
|
10
|
-
|
|
11
|
-
|
|
28
|
+
min,
|
|
29
|
+
max,
|
|
12
30
|
numberOfTicks,
|
|
13
|
-
floor,
|
|
14
|
-
ceiling,
|
|
15
31
|
orientation,
|
|
16
|
-
|
|
32
|
+
fontSize = 19,
|
|
33
|
+
polarity = "standard",
|
|
34
|
+
showGridlines = false,
|
|
35
|
+
showTickMarks = false,
|
|
36
|
+
strokeWidth = 2,
|
|
37
|
+
labelFormatter = undefined as LabelFormatter | undefined,
|
|
38
|
+
niceTicks = true,
|
|
39
|
+
leftPad = 0,
|
|
40
|
+
rightPad = 0,
|
|
41
|
+
}: {
|
|
42
|
+
ticksArray?: number[]; // bindable
|
|
43
|
+
tickWidth: number;
|
|
44
|
+
chartHeight: number;
|
|
45
|
+
min: number;
|
|
46
|
+
max: number;
|
|
47
|
+
numberOfTicks?: number;
|
|
48
|
+
orientation: Orientation;
|
|
49
|
+
fontSize?: number;
|
|
50
|
+
polarity?: Polarity;
|
|
51
|
+
showGridlines?: boolean;
|
|
52
|
+
showTickMarks?: boolean;
|
|
53
|
+
strokeWidth?: number;
|
|
54
|
+
labelFormatter?: LabelFormatter;
|
|
55
|
+
niceTicks?: boolean;
|
|
56
|
+
leftPad?: number;
|
|
57
|
+
rightPad?: number;
|
|
17
58
|
} = $props();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let roughStep = rangeVal.div(numTicks - 1);
|
|
37
|
-
let normalizedSteps = [1, 2, 5, 10];
|
|
38
|
-
|
|
39
|
-
let stepPower = Decimal.pow(
|
|
40
|
-
10,
|
|
41
|
-
-Math.floor(Math.log10(roughStep.toNumber())),
|
|
42
|
-
);
|
|
43
|
-
let normalizedStep = roughStep.mul(stepPower);
|
|
44
|
-
let optimalStep = new Decimal(
|
|
45
|
-
normalizedSteps.find((step) => step >= normalizedStep.toNumber()),
|
|
46
|
-
).div(stepPower);
|
|
47
|
-
|
|
48
|
-
let scaleMin = minVal.div(optimalStep).floor().mul(optimalStep);
|
|
49
|
-
let scaleMax = maxVal.div(optimalStep).ceil().mul(optimalStep);
|
|
50
|
-
|
|
51
|
-
let ticks = [];
|
|
52
|
-
for (let i = scaleMin; i.lte(scaleMax); i = i.plus(optimalStep)) {
|
|
53
|
-
ticks.push(i.toNumber());
|
|
54
|
-
}
|
|
55
|
-
return ticks;
|
|
59
|
+
// function axisValue(fn: any, tick: number): number {
|
|
60
|
+
// // Try single-call first: axisFunction(tick)
|
|
61
|
+
// try {
|
|
62
|
+
// const v = fn(tick);
|
|
63
|
+
// if (typeof v === "number") return v;
|
|
64
|
+
// } catch {
|
|
65
|
+
// // ignore
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// // Fallback: axisFunction()(tick)
|
|
69
|
+
// const inner = fn();
|
|
70
|
+
// return inner(tick);
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
// Default label when no labelFormatter is supplied
|
|
74
|
+
function defaultLabel(tick: number): string {
|
|
75
|
+
return String(tick);
|
|
56
76
|
}
|
|
57
77
|
|
|
58
|
-
function tickCount(
|
|
59
|
-
|
|
78
|
+
function tickCount(w: number, h: number): number {
|
|
79
|
+
const tickNum = orientation.axis === "y" ? h / 50 : w / 50;
|
|
60
80
|
return tickNum;
|
|
61
81
|
}
|
|
62
82
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
let computedTickCount = $derived(
|
|
84
|
+
numberOfTicks ?? tickCount(tickWidth, chartHeight),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
let rawTicks = $derived(
|
|
88
|
+
niceTicks
|
|
89
|
+
? ticks(...nice(min, max, computedTickCount), computedTickCount)
|
|
90
|
+
: leftPad || rightPad
|
|
91
|
+
? polarity === "standard"
|
|
92
|
+
? [min + (max - min) * leftPad, max - (max - min) * rightPad]
|
|
93
|
+
: [min + (max - min) * rightPad, max - (max - min) * leftPad]
|
|
94
|
+
: [min, max],
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
let ticksOrdered = $derived(
|
|
98
|
+
polarity === "standard" ? rawTicks : [...rawTicks].toReversed(),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
$effect(() => {
|
|
102
|
+
ticksArray = ticksOrdered;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
let ticksDomain = $derived(
|
|
106
|
+
polarity === "standard"
|
|
107
|
+
? [Math.min(...ticksArray), Math.max(...ticksArray)]
|
|
108
|
+
: [Math.max(...ticksArray), Math.min(...ticksArray)],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
let axisFunction = $derived(
|
|
112
|
+
scaleLinear().domain(ticksDomain).range([0, tickWidth]),
|
|
113
|
+
);
|
|
71
114
|
</script>
|
|
72
115
|
|
|
73
116
|
{#if axisFunction && ticksArray && orientation.axis && orientation.position}
|
|
74
117
|
{#each ticksArray as tick, index}
|
|
75
118
|
<g
|
|
76
|
-
transform="translate(
|
|
77
|
-
? axisFunction(tick)
|
|
78
|
-
|
|
119
|
+
transform="translate(
|
|
120
|
+
{orientation.axis === 'x' ? axisFunction(tick) : 0},
|
|
121
|
+
{orientation.axis === 'y' ? axisFunction(tick) : 0}
|
|
122
|
+
)"
|
|
79
123
|
>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
?
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
124
|
+
{#if showTickMarks}
|
|
125
|
+
<path
|
|
126
|
+
d={orientation.axis === "y"
|
|
127
|
+
? orientation.position === "left"
|
|
128
|
+
? `M1 0 l-8 0`
|
|
129
|
+
: `M1 0 l8 0`
|
|
130
|
+
: orientation.position === "top"
|
|
131
|
+
? "M0 -1 l0 -8"
|
|
132
|
+
: "M0 -1 l0 8"}
|
|
133
|
+
stroke="grey"
|
|
134
|
+
stroke-width={strokeWidth}
|
|
135
|
+
></path>
|
|
136
|
+
{/if}
|
|
137
|
+
{#if showGridlines}
|
|
138
|
+
<path
|
|
139
|
+
d={orientation.axis === "y"
|
|
140
|
+
? orientation.position === "left"
|
|
141
|
+
? `M0 0 l${tickWidth} 0`
|
|
142
|
+
: `M0 0 l-${tickWidth} 0`
|
|
143
|
+
: orientation.position === "top"
|
|
144
|
+
? `M0 0 l0 ${chartHeight}`
|
|
145
|
+
: `M0 0 l0 -${chartHeight}`}
|
|
146
|
+
stroke="grey"
|
|
147
|
+
stroke-width={strokeWidth}
|
|
148
|
+
></path>
|
|
149
|
+
{/if}
|
|
91
150
|
<text
|
|
92
|
-
transform="translate(
|
|
151
|
+
transform="translate(
|
|
152
|
+
{orientation.axis === 'x'
|
|
93
153
|
? 0
|
|
94
154
|
: orientation.position === 'left'
|
|
95
155
|
? -10
|
|
96
|
-
: 10},
|
|
156
|
+
: 10},
|
|
157
|
+
{orientation.axis === 'y'
|
|
97
158
|
? 5
|
|
98
159
|
: orientation.position === 'top'
|
|
99
160
|
? -10
|
|
100
|
-
:
|
|
101
|
-
|
|
161
|
+
: fontSize * 1.4}
|
|
162
|
+
)"
|
|
163
|
+
font-size={fontSize}
|
|
102
164
|
text-anchor={orientation.axis === "x"
|
|
103
165
|
? "middle"
|
|
104
166
|
: orientation.position === "left"
|
|
105
167
|
? "end"
|
|
106
168
|
: "start"}
|
|
107
|
-
fill="
|
|
169
|
+
fill="grey"
|
|
108
170
|
>
|
|
109
|
-
{
|
|
171
|
+
{labelFormatter
|
|
172
|
+
? labelFormatter(tick, index, ticksArray.length)
|
|
173
|
+
: defaultLabel(tick)}
|
|
110
174
|
</text>
|
|
111
175
|
</g>
|
|
112
176
|
{/each}
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
chartWidth: any;
|
|
11
|
-
chartHeight: any;
|
|
12
|
-
axisFunction: any;
|
|
13
|
-
values: any;
|
|
14
|
-
numberOfTicks: any;
|
|
15
|
-
floor: any;
|
|
16
|
-
ceiling: any;
|
|
17
|
-
orientation: any;
|
|
18
|
-
yearsInput: any;
|
|
19
|
-
}, {}, "ticksArray">;
|
|
1
|
+
import Axis from "./Axis.svelte";
|
|
2
|
+
type Axis = "x" | "y";
|
|
3
|
+
type Position = "left" | "right" | "top" | "bottom";
|
|
4
|
+
interface Orientation {
|
|
5
|
+
axis: Axis;
|
|
6
|
+
position: Position;
|
|
7
|
+
}
|
|
8
|
+
type Polarity = "standard" | "reverse";
|
|
9
|
+
type LabelFormatter = (tick: number, index: number, ticksArrayLength: number) => string | number;
|
|
20
10
|
type $$ComponentProps = {
|
|
21
|
-
ticksArray?:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
ticksArray?: number[];
|
|
12
|
+
tickWidth: number;
|
|
13
|
+
chartHeight: number;
|
|
14
|
+
min: number;
|
|
15
|
+
max: number;
|
|
16
|
+
numberOfTicks?: number;
|
|
17
|
+
orientation: Orientation;
|
|
18
|
+
fontSize?: number;
|
|
19
|
+
polarity?: Polarity;
|
|
20
|
+
showGridlines?: boolean;
|
|
21
|
+
showTickMarks?: boolean;
|
|
22
|
+
strokeWidth?: number;
|
|
23
|
+
labelFormatter?: LabelFormatter;
|
|
24
|
+
niceTicks?: boolean;
|
|
25
|
+
leftPad?: number;
|
|
26
|
+
rightPad?: number;
|
|
33
27
|
};
|
|
28
|
+
declare const Ticks: import("svelte").Component<$$ComponentProps, {}, "ticksArray">;
|
|
29
|
+
type Ticks = ReturnType<typeof Ticks>;
|
|
30
|
+
export default Ticks;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { highlight } from "./../../../utils/syntax-highlighting/shikiHighlight";
|
|
9
9
|
import Lines from "./Lines.svelte";
|
|
10
10
|
import ValueLabel from "./ValueLabel.svelte";
|
|
11
|
+
import Axis from "../axis/Axis.svelte";
|
|
11
12
|
|
|
12
13
|
let {
|
|
13
14
|
series,
|
|
@@ -15,17 +16,18 @@
|
|
|
15
16
|
x,
|
|
16
17
|
lineChartData,
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
return scaleLinear()
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
xScale = (number) => {
|
|
20
|
+
return scaleLinear().domain([xTickMin, xTickMax]).range([0, chartWidth])(
|
|
21
|
+
number,
|
|
22
|
+
);
|
|
22
23
|
},
|
|
23
|
-
|
|
24
|
-
return scaleLinear()
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
yScale = (number) => {
|
|
25
|
+
return scaleLinear().domain([yTickMin, yTickMax]).range([chartHeight, 0])(
|
|
26
|
+
number,
|
|
27
|
+
);
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
lineScale = line()
|
|
29
31
|
.x((d) => xFunction(d[x]))
|
|
30
32
|
.y((d) => yFunction(d[y]))
|
|
31
33
|
.curve(curveLinear),
|
|
@@ -108,6 +110,10 @@
|
|
|
108
110
|
paddingBottom = 50,
|
|
109
111
|
paddingLeft = 50,
|
|
110
112
|
paddingRight = 150,
|
|
113
|
+
xFloor = undefined,
|
|
114
|
+
xCeiling = undefined,
|
|
115
|
+
yFloor = undefined,
|
|
116
|
+
yCeiling = undefined,
|
|
111
117
|
activeMarkerId = undefined,
|
|
112
118
|
chartBackgroundColor = "#f5f5f5",
|
|
113
119
|
seriesLabels = $bindable(false),
|
|
@@ -157,6 +163,18 @@
|
|
|
157
163
|
},
|
|
158
164
|
} = $props();
|
|
159
165
|
|
|
166
|
+
let xTicks = $state([]);
|
|
167
|
+
let yTicks = $state([]);
|
|
168
|
+
|
|
169
|
+
const xTickMin = $derived(xTicks.length ? Math.min(...xTicks) : undefined);
|
|
170
|
+
const xTickMax = $derived(xTicks.length ? Math.max(...xTicks) : undefined);
|
|
171
|
+
const yTickMin = $derived(yTicks.length ? Math.min(...yTicks) : undefined);
|
|
172
|
+
const yTickMax = $derived(yTicks.length ? Math.max(...yTicks) : undefined);
|
|
173
|
+
|
|
174
|
+
let xFunction = $derived((value) => xScale(value));
|
|
175
|
+
let yFunction = $derived((value) => yScale(value));
|
|
176
|
+
let lineFunction = $derived((value) => lineScale(value));
|
|
177
|
+
|
|
160
178
|
const colorValues = Array.isArray(colors) ? colors : Object.values(colors);
|
|
161
179
|
const lineColorMap = {};
|
|
162
180
|
|
|
@@ -197,7 +215,7 @@
|
|
|
197
215
|
let chartHeight = $derived(svgHeight - paddingTop - paddingBottom);
|
|
198
216
|
let areaFunction = $derived(
|
|
199
217
|
area()
|
|
200
|
-
.y0((d) => yFunction(
|
|
218
|
+
.y0((d) => yFunction(yTickMin))
|
|
201
219
|
.x((d) => xFunction(d.x))
|
|
202
220
|
.y1((d) => yFunction(d.y))
|
|
203
221
|
.curve(curveLinear),
|
|
@@ -292,17 +310,29 @@
|
|
|
292
310
|
>
|
|
293
311
|
{#if svgWidth}
|
|
294
312
|
<g transform="translate({paddingLeft},{paddingTop})">
|
|
295
|
-
<
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
313
|
+
<Axis
|
|
314
|
+
bind:ticksArray={yTicks}
|
|
315
|
+
{chartHeight}
|
|
316
|
+
{chartWidth}
|
|
317
|
+
orientation={{ axis: "y", position: "left" }}
|
|
318
|
+
range={[chartHeight, 0]}
|
|
319
|
+
domain={[yTickMin, yTickMax]}
|
|
320
|
+
values={lineChartData.lines.flatMap((l) => l.data.map((d) => d[y]))}
|
|
321
|
+
ceiling={yCeiling ?? yTickMax}
|
|
322
|
+
floor={yFloor ?? yTickMin}
|
|
323
|
+
></Axis>
|
|
324
|
+
<!--X axis-->
|
|
325
|
+
<Axis
|
|
326
|
+
bind:ticksArray={xTicks}
|
|
327
|
+
{chartWidth}
|
|
328
|
+
{chartHeight}
|
|
329
|
+
orientation={{ axis: "x", position: "bottom" }}
|
|
330
|
+
values={lineChartData.lines.flatMap((l) => l.data.map((d) => d[x]))}
|
|
331
|
+
range={[0, chartWidth]}
|
|
332
|
+
domain={[xTickMin, xTickMax]}
|
|
333
|
+
ceiling={xCeiling ?? xTickMax}
|
|
334
|
+
floor={xFloor ?? xTickMin}
|
|
335
|
+
></Axis>
|
|
306
336
|
<g data-role="lines-group">
|
|
307
337
|
<Lines
|
|
308
338
|
{tieredDataObject}
|
|
@@ -8,9 +8,9 @@ declare const LineChart: import("svelte").Component<{
|
|
|
8
8
|
y: any;
|
|
9
9
|
x: any;
|
|
10
10
|
lineChartData: any;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
xScale?: Function;
|
|
12
|
+
yScale?: Function;
|
|
13
|
+
lineScale?: any;
|
|
14
14
|
labelText?: Function;
|
|
15
15
|
onClickSeries?: Function;
|
|
16
16
|
onMouseLeaveSeries?: Function;
|
|
@@ -34,6 +34,10 @@ declare const LineChart: import("svelte").Component<{
|
|
|
34
34
|
paddingBottom?: number;
|
|
35
35
|
paddingLeft?: number;
|
|
36
36
|
paddingRight?: number;
|
|
37
|
+
xFloor?: any;
|
|
38
|
+
xCeiling?: any;
|
|
39
|
+
yFloor?: any;
|
|
40
|
+
yCeiling?: any;
|
|
37
41
|
activeMarkerId?: any;
|
|
38
42
|
chartBackgroundColor?: string;
|
|
39
43
|
seriesLabels?: boolean;
|
|
@@ -50,9 +54,9 @@ type $$ComponentProps = {
|
|
|
50
54
|
y: any;
|
|
51
55
|
x: any;
|
|
52
56
|
lineChartData: any;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
xScale?: Function;
|
|
58
|
+
yScale?: Function;
|
|
59
|
+
lineScale?: any;
|
|
56
60
|
labelText?: Function;
|
|
57
61
|
onClickSeries?: Function;
|
|
58
62
|
onMouseLeaveSeries?: Function;
|
|
@@ -76,6 +80,10 @@ type $$ComponentProps = {
|
|
|
76
80
|
paddingBottom?: number;
|
|
77
81
|
paddingLeft?: number;
|
|
78
82
|
paddingRight?: number;
|
|
83
|
+
xFloor?: any;
|
|
84
|
+
xCeiling?: any;
|
|
85
|
+
yFloor?: any;
|
|
86
|
+
yCeiling?: any;
|
|
79
87
|
activeMarkerId?: any;
|
|
80
88
|
chartBackgroundColor?: string;
|
|
81
89
|
seriesLabels?: boolean;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
markerRect = undefined,
|
|
12
12
|
tooltipSnippet,
|
|
13
13
|
labelText = undefined,
|
|
14
|
+
yOffset = 20,
|
|
14
15
|
} = $props();
|
|
15
16
|
|
|
16
17
|
let textDimensions = $state();
|
|
@@ -31,7 +32,7 @@ left: {markerRect?.x +
|
|
|
31
32
|
style="position:absolute; left: {markerRect?.x - textDimensions?.width / 2}px;
|
|
32
33
|
top: {markerRect?.y -
|
|
33
34
|
textDimensions?.height -
|
|
34
|
-
|
|
35
|
+
yOffset}px; pointer-events: none"
|
|
35
36
|
bind:contentRect={textDimensions}
|
|
36
37
|
>
|
|
37
38
|
{#if tooltipSnippet === undefined}
|
|
@@ -15,6 +15,7 @@ declare const ValueLabel: import("svelte").Component<{
|
|
|
15
15
|
markerRect?: any;
|
|
16
16
|
tooltipSnippet: any;
|
|
17
17
|
labelText?: any;
|
|
18
|
+
yOffset?: number;
|
|
18
19
|
}, {}, "">;
|
|
19
20
|
type $$ComponentProps = {
|
|
20
21
|
activeMarkerId: any;
|
|
@@ -28,4 +29,5 @@ type $$ComponentProps = {
|
|
|
28
29
|
markerRect?: any;
|
|
29
30
|
tooltipSnippet: any;
|
|
30
31
|
labelText?: any;
|
|
32
|
+
yOffset?: number;
|
|
31
33
|
};
|