@communitiesuk/svelte-component-library 0.1.19-beta.2 → 0.1.19-beta.20
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/data-vis/Histogram.svelte +245 -0
- package/dist/components/data-vis/Histogram.svelte.d.ts +71 -0
- package/dist/components/data-vis/axis/Axis.svelte +140 -34
- package/dist/components/data-vis/axis/Axis.svelte.d.ts +34 -30
- package/dist/components/data-vis/axis/Ticks.svelte +155 -60
- package/dist/components/data-vis/axis/Ticks.svelte.d.ts +25 -30
- 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/position-chart/PositionChart.svelte +220 -112
- package/dist/components/data-vis/position-chart/PositionChart.svelte.d.ts +26 -4
- package/dist/components/data-vis/position-chart/PositionChartAxis.svelte +38 -34
- package/dist/components/data-vis/position-chart/PositionChartAxis.svelte.d.ts +6 -2
- 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 +185 -0
- package/dist/components/ui/BasicMultiSelect.svelte.d.ts +8 -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/Details.svelte +10 -2
- package/dist/components/ui/Details.svelte.d.ts +2 -0
- package/dist/components/ui/Masthead.svelte +36 -6
- package/dist/components/ui/Masthead.svelte.d.ts +4 -0
- package/dist/components/ui/PostcodeOrAreaSearch.svelte +12 -0
- package/dist/components/ui/PostcodeOrAreaSearch.svelte.d.ts +4 -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 +185 -34
- package/dist/components/ui/SearchAutocomplete.svelte.d.ts +5 -0
- package/dist/components/ui/Tabs.svelte +190 -18
- package/dist/components/ui/Tabs.svelte.d.ts +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +4 -1
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { scaleLinear } from "d3-scale";
|
|
3
|
+
import { bin, range as d3range } from "d3-array";
|
|
4
|
+
import chroma from "chroma-js";
|
|
3
5
|
import PositionChartAxis from "./PositionChartAxis.svelte";
|
|
4
6
|
import ValueLabel from "../line-chart/ValueLabel.svelte";
|
|
5
7
|
import Button from "../../ui/Button.svelte";
|
|
6
8
|
import InsetText from "../../content/InsetText.svelte";
|
|
9
|
+
import Axis from "../axis/Axis.svelte";
|
|
7
10
|
let {
|
|
8
11
|
value = undefined,
|
|
9
12
|
min = undefined,
|
|
10
13
|
max = undefined,
|
|
11
14
|
label = undefined,
|
|
12
15
|
showAxis = true,
|
|
16
|
+
showArrows = false,
|
|
17
|
+
showAverage = false,
|
|
13
18
|
chartWidth = $bindable(500), // the 'chart' is the bar and the marker
|
|
14
19
|
chartHeight = 24,
|
|
15
|
-
|
|
20
|
+
color = "#CA357C",
|
|
16
21
|
nSegments = 10,
|
|
17
22
|
startColor = "#8EB8DC",
|
|
18
23
|
endColor = "#0F385C",
|
|
19
24
|
midColor = undefined,
|
|
20
|
-
|
|
25
|
+
customColorScale = undefined,
|
|
21
26
|
opacity = 1,
|
|
22
27
|
annotation = undefined,
|
|
23
28
|
showIcon = false,
|
|
24
29
|
moreInfo = undefined,
|
|
25
30
|
markerRadius = chartHeight / 2,
|
|
31
|
+
numberOfTicks = undefined,
|
|
26
32
|
options = [],
|
|
27
33
|
rowData = [
|
|
28
34
|
{
|
|
29
35
|
value: value,
|
|
30
|
-
|
|
36
|
+
color: color,
|
|
31
37
|
opacity: opacity,
|
|
32
38
|
annotation: annotation,
|
|
33
39
|
},
|
|
@@ -79,10 +85,51 @@
|
|
|
79
85
|
activeMarkerId = null;
|
|
80
86
|
},
|
|
81
87
|
activeMarkerId = undefined,
|
|
88
|
+
distribution = [],
|
|
89
|
+
floor = undefined,
|
|
90
|
+
ceiling = undefined,
|
|
91
|
+
averageValue = undefined,
|
|
92
|
+
polarity = "standard",
|
|
93
|
+
skew = false,
|
|
94
|
+
showTickMarks = true,
|
|
95
|
+
showGridlines = false,
|
|
82
96
|
} = $props();
|
|
83
97
|
|
|
98
|
+
let xTicks = $state([]);
|
|
99
|
+
|
|
100
|
+
let xTickFirst = $derived(xTicks.length ? xTicks[0] : 0);
|
|
101
|
+
let xTickLast = $derived(xTicks.length ? xTicks.at(-1) : 1);
|
|
102
|
+
|
|
103
|
+
let domainMin = $derived(Math.min(xTickFirst, xTickLast));
|
|
104
|
+
let domainMax = $derived(Math.max(xTickFirst, xTickLast));
|
|
105
|
+
|
|
106
|
+
const segmentScale = $derived(
|
|
107
|
+
scaleLinear().domain([0, nSegments]).range([domainMin, domainMax]),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const binThresholds = $derived(d3range(1, nSegments).map(segmentScale));
|
|
111
|
+
|
|
112
|
+
const binner = $derived(
|
|
113
|
+
bin().domain([domainMin, domainMax]).thresholds(binThresholds),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const bins = $derived(
|
|
117
|
+
polarity === "reverse"
|
|
118
|
+
? binner(distribution).toReversed()
|
|
119
|
+
: binner(distribution),
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const proportionsInBins = $derived(
|
|
123
|
+
bins.map((b) => b.length / distribution.length),
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
let proportionInExtremeBins = $derived([
|
|
127
|
+
proportionsInBins[0],
|
|
128
|
+
proportionsInBins.at(-1),
|
|
129
|
+
]);
|
|
130
|
+
|
|
84
131
|
// base defaults that apply to every row
|
|
85
|
-
const baseRow = { value,
|
|
132
|
+
const baseRow = { value, color, opacity, annotation, markerRadius };
|
|
86
133
|
|
|
87
134
|
// base defaults that apply to every chart
|
|
88
135
|
const baseChart = { label, chartHeight, min, max, showAxis };
|
|
@@ -147,89 +194,51 @@
|
|
|
147
194
|
allDataNormalized.some((obj) => obj.divider !== undefined),
|
|
148
195
|
);
|
|
149
196
|
|
|
150
|
-
let gridTemplateRows = $derived(() => {
|
|
151
|
-
let rows = showAxis ? numberOfPositionCharts + 2 : numberOfPositionCharts;
|
|
152
|
-
if (open) rows += 1;
|
|
153
|
-
if (divider) rows += 1;
|
|
154
|
-
return `repeat(${rows}, auto)`;
|
|
155
|
-
});
|
|
156
197
|
const range = $derived(Array.from({ length: nSegments }, (_, i) => i));
|
|
157
198
|
|
|
158
|
-
function interpolateColors(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
r: (bigint >> 16) & 255,
|
|
171
|
-
g: (bigint >> 8) & 255,
|
|
172
|
-
b: bigint & 255,
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
// Convert RGB to hex
|
|
176
|
-
const rgbToHex = ({ r, g, b }) =>
|
|
177
|
-
"#" +
|
|
178
|
-
[r, g, b]
|
|
179
|
-
.map((x) => {
|
|
180
|
-
const hex = x.toString(16);
|
|
181
|
-
return hex.length === 1 ? "0" + hex : hex;
|
|
182
|
-
})
|
|
183
|
-
.join("");
|
|
184
|
-
// Helper: interpolate between two colors
|
|
185
|
-
const interpolate = (start, end, count) => {
|
|
186
|
-
const arr = [];
|
|
187
|
-
for (let i = 0; i < count; i++) {
|
|
188
|
-
const t = i / (count - 1);
|
|
189
|
-
const r = Math.round(start.r + (end.r - start.r) * t);
|
|
190
|
-
const g = Math.round(start.g + (end.g - start.g) * t);
|
|
191
|
-
const b = Math.round(start.b + (end.b - start.b) * t);
|
|
192
|
-
arr.push({ r, g, b });
|
|
193
|
-
}
|
|
194
|
-
return arr;
|
|
195
|
-
};
|
|
196
|
-
const start = hexToRgb(hex1);
|
|
197
|
-
const end = hexToRgb(hex2);
|
|
198
|
-
// Case 1: just two colors
|
|
199
|
-
if (!hexMid) {
|
|
200
|
-
return interpolate(start, end, steps).map(rgbToHex);
|
|
201
|
-
}
|
|
202
|
-
// Case 2: three colors
|
|
203
|
-
const mid = hexToRgb(hexMid);
|
|
204
|
-
const result = [];
|
|
205
|
-
if (steps % 2 === 1) {
|
|
206
|
-
// Odd steps → midpoint included
|
|
207
|
-
const half = (steps - 1) / 2;
|
|
208
|
-
const firstHalf = interpolate(start, mid, half + 1); // includes mid
|
|
209
|
-
const secondHalf = interpolate(mid, end, half + 1); // includes mid again
|
|
210
|
-
result.push(
|
|
211
|
-
...firstHalf.slice(0, -1).map(rgbToHex), // drop duplicate mid
|
|
212
|
-
...secondHalf.map(rgbToHex),
|
|
213
|
-
);
|
|
199
|
+
function interpolateColors(
|
|
200
|
+
startColor,
|
|
201
|
+
endColor,
|
|
202
|
+
nSegments,
|
|
203
|
+
midColor = null,
|
|
204
|
+
skew,
|
|
205
|
+
) {
|
|
206
|
+
const colorArray = [startColor, midColor, endColor].filter(Boolean);
|
|
207
|
+
|
|
208
|
+
if (!skew) {
|
|
209
|
+
return chroma.scale(colorArray).colors(nSegments);
|
|
214
210
|
} else {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
211
|
+
const extremeColors = chroma
|
|
212
|
+
.scale([startColor, midColor, endColor])
|
|
213
|
+
.padding([
|
|
214
|
+
proportionInExtremeBins[0] / 2,
|
|
215
|
+
proportionInExtremeBins[1] / 2,
|
|
216
|
+
])
|
|
217
|
+
.colors(2);
|
|
218
|
+
|
|
219
|
+
const averageNormalised =
|
|
220
|
+
(averageValue - xTickFirst) / (xTickLast - xTickFirst);
|
|
221
|
+
|
|
222
|
+
const binColors = chroma
|
|
223
|
+
.scale([extremeColors[0], midColor, extremeColors[1]])
|
|
224
|
+
.domain([0, averageNormalised, 1])
|
|
225
|
+
.colors(10);
|
|
226
|
+
|
|
227
|
+
return binColors;
|
|
223
228
|
}
|
|
224
|
-
return result;
|
|
225
229
|
}
|
|
226
230
|
|
|
231
|
+
let colorScale = $derived(
|
|
232
|
+
customColorScale ??
|
|
233
|
+
interpolateColors(startColor, endColor, nSegments, midColor, skew),
|
|
234
|
+
);
|
|
235
|
+
|
|
227
236
|
// the 'bar' is the 10 rectangles side by side
|
|
228
237
|
let barWidth = $derived(chartWidth - markerRadius * 2);
|
|
229
238
|
let barHeight = $derived((chartHeight * 5) / 6);
|
|
230
239
|
|
|
231
240
|
function xFunction(min, max) {
|
|
232
|
-
return scaleLinear().domain([min, max]).range([0, barWidth]);
|
|
241
|
+
return scaleLinear().domain([min, max]).range([0, barWidth]).clamp(true);
|
|
233
242
|
}
|
|
234
243
|
|
|
235
244
|
let annotations = $derived(
|
|
@@ -239,6 +248,30 @@
|
|
|
239
248
|
(d) => typeof d.annotation === "string" && d.annotation.length > 0,
|
|
240
249
|
),
|
|
241
250
|
);
|
|
251
|
+
|
|
252
|
+
let gridTemplateRows = $derived(
|
|
253
|
+
allDataNormalized
|
|
254
|
+
.map((item, i) => {
|
|
255
|
+
const sizes = ["minmax(0,1fr)"];
|
|
256
|
+
if (moreInfoTogglesArray[i]) sizes.push("minmax(0,auto)");
|
|
257
|
+
if (item.divider === "true") sizes.push("minmax(0,auto)");
|
|
258
|
+
return sizes.join(" "); // still fine because number of rows matches
|
|
259
|
+
})
|
|
260
|
+
.concat(showAxis ? ["minmax(0,auto)"] : [])
|
|
261
|
+
.join(" "),
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
function segmentIndex(value) {
|
|
265
|
+
return Math.max(
|
|
266
|
+
0,
|
|
267
|
+
Math.min(
|
|
268
|
+
nSegments - 1,
|
|
269
|
+
Math.floor(
|
|
270
|
+
(nSegments * (value - xTickFirst)) / (xTickLast - xTickFirst),
|
|
271
|
+
),
|
|
272
|
+
),
|
|
273
|
+
);
|
|
274
|
+
}
|
|
242
275
|
</script>
|
|
243
276
|
|
|
244
277
|
{#if annotations.length}
|
|
@@ -251,7 +284,7 @@
|
|
|
251
284
|
id="label"
|
|
252
285
|
x={d.value}
|
|
253
286
|
y="20"
|
|
254
|
-
fill={d.
|
|
287
|
+
fill={d.color}
|
|
255
288
|
font-size="18"
|
|
256
289
|
opacity={typeof activeMarkerId !== "undefined" && activeMarkerId
|
|
257
290
|
? 0.2
|
|
@@ -273,7 +306,7 @@
|
|
|
273
306
|
? 0.2
|
|
274
307
|
: 1}
|
|
275
308
|
>
|
|
276
|
-
<path d="M 0 0 L 6 3 L 0 6 z" fill={d.
|
|
309
|
+
<path d="M 0 0 L 6 3 L 0 6 z" fill={d.color}></path>
|
|
277
310
|
</marker>
|
|
278
311
|
</defs>
|
|
279
312
|
<path
|
|
@@ -282,7 +315,7 @@
|
|
|
282
315
|
4 +
|
|
283
316
|
(topWidth - chartWidth)} v 15"
|
|
284
317
|
fill="none"
|
|
285
|
-
stroke={d.
|
|
318
|
+
stroke={d.color}
|
|
286
319
|
stroke-width="1.5"
|
|
287
320
|
marker-end="url(#arrow-down)"
|
|
288
321
|
opacity={typeof activeMarkerId !== "undefined" && activeMarkerId
|
|
@@ -315,19 +348,27 @@
|
|
|
315
348
|
</p>
|
|
316
349
|
{/if}
|
|
317
350
|
{#if showIcon}
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
351
|
+
<div class="button-container">
|
|
352
|
+
<Button
|
|
353
|
+
textContent="i"
|
|
354
|
+
buttonType="moreInfo"
|
|
355
|
+
noPadding={true}
|
|
356
|
+
onClickFunction={() => updateMoreInfoTogglesArray(i)}
|
|
357
|
+
></Button>
|
|
358
|
+
</div>
|
|
324
359
|
{/if}
|
|
325
360
|
<div
|
|
326
361
|
class="chart"
|
|
327
|
-
style="height:
|
|
362
|
+
style="height:{chartHeight +
|
|
363
|
+
(showAxis ? 30 : 30) +
|
|
364
|
+
(showArrows ? 30 : 0) +
|
|
365
|
+
(showAverage ? 40 : 0)}px"
|
|
328
366
|
bind:clientWidth={chartWidth}
|
|
329
367
|
>
|
|
330
|
-
<svg
|
|
368
|
+
<svg
|
|
369
|
+
width={chartWidth}
|
|
370
|
+
height={chartHeight + (showAxis ? 40 : 0) + (showAverage ? 40 : 0)}
|
|
371
|
+
>
|
|
331
372
|
{#each range as number}
|
|
332
373
|
<g
|
|
333
374
|
transform="translate({markerRadius +
|
|
@@ -337,11 +378,7 @@
|
|
|
337
378
|
><rect
|
|
338
379
|
width={barWidth / nSegments}
|
|
339
380
|
height={barHeight}
|
|
340
|
-
fill={colorScale
|
|
341
|
-
? colorScale[number]
|
|
342
|
-
: interpolateColors(startColor, endColor, nSegments, midColor)[
|
|
343
|
-
number
|
|
344
|
-
]}
|
|
381
|
+
fill={colorScale[number]}
|
|
345
382
|
></rect></g
|
|
346
383
|
>{/each}
|
|
347
384
|
{#each Object.entries(positionChart.rowData) as [tier, points]}
|
|
@@ -372,30 +409,105 @@
|
|
|
372
409
|
: null}
|
|
373
410
|
pointer-events={interactiveMarkers ? null : "none"}
|
|
374
411
|
transform="translate({xFunction(
|
|
375
|
-
|
|
376
|
-
|
|
412
|
+
xTickFirst,
|
|
413
|
+
xTickLast,
|
|
377
414
|
)(rowValue.value) + markerRadius},{positionChart.chartHeight /
|
|
378
415
|
2})"
|
|
379
416
|
>
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
417
|
+
{#if rowValue.shape === "line"}
|
|
418
|
+
<line
|
|
419
|
+
x1={0}
|
|
420
|
+
x2={0}
|
|
421
|
+
y1={chartHeight / 2.4}
|
|
422
|
+
y2={-chartHeight / 2.4}
|
|
423
|
+
stroke={rowValue.color === "inherit"
|
|
424
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
425
|
+
: rowValue.color}
|
|
426
|
+
stroke-width={rowValue.markerRadius}
|
|
427
|
+
opacity={rowValue.opacity}
|
|
428
|
+
pointer-events={rowValue.pointerEvents}
|
|
429
|
+
></line>
|
|
430
|
+
{:else}
|
|
431
|
+
<circle
|
|
432
|
+
r={rowValue.markerRadius}
|
|
433
|
+
cx="0"
|
|
434
|
+
cy="0"
|
|
435
|
+
stroke="white"
|
|
436
|
+
fill={rowValue.color === "inherit"
|
|
437
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
438
|
+
: rowValue.color}
|
|
439
|
+
stroke-width={3}
|
|
440
|
+
opacity={rowValue.opacity}
|
|
441
|
+
></circle>
|
|
442
|
+
<circle
|
|
443
|
+
r={rowValue.markerRadius * 0.9}
|
|
444
|
+
cx="0"
|
|
445
|
+
cy="0"
|
|
446
|
+
fill={rowValue.color === "inherit"
|
|
447
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
448
|
+
: rowValue.color}
|
|
449
|
+
stroke="black"
|
|
450
|
+
stroke-width={1.5}
|
|
451
|
+
opacity={rowValue.opacity}
|
|
452
|
+
></circle>
|
|
453
|
+
{/if}
|
|
388
454
|
</g>
|
|
389
455
|
{/if}
|
|
390
456
|
{/each}
|
|
391
457
|
{/each}
|
|
458
|
+
{#if showAxis}
|
|
459
|
+
<Axis
|
|
460
|
+
bind:ticksArray={xTicks}
|
|
461
|
+
{chartHeight}
|
|
462
|
+
chartWidth={chartWidth - markerRadius * 2}
|
|
463
|
+
orientation={{ axis: "x", position: "bottom" }}
|
|
464
|
+
range={[markerRadius, chartWidth - markerRadius]}
|
|
465
|
+
domain={[xTickFirst, xTickLast]}
|
|
466
|
+
{min}
|
|
467
|
+
{max}
|
|
468
|
+
fontSize={14}
|
|
469
|
+
{floor}
|
|
470
|
+
{ceiling}
|
|
471
|
+
{numberOfTicks}
|
|
472
|
+
{polarity}
|
|
473
|
+
{showTickMarks}
|
|
474
|
+
{showGridlines}
|
|
475
|
+
></Axis>
|
|
476
|
+
{/if}
|
|
477
|
+
{#if showAverage}
|
|
478
|
+
<g
|
|
479
|
+
transform="translate({xFunction(
|
|
480
|
+
xTickFirst,
|
|
481
|
+
xTickLast,
|
|
482
|
+
)(averageValue) + markerRadius}, {chartHeight * 1.7})"
|
|
483
|
+
>
|
|
484
|
+
<text
|
|
485
|
+
fill="#444"
|
|
486
|
+
font-size={15}
|
|
487
|
+
text-anchor="middle"
|
|
488
|
+
font-weight="bold"
|
|
489
|
+
>
|
|
490
|
+
<tspan x="1" dy="15">▲</tspan>
|
|
491
|
+
<tspan x="1" dy="4">|</tspan>
|
|
492
|
+
<tspan font-family="GDS Transport" x="1" dy="13">Average</tspan>
|
|
493
|
+
</text>
|
|
494
|
+
</g>
|
|
495
|
+
{/if}
|
|
392
496
|
</svg>
|
|
497
|
+
{#if showArrows}
|
|
498
|
+
<PositionChartAxis
|
|
499
|
+
markerRadius={10}
|
|
500
|
+
barWidth={chartWidth}
|
|
501
|
+
textSize="xs"
|
|
502
|
+
{chartWidth}
|
|
503
|
+
axisLabels={["Worse than average", "Better than average"]}
|
|
504
|
+
></PositionChartAxis>
|
|
505
|
+
{/if}
|
|
393
506
|
</div>
|
|
394
507
|
{#if moreInfoTogglesArray[i]}
|
|
395
|
-
<div class="accordion" style="grid-column:1 / -1
|
|
396
|
-
<
|
|
397
|
-
|
|
398
|
-
></InsetText> -->
|
|
508
|
+
<div class="accordion" style="grid-column:1 / -1">
|
|
509
|
+
<InsetText content={positionChart.moreInfo} renderStringAsHTML={true}
|
|
510
|
+
></InsetText>
|
|
399
511
|
</div>
|
|
400
512
|
{/if}
|
|
401
513
|
{#if positionChart.divider}
|
|
@@ -420,9 +532,6 @@
|
|
|
420
532
|
{#if showLabel}
|
|
421
533
|
<div class="empty"></div>
|
|
422
534
|
{/if}
|
|
423
|
-
<div class="axis">
|
|
424
|
-
<PositionChartAxis {markerRadius} {barWidth}></PositionChartAxis>
|
|
425
|
-
</div>
|
|
426
535
|
{/if}
|
|
427
536
|
{#if activeMarkerId}
|
|
428
537
|
<ValueLabel
|
|
@@ -448,14 +557,13 @@
|
|
|
448
557
|
-moz-column-gap: 2%;
|
|
449
558
|
column-gap: 2%;
|
|
450
559
|
row-gap: 2%;
|
|
560
|
+
overflow: visible;
|
|
451
561
|
}
|
|
452
562
|
.chart {
|
|
453
563
|
display: flex;
|
|
454
564
|
flex-direction: column;
|
|
455
565
|
justify-content: flex-end;
|
|
456
566
|
min-width: 0;
|
|
457
|
-
|
|
458
|
-
.accordion {
|
|
459
|
-
max-height: 500px !important; /* large enough to fit content */
|
|
567
|
+
overflow: visible;
|
|
460
568
|
}
|
|
461
569
|
</style>
|
|
@@ -9,19 +9,22 @@ declare const PositionChart: import("svelte").Component<{
|
|
|
9
9
|
max?: any;
|
|
10
10
|
label?: any;
|
|
11
11
|
showAxis?: boolean;
|
|
12
|
+
showArrows?: boolean;
|
|
13
|
+
showAverage?: boolean;
|
|
12
14
|
chartWidth?: number;
|
|
13
15
|
chartHeight?: number;
|
|
14
|
-
|
|
16
|
+
color?: string;
|
|
15
17
|
nSegments?: number;
|
|
16
18
|
startColor?: string;
|
|
17
19
|
endColor?: string;
|
|
18
20
|
midColor?: any;
|
|
19
|
-
|
|
21
|
+
customColorScale?: any;
|
|
20
22
|
opacity?: number;
|
|
21
23
|
annotation?: any;
|
|
22
24
|
showIcon?: boolean;
|
|
23
25
|
moreInfo?: any;
|
|
24
26
|
markerRadius?: any;
|
|
27
|
+
numberOfTicks?: any;
|
|
25
28
|
options?: any[];
|
|
26
29
|
rowData?: any[];
|
|
27
30
|
allData?: any[];
|
|
@@ -42,6 +45,14 @@ declare const PositionChart: import("svelte").Component<{
|
|
|
42
45
|
onMouseEnterMarker?: Function;
|
|
43
46
|
onMouseLeaveMarker?: Function;
|
|
44
47
|
activeMarkerId?: any;
|
|
48
|
+
distribution?: any[];
|
|
49
|
+
floor?: any;
|
|
50
|
+
ceiling?: any;
|
|
51
|
+
averageValue?: any;
|
|
52
|
+
polarity?: string;
|
|
53
|
+
skew?: boolean;
|
|
54
|
+
showTickMarks?: boolean;
|
|
55
|
+
showGridlines?: boolean;
|
|
45
56
|
}, {}, "chartWidth">;
|
|
46
57
|
type $$ComponentProps = {
|
|
47
58
|
value?: any;
|
|
@@ -49,19 +60,22 @@ type $$ComponentProps = {
|
|
|
49
60
|
max?: any;
|
|
50
61
|
label?: any;
|
|
51
62
|
showAxis?: boolean;
|
|
63
|
+
showArrows?: boolean;
|
|
64
|
+
showAverage?: boolean;
|
|
52
65
|
chartWidth?: number;
|
|
53
66
|
chartHeight?: number;
|
|
54
|
-
|
|
67
|
+
color?: string;
|
|
55
68
|
nSegments?: number;
|
|
56
69
|
startColor?: string;
|
|
57
70
|
endColor?: string;
|
|
58
71
|
midColor?: any;
|
|
59
|
-
|
|
72
|
+
customColorScale?: any;
|
|
60
73
|
opacity?: number;
|
|
61
74
|
annotation?: any;
|
|
62
75
|
showIcon?: boolean;
|
|
63
76
|
moreInfo?: any;
|
|
64
77
|
markerRadius?: any;
|
|
78
|
+
numberOfTicks?: any;
|
|
65
79
|
options?: any[];
|
|
66
80
|
rowData?: any[];
|
|
67
81
|
allData?: any[];
|
|
@@ -82,4 +96,12 @@ type $$ComponentProps = {
|
|
|
82
96
|
onMouseEnterMarker?: Function;
|
|
83
97
|
onMouseLeaveMarker?: Function;
|
|
84
98
|
activeMarkerId?: any;
|
|
99
|
+
distribution?: any[];
|
|
100
|
+
floor?: any;
|
|
101
|
+
ceiling?: any;
|
|
102
|
+
averageValue?: any;
|
|
103
|
+
polarity?: string;
|
|
104
|
+
skew?: boolean;
|
|
105
|
+
showTickMarks?: boolean;
|
|
106
|
+
showGridlines?: boolean;
|
|
85
107
|
};
|
|
@@ -1,70 +1,74 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
let {
|
|
2
|
+
let {
|
|
3
|
+
markerRadius = undefined,
|
|
4
|
+
textSize = "s",
|
|
5
|
+
chartWidth,
|
|
6
|
+
axisLabels = ["Left", "Right"],
|
|
7
|
+
} = $props();
|
|
3
8
|
</script>
|
|
4
9
|
|
|
5
|
-
<div
|
|
6
|
-
|
|
10
|
+
<div
|
|
11
|
+
class="axis govuk-body-{textSize}"
|
|
12
|
+
style="--axis-padding:{markerRadius}px; width: {chartWidth}"
|
|
13
|
+
>
|
|
14
|
+
<div class="right-label">
|
|
7
15
|
<svg
|
|
8
16
|
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
-
width="
|
|
17
|
+
width="18"
|
|
10
18
|
height="16"
|
|
11
|
-
viewBox="0 0 11
|
|
19
|
+
viewBox="0 0 11 20"
|
|
12
20
|
fill="none"
|
|
13
21
|
>
|
|
14
22
|
<path
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
transform="translate(20,21)rotate(180)"
|
|
24
|
+
d="M 19.7071 12.7071 C 20.0976 12.3166 20.0976 11.6834 19.7071 11.2929 L 13.3431 4.9289 C 12.9526 4.5384 12.3195 4.5384 11.9289 4.9289 C 11.5384 5.3195 11.5384 5.9526 11.9289 6.3431 L 17.5858 12 L 11.9289 17.6568 C 11.5384 18.0474 11.5384 18.6805 11.9289 19.0711 C 12.3195 19.4616 12.9526 19.4616 13.3431 19.0711 L 19.7071 12.7071 Z M 4 12 L 4 13 L 19 13 L 19 12 L 19 11 L 9 11 L 4 11 Z"
|
|
25
|
+
fill="darkgrey"
|
|
17
26
|
></path>
|
|
18
27
|
</svg>
|
|
19
|
-
<span
|
|
28
|
+
<span class="axis-text">{axisLabels[0]}</span>
|
|
20
29
|
</div>
|
|
21
|
-
<div class="
|
|
22
|
-
<span
|
|
30
|
+
<div class="left-label">
|
|
31
|
+
<span class="axis-text">{axisLabels[1]}</span>
|
|
23
32
|
<svg
|
|
24
33
|
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
-
width="
|
|
34
|
+
width="18"
|
|
26
35
|
height="16"
|
|
27
|
-
viewBox="0 0
|
|
36
|
+
viewBox="0 0 11 20"
|
|
28
37
|
fill="none"
|
|
29
38
|
>
|
|
30
39
|
<path
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
transform="translate(-5,-3)"
|
|
41
|
+
d="M 19.7071 12.7071 C 20.0976 12.3166 20.0976 11.6834 19.7071 11.2929 L 13.3431 4.9289 C 12.9526 4.5384 12.3195 4.5384 11.9289 4.9289 C 11.5384 5.3195 11.5384 5.9526 11.9289 6.3431 L 17.5858 12 L 11.9289 17.6568 C 11.5384 18.0474 11.5384 18.6805 11.9289 19.0711 C 12.3195 19.4616 12.9526 19.4616 13.3431 19.0711 L 19.7071 12.7071 Z M 4 12 L 4 13 L 19 13 L 19 12 L 19 11 L 9 11 L 4 11 Z"
|
|
42
|
+
fill="darkgrey"
|
|
33
43
|
></path>
|
|
34
44
|
</svg>
|
|
35
45
|
</div>
|
|
36
46
|
</div>
|
|
37
47
|
|
|
38
48
|
<style>
|
|
49
|
+
svg {
|
|
50
|
+
overflow: visible;
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
.axis {
|
|
40
54
|
display: flex;
|
|
41
55
|
justify-content: space-between;
|
|
42
|
-
align-items: center;
|
|
43
|
-
padding: 0 var(--axis-padding);
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
.
|
|
47
|
-
.
|
|
58
|
+
.left-label,
|
|
59
|
+
.right-label {
|
|
48
60
|
display: flex;
|
|
49
|
-
|
|
50
|
-
gap: 5px;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* Tell the parent to act as a container */
|
|
54
|
-
.axis {
|
|
55
|
-
container-type: inline-size;
|
|
61
|
+
max-width: 120px;
|
|
56
62
|
}
|
|
57
63
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.less-deprived {
|
|
61
|
-
display: none;
|
|
62
|
-
}
|
|
64
|
+
.left-label {
|
|
65
|
+
text-align: end;
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
.axis-text {
|
|
69
|
+
font-family: "GDS Transport";
|
|
70
|
+
line-height: 0.9;
|
|
71
|
+
color: #666666;
|
|
72
|
+
font-style: italic;
|
|
69
73
|
}
|
|
70
74
|
</style>
|
|
@@ -5,9 +5,13 @@ type PositionChartAxis = {
|
|
|
5
5
|
};
|
|
6
6
|
declare const PositionChartAxis: import("svelte").Component<{
|
|
7
7
|
markerRadius?: any;
|
|
8
|
-
|
|
8
|
+
textSize?: string;
|
|
9
|
+
chartWidth: any;
|
|
10
|
+
axisLabels?: any[];
|
|
9
11
|
}, {}, "">;
|
|
10
12
|
type $$ComponentProps = {
|
|
11
13
|
markerRadius?: any;
|
|
12
|
-
|
|
14
|
+
textSize?: string;
|
|
15
|
+
chartWidth: any;
|
|
16
|
+
axisLabels?: any[];
|
|
13
17
|
};
|