Skip to content

Commit 34d45d3

Browse files
committed
feat: enhance documentation for legend and progress properties
Signed-off-by: Sergej Atamantschuk <[email protected]>
1 parent 0248bd4 commit 34d45d3

File tree

3 files changed

+52
-42
lines changed

3 files changed

+52
-42
lines changed

guide/options/legend.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ head:
1515
|------------------|----------------------------------------------------|---------|
1616
| Number \| String | any number with `.` or `","` as decimals delimiter | |
1717

18-
The `legend` property can be any Number or String.
19-
While [`progress`](progress.md) only accepts values between -100 and 100, `legend` lets you go beyond that range. You
20-
can even use `"."` or `","` as a delimiter for simple formatting, or set an initial counter-placeholder like "0045.00".
21-
Just make sure it's a valid JavaScript Number.
18+
The `legend` property is used to display a value inside the circle.
19+
It accepts any Number or String, allowing for flexible formatting options.
20+
21+
This property is useful when you want to display values beyond the typical
22+
progress range of -100 to 100, apply custom formatting, or show initial counter values with leading zeros.
23+
24+
You can use `"."` or `","` as a delimiter for simple formatting, or set an initial
25+
counter-placeholder like "0045.00". Just ensure it's a valid JavaScript Number.
2226

2327
::: warning Legend vs progress
2428
The [`progress`](progress.md) property is always required. When both `legend` and [`progress`](progress.md) are defined,
25-
`legend` will take over as the displayed value inside the circle!
26-
How you calculate the [`progress`](progress.md) based on the `legend` value is entirely up to you.
29+
`legend` will take over as the displayed value inside the
30+
circle. The `progress` property is still required and should be calculated based on the `legend` value as needed.
2731
:::
2832

2933
::: tip
@@ -36,7 +40,6 @@ Use the [`hideLegend`](hideLegend.md) property.
3640
###### Usage: 📜
3741

3842
```vue
39-
4043
<ve-progress :legend="150" />
4144
<ve-progress legend="020" />
4245
<ve-progress legend="200,50" />
@@ -58,10 +61,10 @@ The `progress` is calculated as a percentage of the `legend` value
5861

5962
```js-vue
6063
<template>
61-
<ve-progress :legend="{{ slider }}" :progress="{{ progress }}"/>
64+
<ve-progress :legend="legend" :progress="{{ progress }}"/>
6265
</template>
6366
<script setup>
64-
import { ref } from "vue";
67+
import { ref, computed } from "vue";
6568
6669
const maxLegendValue = 4000;
6770
const legend = ref({{ slider }});
@@ -88,7 +91,6 @@ const progress = rating * 100 / 5; // the rating percentage
8891
And then apply the values:
8992

9093
```vue
91-
9294
<ve-progress :progress="progress" :legend="rating" />
9395
```
9496

@@ -99,10 +101,10 @@ As a result, the rating can be displayed as a circle legend, and the progress wi
99101

100102
```js-vue
101103
<template>
102-
<ve-progress :legend="{{ slider }}" :progress="{{ progress }}"/>
104+
<ve-progress :legend="stars" :progress="{{ progress }}"/>
103105
</template>
104106
<script setup>
105-
import { ref } from "vue";
107+
import { ref, computed } from "vue";
106108
107109
const maxStars = 5;
108110
const stars = ref({{ slider }});
@@ -116,7 +118,7 @@ As a result, the rating can be displayed as a circle legend, and the progress wi
116118
</template>
117119
</LegendAndProgress>
118120

119-
With the `legend` as a String, you can use custom decimal delimiters and easily format the displayed value:
121+
With the `legend` is a String, you can use custom decimal delimiters and easily format the displayed value:
120122

121123
<LegendFormatting class="mb-10">
122124
<template #code="{ progress }">

guide/options/legendFormatter.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Function that returns formatted value as string.
2+
description: Function that returns formatted value as string
33
aside: false
44
head:
55
- - meta
@@ -11,20 +11,23 @@ head:
1111

1212
<Badge class="mt-2" type="success" text="Animated" />
1313

14-
| type | values | default |
15-
|----------|---------------------------------------------------------------------------|---------|
16-
| Function | `(props: object) => string` Function returning formatted value as string | |
14+
| type | values | default |
15+
|----------|--------------------------------------------------------------------------|---------|
16+
| Function | `(props: object) => string` Function returning formatted value as string | |
1717

18-
You can provide a function to format the circle legend. The function can return any string
19-
value, even HTML!
20-
You have full freedom to format the value of the [`legend`](legend.md) or [`progress`](progress.md) as you like.
18+
The `legendFormatter` property allows you to provide a custom function to format the circle legend displayed in the
19+
center of the circle.
20+
This function can
21+
return any string value, including HTML, giving you full control over the legend's appearance.
2122

22-
The circle legend is animated and counts up and down depending on the circle [`animation`](animation.md) configuration.
23-
The function takes a counter properties object as an argument and is
24-
called on every counter tick providing the current value of the counter that can be used to format the legend.
23+
The circle legend is animated according to the circle's [`animation`](animation.md) configuration.
24+
The `legendFormatter` will be called on every animation tick, providing the current value of the counter that can be
25+
used to format the legend.
26+
The value of the counter at a specific animation tick represents the value that is passed as
27+
[`legend`](legend.md) or [`progress`](progress.md) to the circle.
2528

2629
::: tip
27-
Alternatively you can use [`scoped slot`](../slots/default.md) for custom formatting.
30+
Alternatively, you can use a [`scoped slot`](../slots/default.md) for custom formatting.
2831
:::
2932

3033
### Usage
@@ -35,10 +38,10 @@ Alternatively you can use [`scoped slot`](../slots/default.md) for custom format
3538
/>
3639
```
3740

38-
| Exposed props | |
39-
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
40-
| `currentValue` | The current value of the counter at specific animation tick. It's always a Number and represents a value that is passed as [`legend`](legend.md) or [`progress`](progress.md) to the circle |
41-
| `currentFormattedValue` | Current value formatted as a String. It's a String representation of the `currentValue` including the formatting wich may be applied with [`legend`](legend.md) |
41+
| Exposed props | Description |
42+
|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
43+
| `currentValue` | The current value of the counter at a specific animation tick. It's always a Number and represents the value that is passed as [`legend`](legend.md) or [`progress`](progress.md) to the circle. |
44+
| `currentFormattedValue` | The current value formatted as a String. It's a String representation of the `currentValue`, including any formatting applied with [`legend`](legend.md). |
4245

4346
### Examples
4447

@@ -48,7 +51,7 @@ Alternatively you can use [`scoped slot`](../slots/default.md) for custom format
4851
import LegendFormatterProps from "../../.vitepress/theme/Guide/LegendFormatter/LegendFormatterProps.vue";
4952
</script>
5053

51-
In the following example, we take the raw `currentValue` value and format it as a string
54+
In the following example, we take the raw `currentValue` and format it as a string:
5255

5356
<LegendFormatterBasic class="mb-10">
5457
<template #code="{ progress }">
@@ -63,8 +66,8 @@ In the following example, we take the raw `currentValue` value and format it as
6366
</template>
6467
</LegendFormatterBasic>
6568

66-
The formatting function can return HTML as a string to customize the styles of the rendered circle legend.
67-
You can add more elements, images and pretty much anything here
69+
The formatting function can return HTML as a string to customize the styles of the rendered circle legend. You can add
70+
more elements, images, and pretty much anything here:
6871

6972
<LegendFormatterHtml class="mb-10">
7073
<template #code>
@@ -91,8 +94,8 @@ You can add more elements, images and pretty much anything here
9194
</template>
9295
</LegendFormatterHtml>
9396

94-
The internal counter component provides additional properties that might be useful. The properties are calculated for
95-
each counter tick.
97+
The internal counter component provides additional properties that might be useful. These properties are calculated for
98+
each counter tick:
9699

97100
<LegendFormatterProps>
98101
<template #code="{ progress, legend }">

guide/options/progress.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: The progress property takes a Number value in the range [-100, 100] and defines the filled area from progress circle line in percent.
2+
description: The progress property takes a Number value in the range [-100, 100] and defines the filled area from progress circle line in percent. It is used to visually represent the progress of a task or process.
33
aside: false
44
head:
55
- - meta
@@ -15,20 +15,25 @@ head:
1515
|--------|-------------|---------|
1616
| Number | [-100, 100] | |
1717

18-
The `progress` property takes a Number value in the range \[-100, 100] and defines the filled area from progress circle
19-
line in percent. By default, `progress` is shown as the **legend** in the middle of the circle.
20-
`progress` is animated
21-
and counts up or down on any value changes with duration defined in **[`animation.duration`](animation.md)** property.
18+
The `progress` property takes a Number value in the range \[-100, 100] and defines the filled area from the progress
19+
circle line in percent.
20+
By default, `progress` is shown as the **legend** in the middle of the circle.
2221

23-
A negative value can be used to fill the progress line counterclockwise. Alternatively the same effect can be achieved
22+
`progress` is animated and counts up or down on any value changes with duration defined in
23+
**[`animation.duration`](animation.md)** property.
24+
25+
A negative value can be used to fill the progress line counterclockwise.
26+
Alternatively, the same effect can be achieved
2427
with the **[`reverse`](reverse.md)** property.
2528

2629
::: warning Progress and Legend
27-
The `progress` is always used to fill the progress circle line, it should be always in the range [-100, 100] and
28-
not valid Numbers lead to **[`noData`](noData)** state. For advanced use cases please use **[`legend`](legend.md)**
30+
The `progress` is always used to fill the progress circle line, it should always be in the range [-100, 100] and invalid
31+
Numbers lead to **[`noData`](noData)** state.
32+
If you want to customize and style what the circle legend displays, you can use the **[`legend`](legend.md)** property,
33+
For advanced use cases, please use **[`legend`](legend.md)**
2934
and take a look at **[`legendFormatter`](legendFormatter.md)** or the **[`default slot`](../slots/default.md)**.
3035

31-
If **[`legend`](legend.md)** is defined the `progress` will **not** be displayed as the circle legend.
36+
If **[`legend`](legend.md)** is defined, the `progress` will **not** be displayed as the circle legend.
3237
:::
3338

3439
###### Usage: 📜

0 commit comments

Comments
 (0)