ts-basic-components-gauge.md 2.2 KB
Newer Older
Z
zengyawen 已提交
1 2 3
# Gauge


E
ester.zhou 已提交
4 5
The **\<Gauge>** component is used to display data in a ring chart.

6 7 8
>  **NOTE**
>
>  This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
9 10 11 12 13 14 15


## Required Permissions

None


E
esterzhou 已提交
16
## Child Components
Z
zengyawen 已提交
17

18
Not supported
Z
zengyawen 已提交
19 20 21 22


## APIs

E
ester.zhou 已提交
23
Gauge(options:{value: number, min?: number, max?: number})
Z
zengyawen 已提交
24

25
- Parameters
E
ester.zhou 已提交
26
    | Name| Type| Mandatory| Default Value| Description|
Z
zengyawen 已提交
27
  | -------- | -------- | -------- | -------- | -------- |
28 29 30
  | value | number | Yes| - | Current data value.|
  | min | number | No| 0 | Minimum value of the current data segment.|
  | max | number | No| 100 | Maximum value of the current data segment.|
Z
zengyawen 已提交
31 32 33 34


## Attributes

35
| Name| Type| Default Value| Description|
Z
zengyawen 已提交
36
| -------- | -------- | -------- | -------- |
37 38 39
| value | number | 0 | Value of the chart.|
| startAngle | number | -150 | Start angle of the chart. The value 0 indicates 0 degrees, and a positive value indicates the clockwise direction.|
| endAngle | number | 150 | End angle of the chart. The value 0 indicates 0 degrees, and a positive value indicates the clockwise direction.|
E
ester.zhou 已提交
40
| colors | Array&lt;ColorStop&gt; | - | Colors of the chart. Colors can be set for individual segments.|
41
| strokeWidth | Length | - | Stroke width of the chart.|
Z
zengyawen 已提交
42

E
ester.zhou 已提交
43 44 45 46 47 48 49 50
## ColorStop

Describes a gradient stop.

| Name     | Type            | Description                                                        |
| --------- | -------------------- | ------------------------------------------------------------ |
| ColorStop | [[ResourceColor](../../ui/ts-types.md#resourcecolor8), 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.|

Z
zengyawen 已提交
51 52 53 54

## Example


55 56
```ts
// xxx.ets
Z
zengyawen 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
@Entry
@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)
        .width(200).height(200)
    }.width('100%').margin({ top: 5 })
  }
}
```

![en-us_image_0000001174422916](figures/en-us_image_0000001174422916.png)