@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,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,11 +388,7 @@
|
|
|
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}
|
|
347
394
|
{#each Object.entries(positionChart.rowData) as [tier, points]}
|
|
@@ -371,31 +418,117 @@
|
|
|
371
418
|
? (e) => e.key === "Enter" && onClickMarker(e, value)
|
|
372
419
|
: null}
|
|
373
420
|
pointer-events={interactiveMarkers ? null : "none"}
|
|
374
|
-
transform="translate({xFunction(
|
|
375
|
-
positionChart.
|
|
376
|
-
positionChart.max,
|
|
377
|
-
)(rowValue.value) + markerRadius},{positionChart.chartHeight /
|
|
378
|
-
2})"
|
|
421
|
+
transform="translate({xFunction(chartDomain)(rowValue.value) +
|
|
422
|
+
markerRadius},{positionChart.chartHeight / 2})"
|
|
379
423
|
>
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
424
|
+
{#if rowValue.shape === "line"}
|
|
425
|
+
<line
|
|
426
|
+
x1={0}
|
|
427
|
+
x2={0}
|
|
428
|
+
y1={chartHeight / 1.5}
|
|
429
|
+
y2={-chartHeight / 1.5}
|
|
430
|
+
stroke={rowValue.color === "inherit"
|
|
431
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
432
|
+
: rowValue.color}
|
|
433
|
+
stroke-width={rowValue.markerRadius * 5}
|
|
434
|
+
opacity={0}
|
|
435
|
+
pointer-events={rowValue.pointerEvents}
|
|
436
|
+
></line>
|
|
437
|
+
<line
|
|
438
|
+
x1={0}
|
|
439
|
+
x2={0}
|
|
440
|
+
y1={chartHeight / 2.4}
|
|
441
|
+
y2={-chartHeight / 2.4}
|
|
442
|
+
stroke={rowValue.color === "inherit"
|
|
443
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
444
|
+
: rowValue.color}
|
|
445
|
+
stroke-width={rowValue.markerRadius}
|
|
446
|
+
opacity={rowValue.opacity}
|
|
447
|
+
pointer-events="none"
|
|
448
|
+
></line>
|
|
449
|
+
{:else}
|
|
450
|
+
<circle
|
|
451
|
+
r={rowValue.markerRadius}
|
|
452
|
+
cx="0"
|
|
453
|
+
cy="0"
|
|
454
|
+
stroke="white"
|
|
455
|
+
fill={rowValue.color === "inherit"
|
|
456
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
457
|
+
: rowValue.color}
|
|
458
|
+
stroke-width={3}
|
|
459
|
+
opacity={rowValue.opacity}
|
|
460
|
+
></circle>
|
|
461
|
+
<circle
|
|
462
|
+
r={rowValue.markerRadius * 0.9}
|
|
463
|
+
cx="0"
|
|
464
|
+
cy="0"
|
|
465
|
+
fill={rowValue.color === "inherit"
|
|
466
|
+
? colorScale[segmentIndex(rowValue.value)]
|
|
467
|
+
: rowValue.color}
|
|
468
|
+
stroke="black"
|
|
469
|
+
stroke-width={1.5}
|
|
470
|
+
opacity={rowValue.opacity}
|
|
471
|
+
></circle>
|
|
472
|
+
{/if}
|
|
388
473
|
</g>
|
|
389
474
|
{/if}
|
|
390
475
|
{/each}
|
|
391
476
|
{/each}
|
|
477
|
+
{#if showAxis}
|
|
478
|
+
<Axis
|
|
479
|
+
bind:axisDomain
|
|
480
|
+
bind:ticksArray={ticksDomain}
|
|
481
|
+
{chartHeight}
|
|
482
|
+
chartWidth={chartWidth - markerRadius * 2}
|
|
483
|
+
orientation={{ axis: "x", position: "bottom" }}
|
|
484
|
+
range={[markerRadius, chartWidth - markerRadius]}
|
|
485
|
+
domain={[xTickFirst, xTickLast]}
|
|
486
|
+
{min}
|
|
487
|
+
{max}
|
|
488
|
+
fontSize={14}
|
|
489
|
+
{floor}
|
|
490
|
+
{ceiling}
|
|
491
|
+
{numberOfTicks}
|
|
492
|
+
{polarity}
|
|
493
|
+
{showTickMarks}
|
|
494
|
+
{showGridlines}
|
|
495
|
+
{labelFormatter}
|
|
496
|
+
{niceTicks}
|
|
497
|
+
{markerRadius}
|
|
498
|
+
{distribution}
|
|
499
|
+
></Axis>
|
|
500
|
+
{/if}
|
|
501
|
+
{#if showAverage}
|
|
502
|
+
<g
|
|
503
|
+
transform="translate({xFunction(chartDomain)(averageValue) +
|
|
504
|
+
markerRadius}, {chartHeight + (showAxis ? 20 : 0)})"
|
|
505
|
+
>
|
|
506
|
+
<text
|
|
507
|
+
fill="#444"
|
|
508
|
+
font-size={15}
|
|
509
|
+
text-anchor="middle"
|
|
510
|
+
font-weight="bold"
|
|
511
|
+
>
|
|
512
|
+
<tspan x="1" dy="15">▲</tspan>
|
|
513
|
+
<tspan x="1" dy="4">|</tspan>
|
|
514
|
+
<tspan font-family="GDS Transport" x="1" dy="13">Average</tspan>
|
|
515
|
+
</text>
|
|
516
|
+
</g>
|
|
517
|
+
{/if}
|
|
392
518
|
</svg>
|
|
519
|
+
{#if showArrows}
|
|
520
|
+
<div class="axis-container" style="margin: 0px {markerRadius}px">
|
|
521
|
+
<PositionChartAxis
|
|
522
|
+
textSize={arrowTextSize}
|
|
523
|
+
axisLabels={["Worse than average", "Better than average"]}
|
|
524
|
+
></PositionChartAxis>
|
|
525
|
+
</div>
|
|
526
|
+
{/if}
|
|
393
527
|
</div>
|
|
394
528
|
{#if moreInfoTogglesArray[i]}
|
|
395
|
-
<div class="accordion" style="grid-column:1 / -1
|
|
396
|
-
<
|
|
397
|
-
|
|
398
|
-
></InsetText> -->
|
|
529
|
+
<div class="accordion" style="grid-column:1 / -1">
|
|
530
|
+
<InsetText content={positionChart.moreInfo} renderStringAsHTML={true}
|
|
531
|
+
></InsetText>
|
|
399
532
|
</div>
|
|
400
533
|
{/if}
|
|
401
534
|
{#if positionChart.divider}
|
|
@@ -420,9 +553,6 @@
|
|
|
420
553
|
{#if showLabel}
|
|
421
554
|
<div class="empty"></div>
|
|
422
555
|
{/if}
|
|
423
|
-
<div class="axis">
|
|
424
|
-
<PositionChartAxis {markerRadius} {barWidth}></PositionChartAxis>
|
|
425
|
-
</div>
|
|
426
556
|
{/if}
|
|
427
557
|
{#if activeMarkerId}
|
|
428
558
|
<ValueLabel
|
|
@@ -441,6 +571,33 @@
|
|
|
441
571
|
{/if}
|
|
442
572
|
</div>
|
|
443
573
|
|
|
574
|
+
<div style="content-visibility: hidden;">
|
|
575
|
+
{#if !showAxis}
|
|
576
|
+
<Axis
|
|
577
|
+
bind:axisDomain
|
|
578
|
+
bind:ticksArray={ticksDomain}
|
|
579
|
+
{chartHeight}
|
|
580
|
+
chartWidth={chartWidth - markerRadius * 2}
|
|
581
|
+
orientation={{ axis: "x", position: "bottom" }}
|
|
582
|
+
range={[markerRadius, chartWidth - markerRadius]}
|
|
583
|
+
domain={[xTickFirst, xTickLast]}
|
|
584
|
+
{min}
|
|
585
|
+
{max}
|
|
586
|
+
fontSize={14}
|
|
587
|
+
{floor}
|
|
588
|
+
{ceiling}
|
|
589
|
+
{numberOfTicks}
|
|
590
|
+
{polarity}
|
|
591
|
+
{showTickMarks}
|
|
592
|
+
{showGridlines}
|
|
593
|
+
{labelFormatter}
|
|
594
|
+
{niceTicks}
|
|
595
|
+
{markerRadius}
|
|
596
|
+
{distribution}
|
|
597
|
+
></Axis>
|
|
598
|
+
{/if}
|
|
599
|
+
</div>
|
|
600
|
+
|
|
444
601
|
<style>
|
|
445
602
|
.grid-container {
|
|
446
603
|
display: grid;
|
|
@@ -448,14 +605,13 @@
|
|
|
448
605
|
-moz-column-gap: 2%;
|
|
449
606
|
column-gap: 2%;
|
|
450
607
|
row-gap: 2%;
|
|
608
|
+
overflow: visible;
|
|
451
609
|
}
|
|
452
610
|
.chart {
|
|
453
611
|
display: flex;
|
|
454
612
|
flex-direction: column;
|
|
455
613
|
justify-content: flex-end;
|
|
456
614
|
min-width: 0;
|
|
457
|
-
|
|
458
|
-
.accordion {
|
|
459
|
-
max-height: 500px !important; /* large enough to fit content */
|
|
615
|
+
overflow: visible;
|
|
460
616
|
}
|
|
461
617
|
</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
|
};
|