Skip to content

Commit 48c3029

Browse files
committed
added descriptions and synchronised code blocks with examples
1 parent b973c8e commit 48c3029

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

src/wrappers/components/data-vis/position-chart/PositionChartWrapper.svelte

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
*
4848
*/
4949
let descriptionArray = [
50-
"This component renders a horizontal bar chart with a highlighted marker to visually represent a single value within a defined range. The bar is segmented into ten color-coded bands, each representing a decile, but plots the marker on a continuous scale. The marker is positioned using a linear scale and can optionally be accompanied by an axis and label for added clarity.",
50+
"This component renders a horizontal bar with a marker to visually represent a single value within a defined range. The bar has ten color-coded segments, each representing a decile, but the marker is plotted on a continuous scale using a linear function. The user can include an axis or label.",
5151
];
5252
5353
let contextArray = [
54-
"Use this component when you want to visually communicate where a value sits within a distribution. Use the stacked version of the component when you want to compare values from similar distributions.",
54+
"Use this component to show where a value sits within a range. Use the stacked version of the component when you want to compare values.",
5555
];
5656
5757
let detailsArray = [
@@ -158,41 +158,43 @@
158158
*/
159159
let parametersSourceArray = $derived(
160160
addIndexAndInitalValue([
161-
{
162-
name: "componentNameProp",
163-
category: "Input props",
164-
propType: "fixed",
165-
value: pageName,
166-
},
167161
{
168162
name: "showAxis",
169-
category: "Input props",
163+
category: "Display",
170164
value: true,
165+
description: "Whether to display an axis. Boolean.",
171166
},
172167
{
173168
name: "value",
174-
category: "Input props",
169+
category: "Data",
175170
value: 3,
171+
description: "The numerical value to be plotted.",
176172
},
177173
{
178174
name: "min",
179-
category: "Input props",
175+
category: "Data",
180176
value: 0,
177+
description: "The minimum value for the scale.",
181178
},
182179
{
183180
name: "max",
184-
category: "Input props",
181+
category: "Data",
185182
value: 10,
183+
description: "The maximum value for the scale.",
186184
},
187185
{
188186
name: "label",
189-
category: "Input props",
190-
value: `Employment`,
187+
category: "Display",
188+
value: "Label",
189+
description:
190+
"Text label to display alongside the chart. If specified, the component uses a grid container, otherwise it uses a flex container.",
191191
},
192192
{
193193
name: "chartHeight",
194-
category: "Input props",
194+
category: "Display",
195195
value: 24,
196+
description:
197+
"The height of the chart (which is made up of the bar and the marker)",
196198
},
197199
]),
198200
);

src/wrappers/components/data-vis/position-chart/position-chart/Examples.svelte

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,14 @@
6161

6262
{#snippet Example1()}
6363
<div class="p-5 bg-white">
64-
<PositionChart value="7" min="1" max="10" label="Education" showAxis={true}
65-
></PositionChart>
64+
<PositionChart value="7" min="0" max="10" label="Education"></PositionChart>
6665
</div>
6766
<CodeBlock code={codeBlocks.codeBlock1} language="svelte"></CodeBlock>
6867
{/snippet}
6968

7069
{#snippet Example2()}
7170
<div class="p-5 bg-white">
72-
<PositionChart value="7" min="1" max="10" showAxis={true}></PositionChart>
71+
<PositionChart value="7" min="0" max="10"></PositionChart>
7372
</div>
7473
<CodeBlock code={codeBlocks.codeBlock2} language="svelte"></CodeBlock>
7574
{/snippet}
@@ -93,11 +92,9 @@
9392
label={item[0]}
9493
stacked={true}
9594
numberOfPositionCharts={dummyData.length}
96-
showAxis={false}
95+
showAxis={dummyData.length == i + 1}
9796
></PositionChart>
9897
{/each}
99-
<div class="empty-div"></div>
100-
<PositionChartAxis></PositionChartAxis>
10198
</div>
10299
</div>
103100
<CodeBlock code={codeBlocks.codeBlock3} language="svelte"></CodeBlock>

src/wrappers/components/data-vis/position-chart/position-chart/codeBlocks.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,33 @@ export const codeBlock1 = `
33
import { PositionChart } from '@communitiesuk/svelte-component-library';
44
</script>
55
6-
<PositionChart value="7" min="1" max="10" label="Education" showAxis={true}
7-
></PositionChart>`;
6+
<PositionChart value="7" min="0" max="10" label="Education"></PositionChart>`;
87

98
export const codeBlock2 = `
109
<script>
1110
import { PositionChart } from '@communitiesuk/svelte-component-library';
1211
</script>
1312
14-
<PositionChart value="7" min="1" max="10" showAxis={true}></PositionChart>`;
13+
<PositionChart value="7" min="0" max="10"></PositionChart>`;
1514

1615
export const codeBlock3 = `
1716
<script>
1817
import { PositionChart } from '@communitiesuk/svelte-component-library';
19-
import { PositionChartAxis } from '@communitiesuk/svelte-component-library';
18+
19+
let dummyData = $state([
20+
["Overall", 3],
21+
["Income", 2.5],
22+
["Living Environment", 5],
23+
["Barriers to Housing & Services", 1],
24+
["Employment", 3],
25+
["Education", 7],
26+
["Health", 6],
27+
["Crime", 6],
28+
])
2029
</script>
2130
22-
<div
31+
32+
<div
2333
class="grid"
2434
style="display: grid;
2535
grid-template-columns: minmax(100px, 30%) 1fr;
@@ -36,9 +46,8 @@ export const codeBlock3 = `
3646
label={item[0]}
3747
stacked={true}
3848
numberOfPositionCharts={dummyData.length}
39-
showAxis={false}
49+
showAxis={dummyData.length == i + 1}
4050
></PositionChart>
4151
{/each}
42-
<div class="empty-div"></div>
43-
<PositionChartAxis></PositionChartAxis>
44-
</div>`;
52+
</div>
53+
</div>`;

0 commit comments

Comments
 (0)