@@ -140,7 +81,7 @@ Methods in [Universal Methods](js-components-common-methods.md) are not suppor
```
-```
+```css
/* xxx.css */
.doc-page {
flex-direction: column;
@@ -189,31 +130,31 @@ Methods in [Universal Methods](js-components-common-methods.md) are not suppor
}
```
-```
+```js
// xxx.js
import prompt from '@system.prompt';
export default {
- showDialog(e) {
+ showDialog() {
this.$element('simpledialog').show()
},
- cancelDialog(e) {
+ cancelDialog() {
prompt.showToast({
message: 'Dialog cancelled'
})
},
- cancelSchedule(e) {
+ cancelSchedule() {
this.$element('simpledialog').close()
prompt.showToast({
message: 'Successfully cancelled'
})
},
- setSchedule(e) {
+ setSchedule() {
this.$element('simpledialog').close()
prompt.showToast({
message: 'Successfully confirmed'
})
},
- doubleclick(e){
+ doubleclick(){
prompt.showToast({
message: 'doubleclick'
})
@@ -221,5 +162,4 @@ export default {
}
```
-![](figures/4.gif)
-
+![4](figures/4.gif)
diff --git a/en/application-dev/reference/arkui-ts/figures/badge.png b/en/application-dev/reference/arkui-ts/figures/badge.png
new file mode 100644
index 0000000000000000000000000000000000000000..0041374b52a2be5a93f620dabed0cba74990ee6f
Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/badge.png differ
diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001174422916.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001174422916.png
deleted file mode 100644
index 2eb96b00f11e597fcc3e3d5ef32701e0a4ef5f5b..0000000000000000000000000000000000000000
Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001174422916.png and /dev/null differ
diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218470.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218470.gif
deleted file mode 100644
index 016da55bb5d98a3d2787d870bf2575fbaf383990..0000000000000000000000000000000000000000
Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218470.gif and /dev/null differ
diff --git a/en/application-dev/reference/arkui-ts/figures/gauge-image.png b/en/application-dev/reference/arkui-ts/figures/gauge-image.png
new file mode 100644
index 0000000000000000000000000000000000000000..d8fa99c3cc70ca08914a3850d95d2511eff923cd
Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gauge-image.png differ
diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md
index f3471dece3c51c704aa137f47a529cbcdf7adb37..5b4387a8c137fd14e9866238aef6785300f93918 100644
--- a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md
+++ b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md
@@ -21,7 +21,7 @@ Gauge(options:{value: number, min?: number, max?: number})
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | number | Yes| Current data value.|
+| value | number | Yes| Current value of the chart, that is, the position to which the pointer points in the chart. It is used as the initial value of the chart when the component is created.|
| min | number | No| Minimum value of the current data segment.
Default value: **0**|
| max | number | No| Maximum value of the current data segment.
Default value: **100**|
@@ -31,10 +31,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name| Type| Description|
| -------- | -------- | -------- |
-| value | number | Value of the chart.
Default value: **0**|
-| startAngle | number | Start angle of the chart. The value 0 indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **-150**|
-| endAngle | number | End angle of the chart. The value 0 indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **150**|
-| colors | Array<ColorStop> | Colors of the chart. Colors can be set for individual segments.|
+| value | number | Value of the chart. It can be dynamically changed.
Default value: **0**|
+| startAngle | number | Start angle of the chart. The value **0** indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **0**|
+| endAngle | number | End angle of the chart. The value **0** indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **360**|
+| colors | Array<[ColorStop](#colorstop)> | Colors of the chart. Colors can be set for individual segments.|
| strokeWidth | Length | Stroke width of the chart.|
## ColorStop
@@ -43,7 +43,7 @@ Describes a gradient stop.
| Name | Type | Description |
| --------- | -------------------- | ------------------------------------------------------------ |
-| ColorStop | [[ResourceColor](ts-types.md#resourcecolor), number] | Type of the gradient stop. The first parameter specifies the color, and the second parameter specifies the offset, which ranges from 0 to 1.|
+| ColorStop | [[ResourceColor](ts-types.md#resourcecolor), number] | Type of the gradient stop. The first parameter indicates the color value. If it is set to a non-color value, the black color is used. The second parameter indicates the color weight. If it is set to a negative number or a non-numeric value, the color weight is 0, which means that the color is not displayed.|
## Example
@@ -55,15 +55,30 @@ Describes a gradient stop.
@Component
struct GaugeExample {
build() {
- Column() {
- Gauge({ value: 50, min: 0, max: 100 })
- .startAngle(210).endAngle(150)
- .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]])
- .strokeWidth(20)
+ Column({ space: 20 }) {
+ // Use the default value of min and max, which is 0-100, and the default values of startAngle and endAngle, which are 0 and 360, respectively.
+ // Set the current value to 75.
+ Gauge({ value: 75 })
+ .width(200).height(200)
+ .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]])
+
+ // Set the value parameter to 75 and the value attribute to 25. The attribute setting is used.
+ Gauge({ value: 75 })
+ .value(25) // If both the attribute and parameter are set, the parameter setting is used.
.width(200).height(200)
+ .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]])
+
+ // A ring chart of 210 to 150 degrees
+ Gauge({ value: 30, min: 0, max: 100 })
+ .startAngle(210)
+ .endAngle(150)
+ .colors([[0x317AF7, 0.1], [0x5BA854, 0.2], [0xE08C3A, 0.3], [0x9C554B, 0.4]])
+ .strokeWidth(20)
+ .width(200)
+ .height(200)
}.width('100%').margin({ top: 5 })
}
}
```
-![en-us_image_0000001174422916](figures/en-us_image_0000001174422916.png)
+![gauge](figures/gauge-image.png)
diff --git a/en/application-dev/reference/arkui-ts/ts-container-badge.md b/en/application-dev/reference/arkui-ts/ts-container-badge.md
index 912f89de44f63e6e3bb896efb5fa64025f4bd115..f3dd7c6710648b165208f64c7147e6f7a9c0758a 100644
--- a/en/application-dev/reference/arkui-ts/ts-container-badge.md
+++ b/en/application-dev/reference/arkui-ts/ts-container-badge.md
@@ -7,11 +7,6 @@ The **\
** component is a container that can be attached to another compon
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
-## Required Permissions
-
-None
-
-
## Child Components
This component supports only one child component.
@@ -19,7 +14,7 @@ This component supports only one child component.
## APIs
-Method 1: Badge(value: {count: number, position?: BadgePosition, maxCount?: number, style: BadgeStyle})
+**Method 1**: Badge(value: {count: number, position?: BadgePosition, maxCount?: number, style: BadgeStyle})
Create a badge.
@@ -27,36 +22,38 @@ Create a badge.
| Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- |
| count | number | Yes| - | Number of notifications.|
-| position | BadgePosition | No| BadgePosition.RightTop | Position to display the badge relative to the parent component.|
+| position | [BadgePosition](#badgeposition) | No| BadgePosition.RightTop | Position to display the badge relative to the parent component.|
| maxCount | number | No| 99 | Maximum number of notifications. When the maximum number is reached, only **maxCount+** is displayed.|
-| style | BadgeStyle | Yes| - | Style of the **** component, including the text color, text size, badge color, and badge size.|
+| style | [BadgeStyle](#badgestyle) | Yes| - | Style of the badge, including the font color, font size, badge color, and badge size.|
-Method 2: Badge(value: {value: string, position?: BadgePosition, style: BadgeStyle})
+**Method 2**: Badge(value: {value: string, position?: BadgePosition, style: BadgeStyle})
Creates a badge based on the given string.
-- Parameters
- | Name| Type| Mandatory| Default Value| Description|
- | -------- | -------- | -------- | -------- | -------- |
- | value | string | Yes| - | Prompt content.|
- | position | BadgePosition | No| BadgePosition.RightTop | Position to display the badge relative to the parent component.|
- | style | BadgeStyle | Yes| - | Style of the **** component, including the text color, text size, badge color, and badge size.|
-
-- BadgeStyle
- | Name| Type| Mandatory| Default Value| Description|
- | -------- | -------- | -------- | -------- | -------- |
- | color | [ResourceColor](ts-types.md#resourcecolor) | No| Color.White | Text color.|
- | fontSize | number \| string | No| 10 | Text size.|
- | badgeSize | number \| string | Yes| - | Badge size.|
- | badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No| Color.Red | Badge color.|
-
-- BadgePosition enums
- | Name| Description|
- | -------- | -------- |
- | RightTop | The badge is displayed in the upper right corner of the parent component.|
- | Right | The badge is vertically centered on the right of the parent component.|
- | Left | The badge is vertically centered on the left of the parent component.|
+**Parameters**
+
+| Name| Type| Mandatory| Default Value| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| value | string | Yes| - | Prompt content.|
+| position | [BadgePosition](#badgeposition) | No| BadgePosition.RightTop | Position to display the badge relative to the parent component.|
+| style | [BadgeStyle](#badgestyle) | Yes| - | Style of the badge, including the font color, font size, badge color, and badge size.|
+
+## BadgePosition
+
+| Name| Description|
+| -------- | -------- |
+| RightTop | The badge is displayed in the upper right corner of the parent component.|
+| Right | The badge is vertically centered on the right of the parent component.|
+| Left | The badge is vertically centered on the left of the parent component.|
+
+## BadgeStyle
+| Name | Type | Mandatory| Default Value | Description |
+| ---------- | ------------------------------------------ | ---- | ----------- | ------------------------------------------- |
+| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Font color. |
+| fontSize | number \| string | No | 10 | Font size, in vp. |
+| badgeSize | number \| string | No | 16 | Badge size, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.|
+| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color.Red | Badge color. |
## Example
@@ -65,44 +62,92 @@ Creates a badge based on the given string.
@Entry
@Component
struct BadgeExample {
- @State counts: number = 1
- @State message: string = 'new'
+ @State counts: number = 1;
+ @State message: string = 'new';
build() {
- Flex({ justifyContent: FlexAlign.SpaceAround }) {
- Badge({
- count: this.counts,
- maxCount: 99,
- style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red }
- }) {
- Button('message')
- .onClick(() => {
- this.counts++
- })
- .width(100).height(50).backgroundColor(0x317aff)
- }.width(100).height(50)
-
- Badge({
- value: this.message,
- style: { color: 0xFFFFFF, fontSize: 9, badgeSize: 20, badgeColor: Color.Blue }
- }) {
- Text('message')
- .width(80).height(50).fontSize(16).lineHeight(37)
- .borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED)
- }.width(80).height(50)
-
- Badge({
- value: ' ',
- position: BadgePosition.Right,
- style: { badgeSize: 6, badgeColor: Color.Red }
- }) {
- Text('message')
- .width(90).height(50).fontSize(16).lineHeight(37)
- .borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED)
- }.width(90).height(50)
- }.width('100%').margin({ top: 5 })
+ Column() {
+ Text('numberBadge').width('80%')
+ Row({ space: 10 }) {
+ // Number badge. The default value of maxCount is 99. If the number of notifications exceeds 99, 99+ is displayed.
+ Badge({
+ count: this.counts,
+ maxCount: 99,
+ position: BadgePosition.RightTop,
+ style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red }
+ }) {
+ Button('message')
+ .onClick(() => {
+ this.counts++;
+ })
+ .width(100).height(50).backgroundColor(0x317aff)
+ }.width(100).height(50)
+
+ // Number badge
+ Badge({
+ count: this.counts,
+ maxCount: 99,
+ position: BadgePosition.Left,
+ style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red }
+ }) {
+ Button('message')
+ .onClick(() => {
+ this.counts++;
+ })
+ .width(100).height(50).backgroundColor(0x317aff)
+ }.width(100).height(50)
+
+
+ // Number badge
+ Badge({
+ count: this.counts,
+ maxCount: 99,
+ position: BadgePosition.Right,
+ style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red }
+ }) {
+ Button('message')
+ .onClick(() => {
+ this.counts++;
+ })
+ .width(100).height(50).backgroundColor(0x317aff)
+ }.width(100).height(50)
+ }.margin(10)
+
+ Text('stringBadge').width('80%')
+ Row({ space: 30 }) {
+ Badge({
+ value: this.message,
+ style: { color: 0xFFFFFF, fontSize: 9, badgeSize: 20, badgeColor: Color.Blue }
+ }) {
+ Text('message')
+ .width(80)
+ .height(50)
+ .fontSize(16)
+ .lineHeight(37)
+ .borderRadius(10)
+ .textAlign(TextAlign.Center)
+ .backgroundColor(0xF3F4ED)
+ }.width(80).height(50)
+
+ // When value is null, the dot-style badge is used.
+ Badge({
+ value: '',
+ position: BadgePosition.Right,
+ style: { badgeSize: 6, badgeColor: Color.Red }
+ }) {
+ Text('message')
+ .width(90)
+ .height(50)
+ .fontSize(16)
+ .lineHeight(37)
+ .borderRadius(10)
+ .textAlign(TextAlign.Center)
+ .backgroundColor(0xF3F4ED)
+ }.width(90).height(50)
+ }.margin(10)
+ }
}
}
```
-![en-us_image_0000001212218470](figures/en-us_image_0000001212218470.gif)
+![badge](figures/badge.png)