@communitiesuk/svelte-component-library 0.1.19-beta.3 → 0.1.19-beta.34
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 +287 -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 +279 -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/data-vis/table/Table.svelte +145 -95
- package/dist/components/data-vis/table/Table.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/Accordion.svelte +212 -66
- package/dist/components/ui/Accordion.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 +220 -104
- package/dist/components/ui/Button.svelte.d.ts +4 -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,40 @@
|
|
|
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
|
+
arrowTextSize = "s",
|
|
18
|
+
showAverage = false,
|
|
13
19
|
chartWidth = $bindable(500), // the 'chart' is the bar and the marker
|
|
14
20
|
chartHeight = 24,
|
|
15
|
-
|
|
21
|
+
color = "#CA357C",
|
|
16
22
|
nSegments = 10,
|
|
17
23
|
startColor = "#8EB8DC",
|
|
18
24
|
endColor = "#0F385C",
|
|
19
25
|
midColor = undefined,
|
|
20
|
-
|
|
26
|
+
customColorScale = undefined,
|
|
21
27
|
opacity = 1,
|
|
22
28
|
annotation = undefined,
|
|
23
29
|
showIcon = false,
|
|
24
30
|
moreInfo = undefined,
|
|
25
31
|
markerRadius = chartHeight / 2,
|
|
32
|
+
numberOfTicks = undefined,
|
|
26
33
|
options = [],
|
|
27
34
|
rowData = [
|
|
28
35
|
{
|
|
29
36
|
value: value,
|
|
30
|
-
|
|
37
|
+
color: color,
|
|
31
38
|
opacity: opacity,
|
|
32
39
|
annotation: annotation,
|
|
33
40
|
},
|
|
@@ -79,10 +86,58 @@
|
|
|
79
86
|
activeMarkerId = null;
|
|
80
87
|
},
|
|
81
88
|
activeMarkerId = undefined,
|
|
89
|
+
distribution = [],
|
|
90
|
+
floor = undefined,
|
|
91
|
+
ceiling = undefined,
|
|
92
|
+
averageValue = undefined,
|
|
93
|
+
polarity = "standard",
|
|
94
|
+
skew = false,
|
|
95
|
+
showTickMarks = true,
|
|
96
|
+
showGridlines = false,
|
|
97
|
+
labelFormatter = (tick, index, ticksArrayLength) => {
|
|
98
|
+
return tick;
|
|
99
|
+
},
|
|
100
|
+
niceTicks = true,
|
|
101
|
+
ticksDomain = $bindable([[]]),
|
|
102
|
+
axisDomain = $bindable([[]]),
|
|
82
103
|
} = $props();
|
|
83
104
|
|
|
105
|
+
let xTickFirst = $derived(ticksDomain.length ? ticksDomain[0] : 0);
|
|
106
|
+
let xTickLast = $derived(ticksDomain.length ? ticksDomain.at(-1) : 1);
|
|
107
|
+
|
|
108
|
+
let domainMin = $derived(Math.min(...axisDomain));
|
|
109
|
+
let domainMax = $derived(Math.max(...axisDomain));
|
|
110
|
+
let chartDomain = $derived(
|
|
111
|
+
polarity === "standard" ? [domainMin, domainMax] : [domainMax, domainMin],
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const segmentScale = $derived(
|
|
115
|
+
scaleLinear().domain([0, nSegments]).range([domainMin, domainMax]),
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const binThresholds = $derived(d3range(1, nSegments).map(segmentScale));
|
|
119
|
+
|
|
120
|
+
const binner = $derived(
|
|
121
|
+
bin().domain([domainMin, domainMax]).thresholds(binThresholds),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const bins = $derived(
|
|
125
|
+
polarity === "reverse"
|
|
126
|
+
? binner(distribution).toReversed()
|
|
127
|
+
: binner(distribution),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const proportionsInBins = $derived(
|
|
131
|
+
bins.map((b) => b.length / distribution.length),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
let proportionInExtremeBins = $derived([
|
|
135
|
+
proportionsInBins[0],
|
|
136
|
+
proportionsInBins.at(-1),
|
|
137
|
+
]);
|
|
138
|
+
|
|
84
139
|
// base defaults that apply to every row
|
|
85
|
-
const baseRow = { value,
|
|
140
|
+
const baseRow = { value, color, opacity, annotation, markerRadius };
|
|
86
141
|
|
|
87
142
|
// base defaults that apply to every chart
|
|
88
143
|
const baseChart = { label, chartHeight, min, max, showAxis };
|
|
@@ -147,89 +202,51 @@
|
|
|
147
202
|
allDataNormalized.some((obj) => obj.divider !== undefined),
|
|
148
203
|
);
|
|
149
204
|
|
|
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
205
|
const range = $derived(Array.from({ length: nSegments }, (_, i) => i));
|
|
157
206
|
|
|
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
|
-
);
|
|
207
|
+
function interpolateColors(
|
|
208
|
+
startColor,
|
|
209
|
+
endColor,
|
|
210
|
+
nSegments,
|
|
211
|
+
midColor = null,
|
|
212
|
+
skew,
|
|
213
|
+
) {
|
|
214
|
+
const colorArray = [startColor, midColor, endColor].filter(Boolean);
|
|
215
|
+
|
|
216
|
+
if (!skew) {
|
|
217
|
+
return chroma.scale(colorArray).colors(nSegments);
|
|
214
218
|
} else {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
const extremeColors = chroma
|
|
220
|
+
.scale([startColor, midColor, endColor])
|
|
221
|
+
.padding([
|
|
222
|
+
proportionInExtremeBins[0] / 2,
|
|
223
|
+
proportionInExtremeBins[1] / 2,
|
|
224
|
+
])
|
|
225
|
+
.colors(2);
|
|
226
|
+
|
|
227
|
+
const averageNormalised =
|
|
228
|
+
(averageValue - xTickFirst) / (xTickLast - xTickFirst);
|
|
229
|
+
|
|
230
|
+
const binColors = chroma
|
|
231
|
+
.scale([extremeColors[0], midColor, extremeColors[1]])
|
|
232
|
+
.domain([0, averageNormalised, 1])
|
|
233
|
+
.colors(10);
|
|
234
|
+
|
|
235
|
+
return binColors;
|
|
223
236
|
}
|
|
224
|
-
return result;
|
|
225
237
|
}
|
|
226
238
|
|
|
239
|
+
let colorScale = $derived(
|
|
240
|
+
customColorScale ??
|
|
241
|
+
interpolateColors(startColor, endColor, nSegments, midColor, skew),
|
|
242
|
+
);
|
|
243
|
+
|
|
227
244
|
// the 'bar' is the 10 rectangles side by side
|
|
228
245
|
let barWidth = $derived(chartWidth - markerRadius * 2);
|
|
229
246
|
let barHeight = $derived((chartHeight * 5) / 6);
|
|
230
247
|
|
|
231
|
-
function xFunction(
|
|
232
|
-
return scaleLinear().domain(
|
|
248
|
+
function xFunction(chartDomain) {
|
|
249
|
+
return scaleLinear().domain(chartDomain).range([0, barWidth]).clamp(true);
|
|
233
250
|
}
|
|
234
251
|
|
|
235
252
|
let annotations = $derived(
|
|
@@ -239,6 +256,41 @@
|
|
|
239
256
|
(d) => typeof d.annotation === "string" && d.annotation.length > 0,
|
|
240
257
|
),
|
|
241
258
|
);
|
|
259
|
+
|
|
260
|
+
let gridTemplateRows = $derived(
|
|
261
|
+
allDataNormalized
|
|
262
|
+
.map((item, i) => {
|
|
263
|
+
const sizes = ["minmax(0,1fr)"];
|
|
264
|
+
if (moreInfoTogglesArray[i]) sizes.push("minmax(0,auto)");
|
|
265
|
+
if (item.divider === "true") sizes.push("minmax(0,auto)");
|
|
266
|
+
return sizes.join(" "); // still fine because number of rows matches
|
|
267
|
+
})
|
|
268
|
+
.concat(showAxis ? ["minmax(0,auto)"] : [])
|
|
269
|
+
.join(" "),
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
function segmentIndex(value) {
|
|
273
|
+
return Math.max(
|
|
274
|
+
0,
|
|
275
|
+
Math.min(
|
|
276
|
+
nSegments - 1,
|
|
277
|
+
Math.floor(
|
|
278
|
+
(nSegments * (value - xTickFirst)) / (xTickLast - xTickFirst),
|
|
279
|
+
),
|
|
280
|
+
),
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
let totalHeight = $derived(
|
|
285
|
+
chartHeight +
|
|
286
|
+
(showAxis ? 25 : 0) +
|
|
287
|
+
(showAverage ? 35 : 0) +
|
|
288
|
+
(showArrows ? 25 : 0),
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
let svgHeight = $derived(
|
|
292
|
+
chartHeight + (showAxis ? 25 : 0) + (showAverage ? 35 : 0),
|
|
293
|
+
);
|
|
242
294
|
</script>
|
|
243
295
|
|
|
244
296
|
{#if annotations.length}
|
|
@@ -251,7 +303,7 @@
|
|
|
251
303
|
id="label"
|
|
252
304
|
x={d.value}
|
|
253
305
|
y="20"
|
|
254
|
-
fill={d.
|
|
306
|
+
fill={d.color}
|
|
255
307
|
font-size="18"
|
|
256
308
|
opacity={typeof activeMarkerId !== "undefined" && activeMarkerId
|
|
257
309
|
? 0.2
|
|
@@ -273,16 +325,16 @@
|
|
|
273
325
|
? 0.2
|
|
274
326
|
: 1}
|
|
275
327
|
>
|
|
276
|
-
<path d="M 0 0 L 6 3 L 0 6 z" fill={d.
|
|
328
|
+
<path d="M 0 0 L 6 3 L 0 6 z" fill={d.color}></path>
|
|
277
329
|
</marker>
|
|
278
330
|
</defs>
|
|
279
331
|
<path
|
|
280
|
-
d="M 4 25 v 10 h {xFunction(
|
|
332
|
+
d="M 4 25 v 10 h {xFunction(chartDomain)(d.value) +
|
|
281
333
|
markerRadius -
|
|
282
334
|
4 +
|
|
283
335
|
(topWidth - chartWidth)} v 15"
|
|
284
336
|
fill="none"
|
|
285
|
-
stroke={d.
|
|
337
|
+
stroke={d.color}
|
|
286
338
|
stroke-width="1.5"
|
|
287
339
|
marker-end="url(#arrow-down)"
|
|
288
340
|
opacity={typeof activeMarkerId !== "undefined" && activeMarkerId
|
|
@@ -298,9 +350,10 @@
|
|
|
298
350
|
class="grid-container"
|
|
299
351
|
bind:this={container}
|
|
300
352
|
style="
|
|
301
|
-
|
|
353
|
+
position: relative;
|
|
302
354
|
grid-template-columns: {gridTemplateColumns};
|
|
303
355
|
grid-template-rows: {gridTemplateRows};
|
|
356
|
+
height: {totalHeight}px;
|
|
304
357
|
"
|
|
305
358
|
>
|
|
306
359
|
{#each allDataNormalized as positionChart, i}
|
|
@@ -315,19 +368,17 @@
|
|
|
315
368
|
</p>
|
|
316
369
|
{/if}
|
|
317
370
|
{#if showIcon}
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
371
|
+
<div class="button-container">
|
|
372
|
+
<Button
|
|
373
|
+
textContent="i"
|
|
374
|
+
buttonType="moreInfo"
|
|
375
|
+
noPadding={true}
|
|
376
|
+
onClickFunction={() => updateMoreInfoTogglesArray(i)}
|
|
377
|
+
></Button>
|
|
378
|
+
</div>
|
|
324
379
|
{/if}
|
|
325
|
-
<div
|
|
326
|
-
|
|
327
|
-
style="height: {positionChart.chartHeight}px"
|
|
328
|
-
bind:clientWidth={chartWidth}
|
|
329
|
-
>
|
|
330
|
-
<svg width={chartWidth} height={positionChart.chartHeight}>
|
|
380
|
+
<div class="chart" bind:clientWidth={chartWidth}>
|
|
381
|
+
<svg width={chartWidth} height={svgHeight} overflow="visible">
|
|
331
382
|
{#each range as number}
|
|
332
383
|
<g
|
|
333
384
|
transform="translate({markerRadius +
|
|
@@ -337,13 +388,33 @@
|
|
|
337
388
|
><rect
|
|
338
389
|
width={barWidth / nSegments}
|
|
339
390
|
height={barHeight}
|
|
340
|
-
fill={colorScale
|
|
341
|
-
? colorScale[number]
|
|
342
|
-
: interpolateColors(startColor, endColor, nSegments, midColor)[
|
|
343
|
-
number
|
|
344
|
-
]}
|
|
391
|
+
fill={colorScale[number]}
|
|
345
392
|
></rect></g
|
|
346
393
|
>{/each}
|
|
394
|
+
{#if showAxis}
|
|
395
|
+
<Axis
|
|
396
|
+
bind:axisDomain
|
|
397
|
+
bind:ticksArray={ticksDomain}
|
|
398
|
+
{chartHeight}
|
|
399
|
+
chartWidth={chartWidth - markerRadius * 2}
|
|
400
|
+
orientation={{ axis: "x", position: "bottom" }}
|
|
401
|
+
range={[markerRadius, chartWidth - markerRadius]}
|
|
402
|
+
domain={[xTickFirst, xTickLast]}
|
|
403
|
+
{min}
|
|
404
|
+
{max}
|
|
405
|
+
fontSize={14}
|
|
406
|
+
{floor}
|
|
407
|
+
{ceiling}
|
|
408
|
+
{numberOfTicks}
|
|
409
|
+
{polarity}
|
|
410
|
+
{showTickMarks}
|
|
411
|
+
{showGridlines}
|
|
412
|
+
{labelFormatter}
|
|
413
|
+
{niceTicks}
|
|
414
|
+
{markerRadius}
|
|
415
|
+
{distribution}
|
|
416
|
+
></Axis>
|
|
417
|
+
{/if}
|
|
347
418
|
{#each Object.entries(positionChart.rowData) as [tier, points]}
|
|
348
419
|
{#each points as rowValue, i}
|
|
349
420
|
{#if !isNaN(Number(rowValue.value))}
|
|
@@ -371,31 +442,94 @@
|
|
|
371
442
|
? (e) => e.key === "Enter" && onClickMarker(e, value)
|
|
372
443
|
: null}
|
|
373
444
|
pointer-events={interactiveMarkers ? null : "none"}
|
|
374
|
-
transform="translate({xFunction(
|
|
375
|
-
positionChart.
|
|
376
|
-
positionChart.max,
|
|
377
|
-
)(rowValue.value) + markerRadius},{positionChart.chartHeight /
|
|
378
|
-
2})"
|
|
445
|
+
transform="translate({xFunction(chartDomain)(rowValue.value) +
|
|
446
|
+
markerRadius},{positionChart.chartHeight / 2})"
|
|
379
447
|
>
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
448
|
+
{#if rowValue.shape === "line"}
|
|
449
|
+
<line
|
|
450
|
+
x1={0}
|
|
451
|
+
x2={0}
|
|
452
|
+
y1={chartHeight / 1.5}
|
|
453
|
+
y2={-chartHeight / 1.5}
|
|
454
|
+
stroke={rowValue.color === "inherit"
|
|
455
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
456
|
+
: rowValue.color}
|
|
457
|
+
stroke-width={rowValue.markerRadius * 7}
|
|
458
|
+
opacity={0}
|
|
459
|
+
pointer-events={rowValue.pointerEvents}
|
|
460
|
+
></line>
|
|
461
|
+
<line
|
|
462
|
+
x1={0}
|
|
463
|
+
x2={0}
|
|
464
|
+
y1={chartHeight / 2.4}
|
|
465
|
+
y2={-chartHeight / 2.4}
|
|
466
|
+
stroke={rowValue.color === "inherit"
|
|
467
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
468
|
+
: rowValue.color}
|
|
469
|
+
stroke-width={rowValue.markerRadius}
|
|
470
|
+
opacity={rowValue.opacity}
|
|
471
|
+
pointer-events="none"
|
|
472
|
+
></line>
|
|
473
|
+
{:else}
|
|
474
|
+
<circle
|
|
475
|
+
r={rowValue.markerRadius}
|
|
476
|
+
cx="0"
|
|
477
|
+
cy="0"
|
|
478
|
+
stroke="white"
|
|
479
|
+
fill={rowValue.color === "inherit"
|
|
480
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
481
|
+
: rowValue.color}
|
|
482
|
+
stroke-width={5}
|
|
483
|
+
opacity={rowValue.opacity}
|
|
484
|
+
></circle>
|
|
485
|
+
<circle
|
|
486
|
+
r={rowValue.markerRadius * 0.9}
|
|
487
|
+
cx="0"
|
|
488
|
+
cy="0"
|
|
489
|
+
fill={rowValue.color === "inherit"
|
|
490
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
491
|
+
: rowValue.color}
|
|
492
|
+
stroke="#111"
|
|
493
|
+
stroke-width={3}
|
|
494
|
+
opacity={rowValue.opacity}
|
|
495
|
+
></circle>
|
|
496
|
+
{/if}
|
|
388
497
|
</g>
|
|
389
498
|
{/if}
|
|
390
499
|
{/each}
|
|
391
500
|
{/each}
|
|
501
|
+
|
|
502
|
+
{#if showAverage}
|
|
503
|
+
<g
|
|
504
|
+
transform="translate({xFunction(chartDomain)(averageValue) +
|
|
505
|
+
markerRadius}, {chartHeight + (showAxis ? 20 : 0)})"
|
|
506
|
+
>
|
|
507
|
+
<text
|
|
508
|
+
fill="#444"
|
|
509
|
+
font-size={15}
|
|
510
|
+
text-anchor="middle"
|
|
511
|
+
font-weight="bold"
|
|
512
|
+
>
|
|
513
|
+
<tspan x="1" dy="15">▲</tspan>
|
|
514
|
+
<tspan x="1" dy="4">|</tspan>
|
|
515
|
+
<tspan font-family="GDS Transport" x="1" dy="13">Average</tspan>
|
|
516
|
+
</text>
|
|
517
|
+
</g>
|
|
518
|
+
{/if}
|
|
392
519
|
</svg>
|
|
520
|
+
{#if showArrows}
|
|
521
|
+
<div class="axis-container" style="margin: 0px {markerRadius}px">
|
|
522
|
+
<PositionChartAxis
|
|
523
|
+
textSize={arrowTextSize}
|
|
524
|
+
axisLabels={["Worse than average", "Better than average"]}
|
|
525
|
+
></PositionChartAxis>
|
|
526
|
+
</div>
|
|
527
|
+
{/if}
|
|
393
528
|
</div>
|
|
394
529
|
{#if moreInfoTogglesArray[i]}
|
|
395
|
-
<div class="accordion" style="grid-column:1 / -1
|
|
396
|
-
<
|
|
397
|
-
|
|
398
|
-
></InsetText> -->
|
|
530
|
+
<div class="accordion" style="grid-column:1 / -1">
|
|
531
|
+
<InsetText content={positionChart.moreInfo} renderStringAsHTML={true}
|
|
532
|
+
></InsetText>
|
|
399
533
|
</div>
|
|
400
534
|
{/if}
|
|
401
535
|
{#if positionChart.divider}
|
|
@@ -420,9 +554,6 @@
|
|
|
420
554
|
{#if showLabel}
|
|
421
555
|
<div class="empty"></div>
|
|
422
556
|
{/if}
|
|
423
|
-
<div class="axis">
|
|
424
|
-
<PositionChartAxis {markerRadius} {barWidth}></PositionChartAxis>
|
|
425
|
-
</div>
|
|
426
557
|
{/if}
|
|
427
558
|
{#if activeMarkerId}
|
|
428
559
|
<ValueLabel
|
|
@@ -441,6 +572,33 @@
|
|
|
441
572
|
{/if}
|
|
442
573
|
</div>
|
|
443
574
|
|
|
575
|
+
<div style="content-visibility: hidden;">
|
|
576
|
+
{#if !showAxis}
|
|
577
|
+
<Axis
|
|
578
|
+
bind:axisDomain
|
|
579
|
+
bind:ticksArray={ticksDomain}
|
|
580
|
+
{chartHeight}
|
|
581
|
+
chartWidth={chartWidth - markerRadius * 2}
|
|
582
|
+
orientation={{ axis: "x", position: "bottom" }}
|
|
583
|
+
range={[markerRadius, chartWidth - markerRadius]}
|
|
584
|
+
domain={[xTickFirst, xTickLast]}
|
|
585
|
+
{min}
|
|
586
|
+
{max}
|
|
587
|
+
fontSize={14}
|
|
588
|
+
{floor}
|
|
589
|
+
{ceiling}
|
|
590
|
+
{numberOfTicks}
|
|
591
|
+
{polarity}
|
|
592
|
+
{showTickMarks}
|
|
593
|
+
{showGridlines}
|
|
594
|
+
{labelFormatter}
|
|
595
|
+
{niceTicks}
|
|
596
|
+
{markerRadius}
|
|
597
|
+
{distribution}
|
|
598
|
+
></Axis>
|
|
599
|
+
{/if}
|
|
600
|
+
</div>
|
|
601
|
+
|
|
444
602
|
<style>
|
|
445
603
|
.grid-container {
|
|
446
604
|
display: grid;
|
|
@@ -448,14 +606,13 @@
|
|
|
448
606
|
-moz-column-gap: 2%;
|
|
449
607
|
column-gap: 2%;
|
|
450
608
|
row-gap: 2%;
|
|
609
|
+
overflow: visible;
|
|
451
610
|
}
|
|
452
611
|
.chart {
|
|
453
612
|
display: flex;
|
|
454
613
|
flex-direction: column;
|
|
455
614
|
justify-content: flex-end;
|
|
456
615
|
min-width: 0;
|
|
457
|
-
|
|
458
|
-
.accordion {
|
|
459
|
-
max-height: 500px !important; /* large enough to fit content */
|
|
616
|
+
overflow: visible;
|
|
460
617
|
}
|
|
461
618
|
</style>
|
|
@@ -9,19 +9,23 @@ declare const PositionChart: import("svelte").Component<{
|
|
|
9
9
|
max?: any;
|
|
10
10
|
label?: any;
|
|
11
11
|
showAxis?: boolean;
|
|
12
|
+
showArrows?: boolean;
|
|
13
|
+
arrowTextSize?: string;
|
|
14
|
+
showAverage?: boolean;
|
|
12
15
|
chartWidth?: number;
|
|
13
16
|
chartHeight?: number;
|
|
14
|
-
|
|
17
|
+
color?: string;
|
|
15
18
|
nSegments?: number;
|
|
16
19
|
startColor?: string;
|
|
17
20
|
endColor?: string;
|
|
18
21
|
midColor?: any;
|
|
19
|
-
|
|
22
|
+
customColorScale?: any;
|
|
20
23
|
opacity?: number;
|
|
21
24
|
annotation?: any;
|
|
22
25
|
showIcon?: boolean;
|
|
23
26
|
moreInfo?: any;
|
|
24
27
|
markerRadius?: any;
|
|
28
|
+
numberOfTicks?: any;
|
|
25
29
|
options?: any[];
|
|
26
30
|
rowData?: any[];
|
|
27
31
|
allData?: any[];
|
|
@@ -42,26 +46,42 @@ declare const PositionChart: import("svelte").Component<{
|
|
|
42
46
|
onMouseEnterMarker?: Function;
|
|
43
47
|
onMouseLeaveMarker?: Function;
|
|
44
48
|
activeMarkerId?: any;
|
|
45
|
-
|
|
49
|
+
distribution?: any[];
|
|
50
|
+
floor?: any;
|
|
51
|
+
ceiling?: any;
|
|
52
|
+
averageValue?: any;
|
|
53
|
+
polarity?: string;
|
|
54
|
+
skew?: boolean;
|
|
55
|
+
showTickMarks?: boolean;
|
|
56
|
+
showGridlines?: boolean;
|
|
57
|
+
labelFormatter?: Function;
|
|
58
|
+
niceTicks?: boolean;
|
|
59
|
+
ticksDomain?: any[];
|
|
60
|
+
axisDomain?: any[];
|
|
61
|
+
}, {}, "chartWidth" | "axisDomain" | "ticksDomain">;
|
|
46
62
|
type $$ComponentProps = {
|
|
47
63
|
value?: any;
|
|
48
64
|
min?: any;
|
|
49
65
|
max?: any;
|
|
50
66
|
label?: any;
|
|
51
67
|
showAxis?: boolean;
|
|
68
|
+
showArrows?: boolean;
|
|
69
|
+
arrowTextSize?: string;
|
|
70
|
+
showAverage?: boolean;
|
|
52
71
|
chartWidth?: number;
|
|
53
72
|
chartHeight?: number;
|
|
54
|
-
|
|
73
|
+
color?: string;
|
|
55
74
|
nSegments?: number;
|
|
56
75
|
startColor?: string;
|
|
57
76
|
endColor?: string;
|
|
58
77
|
midColor?: any;
|
|
59
|
-
|
|
78
|
+
customColorScale?: any;
|
|
60
79
|
opacity?: number;
|
|
61
80
|
annotation?: any;
|
|
62
81
|
showIcon?: boolean;
|
|
63
82
|
moreInfo?: any;
|
|
64
83
|
markerRadius?: any;
|
|
84
|
+
numberOfTicks?: any;
|
|
65
85
|
options?: any[];
|
|
66
86
|
rowData?: any[];
|
|
67
87
|
allData?: any[];
|
|
@@ -82,4 +102,16 @@ type $$ComponentProps = {
|
|
|
82
102
|
onMouseEnterMarker?: Function;
|
|
83
103
|
onMouseLeaveMarker?: Function;
|
|
84
104
|
activeMarkerId?: any;
|
|
105
|
+
distribution?: any[];
|
|
106
|
+
floor?: any;
|
|
107
|
+
ceiling?: any;
|
|
108
|
+
averageValue?: any;
|
|
109
|
+
polarity?: string;
|
|
110
|
+
skew?: boolean;
|
|
111
|
+
showTickMarks?: boolean;
|
|
112
|
+
showGridlines?: boolean;
|
|
113
|
+
labelFormatter?: Function;
|
|
114
|
+
niceTicks?: boolean;
|
|
115
|
+
ticksDomain?: any[];
|
|
116
|
+
axisDomain?: any[];
|
|
85
117
|
};
|