1e41f4b71Sopenharmony_ci# Gauge
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci数据量规图表组件,用于将数据展示为环形图表。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci>  **说明:**
7e41f4b71Sopenharmony_ci>
8e41f4b71Sopenharmony_ci>  该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## 子组件
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci可以包含单个子组件。
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci> **说明:**
16e41f4b71Sopenharmony_ci>
17e41f4b71Sopenharmony_ci> 建议使用文本组件构建当前数值文本和辅助文本。
18e41f4b71Sopenharmony_ci>
19e41f4b71Sopenharmony_ci> 若子组件宽高为百分比形式,则基准范围为以外圆环做为内切圆的矩形。
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci## 接口
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ciGauge(options: GaugeOptions)
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci创建数据量规图表组件。
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci**参数:**
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 |
37e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
38e41f4b71Sopenharmony_ci| options |  [GaugeOptions](#gaugeoptions14对象说明)| 是 | 数据量规图表组件参数。 |
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci## GaugeOptions<sup>14+</sup>对象说明
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci**卡片能力:** 从API version 14开始,该接口支持在ArkTS卡片中使用。
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 14开始,该接口支持在原子化服务中使用。
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 |
49e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
50e41f4b71Sopenharmony_ci| value | number | 是 | 量规图的当前数据值,即图中指针指向位置。用于组件创建时量规图初始值的预置。<br/>**说明:** <br/>value不在min和max范围内时使用min作为默认值。 |
51e41f4b71Sopenharmony_ci| min | number | 否 | 当前数据段最小值。<br/>默认值:0 |
52e41f4b71Sopenharmony_ci| max | number | 否 | 当前数据段最大值。<br/>默认值:100<br/>**说明:** <br/>max小于min时使用默认值0和100。<br/>max和min支持负数。 |
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci## 属性
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性:
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci### value
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_civalue(value: number)
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci设置量规图的数据值。
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci**参数:** 
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                                         |
73e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
74e41f4b71Sopenharmony_ci| value  | number | 是   | 量规图的数据值,可用于动态修改量规图的数据值。<br/>默认值:0 |
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci### startAngle
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_cistartAngle(angle: number)
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci设置起始角度位置。
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**参数:** 
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                                         |
91e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
92e41f4b71Sopenharmony_ci| angle  | number | 是   | 起始角度位置,时钟0点为0度,顺时针方向为正角度。<br/>默认值:0 |
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci### endAngle
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ciendAngle(angle: number)
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci设置终止角度位置。起始角度位置和终止角度位置差过小时,会绘制出异常图像,请取合理的起始角度位置和终止角度位置。建议使用单色环改变Gauge的value参数实现数据值的调节,可通过定时器setTimeout进行数值的延迟加载。
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci**参数:** 
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                                         |
109e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
110e41f4b71Sopenharmony_ci| angle  | number | 是   | 终止角度位置,时钟0点为0度,顺时针方向为正角度。<br/>默认值:360 |
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci### colors
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_cicolors(colors: ResourceColor | LinearGradient | Array<[ResourceColor | LinearGradient, number]>)
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci设置量规图的颜色。
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci从API version 11开始,该接口使用以下规则:
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci参数类型为ResourceColor,则圆环类型为单色环。
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci参数类型为LinearGradient,则圆环类型为渐变环。
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci参数类型为数组,则圆环类型为分段渐变环,第一个参数为颜色值,若设置为非颜色类型,则置为"0xFFE84026"。第二个参数为颜色所占比重,若设置为负数或是非数值类型,则将比重置为0。
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci分段渐变环最大显示段数为9段,若多于9段,则多于部分不显示。
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci**参数:** 
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci| 参数名 | 类型                                                         | 必填 | 说明                                                         |
137e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
138e41f4b71Sopenharmony_ci| colors | [ResourceColor<sup>11+</sup>](ts-types.md#resourcecolor)&nbsp;\|&nbsp;[LinearGradient<sup>11+</sup>](ts-basic-components-datapanel.md#lineargradient10)&nbsp;\|&nbsp;Array&lt;[[ResourceColor](ts-types.md#resourcecolor)&nbsp;\|&nbsp;[LinearGradient<sup>11+</sup>](ts-basic-components-datapanel.md#lineargradient10)&nbsp;\,&nbsp;number]&gt; | 是   | 量规图的颜色,支持分段颜色设置。<br/>API version 9 默认值:Color.Black<br/>API version 11默认值:<br/>若不传颜色,或者数组为空,无法确定圆环类型及颜色,则圆环颜色为"0xFF64BB5C"、"0xFFF7CE00"、"0xFFE84026"的渐变环。<br/>若传入颜色,但颜色值有误,则该颜色为"0xFFE84026"。 |
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci### strokeWidth
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_cistrokeWidth(length: Length)
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci设置环形量规图的环形厚度。
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci**卡片能力:** 从API version 9开始,该接口支持在ArkTS卡片中使用。
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci**参数:** 
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci| 参数名 | 类型                         | 必填 | 说明                                                         |
155e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | ------------------------------------------------------------ |
156e41f4b71Sopenharmony_ci| length | [Length](ts-types.md#length) | 是   | 环形量规图的环形厚度。<br/>默认值:4<br/>单位:vp<br/>**说明:** <br/>设置小于0的值时,按默认值显示。<br/>不支持百分比。 |
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci### description<sup>11+</sup>
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_cidescription(value: CustomBuilder)
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci设置说明内容。
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**参数:** 
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci| 参数名 | 类型                                        | 必填 | 说明                                                         |
171e41f4b71Sopenharmony_ci| ------ | ------------------------------------------- | ---- | ------------------------------------------------------------ |
172e41f4b71Sopenharmony_ci| value  | [CustomBuilder](ts-types.md#custombuilder8) | 是   | 说明内容。<br/>**说明:** <br/>@Builder中的内容由开发者自定义,建议使用文本或者图片。<br/>若自定义部分的宽高为百分比形式,则基准范围为圆环直径的44.4%*25.4%的矩形(图片为28.6%*28.6%),距离圆环底部0vp,左右居中。<br/>设置null则不显示内容。<br/>不设置则依赖是否设置数据最大最小值。<br/>若设置最大最小值或者只设置其中一个,则显示最大最小值。<br/>若未设置最大最小值,则不显示内容。<br/>最大最小值显示在圆环底部,位置不可移动,若圆环开口角度设置不恰当,存在圆环遮挡文字的情况。 |
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci### trackShadow<sup>11+</sup>
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_citrackShadow(value: GaugeShadowOptions)
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci设置阴影样式。
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**参数:** 
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci| 参数名 | 类型                                                | 必填 | 说明                                                         |
187e41f4b71Sopenharmony_ci| ------ | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
188e41f4b71Sopenharmony_ci| value  | [GaugeShadowOptions](#gaugeshadowoptions11对象说明) | 是   | 阴影样式。<br/>**说明:** <br/>阴影颜色与圆环颜色一致。<br/>设置null为不开启投影。 |
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci### indicator<sup>11+</sup>
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ciindicator(value: GaugeIndicatorOptions)
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci设置指针样式。
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**参数:** 
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci| 参数名 | 类型                                                      | 必填 | 说明                                                  |
203e41f4b71Sopenharmony_ci| ------ | --------------------------------------------------------- | ---- | ----------------------------------------------------- |
204e41f4b71Sopenharmony_ci| value  | [GaugeIndicatorOptions](#gaugeindicatoroptions11对象说明) | 是   | 指针样式。<br/>**说明:** <br/>设置null则不显示指针。 |
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci### privacySensitive<sup>12+</sup>
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ciprivacySensitive(isPrivacySensitiveMode: Optional\<boolean\>)
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci设置隐私敏感。
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci**卡片能力:** 从API version 12开始,该接口支持在ArkTS卡片中使用。
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci**参数:** 
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci| 参数名 | 类型                                                      | 必填 | 说明                                                  |
221e41f4b71Sopenharmony_ci| ------ | --------------------------------------------------------- | ---- | ----------------------------------------------------- |
222e41f4b71Sopenharmony_ci| isPrivacySensitiveMode  | [Optional\<boolean\>] | 是   | 设置隐私敏感,隐私模式下Gauge指针指向0位置,最大值最小值文本将被遮罩,量程显示灰色或者底色。<br/>**说明:** <br/>设置null则不敏感。<br/>[需要卡片框架支持。](./ts-universal-attributes-obscured.md) |
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci### contentModifier<sup>12+</sup>
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_cicontentModifier(modifier: ContentModifier\<GaugeConfiguration>)
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci定制Slider内容区的方法。
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci**参数:**
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci| 参数名 | 类型                                          | 必填 | 说明                                             |
237e41f4b71Sopenharmony_ci| ------ | --------------------------------------------- | ---- | ------------------------------------------------ |
238e41f4b71Sopenharmony_ci| modifier  | [ContentModifier\<GaugeConfiguration>](#gaugeconfiguration12对象说明) | 是   | 在Gauge组件上,定制内容区的方法。<br/>modifier: 内容修改器,开发者需要自定义class实现ContentModifier接口。 |
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci## GaugeShadowOptions<sup>11+</sup>对象说明
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ciGaugeShadowOptions继承自[MultiShadowOptions](ts-types.md#multishadowoptions10),具有MultiShadowOptions的全部属性。
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci## GaugeIndicatorOptions<sup>11+</sup>对象说明
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci| 名称          | 类型 | 必填 | 说明 |
253e41f4b71Sopenharmony_ci| ------------- | ------- | ---- | -------- |
254e41f4b71Sopenharmony_ci| icon | [ResourceStr](ts-types.md#resourcestr) | 否 | 图标资源路径。<br/>**说明:** <br/>不配置则使用默认的三角形样式指针。<br/>支持使用svg格式的图标,若使用其他格式,则使用默认的三角形样式指针。 |
255e41f4b71Sopenharmony_ci| space | [Dimension](ts-types.md#dimension10) | 否 | 指针距离圆环外边的间距。(不支持百分比) <br/>默认值:8<br/>单位:vp <br/>**说明:** <br/> 对于默认的三角形样式指针,间距为黑色三角形到圆环外边的间距。<br/> 若设置值小于0,则使用默认值。<br/>若设置值大于圆环半径,则使用默认值。|
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci## GaugeConfiguration<sup>12+</sup>对象说明
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci开发者需要自定义class实现ContentModifier接口。
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.ArkUI.ArkUI.Full
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci| 名称  | 类型    | 必填 | 说明              |
266e41f4b71Sopenharmony_ci| ------ | ------ | ----| ---------------- |
267e41f4b71Sopenharmony_ci| value | number | 是 | 当前数据值。 |
268e41f4b71Sopenharmony_ci| min | number | 是 | 当前数据段最小值。 |
269e41f4b71Sopenharmony_ci| max | number | 是 | 当前数据段最大值。 |
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci## 示例
273e41f4b71Sopenharmony_ci### 示例1
274e41f4b71Sopenharmony_ci示例使用当前数值、说明文本、辅助文本。
275e41f4b71Sopenharmony_ci```ts
276e41f4b71Sopenharmony_ci@Entry
277e41f4b71Sopenharmony_ci@Component
278e41f4b71Sopenharmony_cistruct Gauge1 {
279e41f4b71Sopenharmony_ci  @Builder descriptionBuilder() {
280e41f4b71Sopenharmony_ci    Text('说明文本')
281e41f4b71Sopenharmony_ci      .maxFontSize('30sp')
282e41f4b71Sopenharmony_ci      .minFontSize("10.0vp")
283e41f4b71Sopenharmony_ci      .fontColor("#fffa2a2d")
284e41f4b71Sopenharmony_ci      .fontWeight(FontWeight.Medium)
285e41f4b71Sopenharmony_ci      .width('100%')
286e41f4b71Sopenharmony_ci      .height("100%")
287e41f4b71Sopenharmony_ci      .textAlign(TextAlign.Center)
288e41f4b71Sopenharmony_ci  }
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci  build() {
291e41f4b71Sopenharmony_ci    Column() {
292e41f4b71Sopenharmony_ci      Gauge({ value: 50, min: 1, max: 100 }) {
293e41f4b71Sopenharmony_ci        Column() {
294e41f4b71Sopenharmony_ci          Text('50')
295e41f4b71Sopenharmony_ci            .fontWeight(FontWeight.Medium)
296e41f4b71Sopenharmony_ci            .width('62%')
297e41f4b71Sopenharmony_ci            .fontColor("#ff182431")
298e41f4b71Sopenharmony_ci            .maxFontSize("60.0vp")
299e41f4b71Sopenharmony_ci            .minFontSize("30.0vp")
300e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
301e41f4b71Sopenharmony_ci            .margin({ top: '35%' })
302e41f4b71Sopenharmony_ci            .textOverflow({ overflow: TextOverflow.Ellipsis })
303e41f4b71Sopenharmony_ci            .maxLines(1)
304e41f4b71Sopenharmony_ci          Text('辅助文本')
305e41f4b71Sopenharmony_ci            .maxFontSize("16.0fp")
306e41f4b71Sopenharmony_ci            .minFontSize("10.0vp")
307e41f4b71Sopenharmony_ci            .fontColor($r('sys.color.ohos_id_color_text_secondary'))
308e41f4b71Sopenharmony_ci            .fontColor($r('sys.color.ohos_id_color_text_secondary'))
309e41f4b71Sopenharmony_ci            .fontWeight(FontWeight.Regular)
310e41f4b71Sopenharmony_ci            .width('67.4%')
311e41f4b71Sopenharmony_ci            .height('9.5%')
312e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
313e41f4b71Sopenharmony_ci        }.width('100%').height('100%')
314e41f4b71Sopenharmony_ci      }
315e41f4b71Sopenharmony_ci      .value(50)
316e41f4b71Sopenharmony_ci      .startAngle(210)
317e41f4b71Sopenharmony_ci      .endAngle(150)
318e41f4b71Sopenharmony_ci      .colors([[new LinearGradient([{ color: "#deb6fb", offset: 0 }, { color: "#ac49f5", offset: 1 }]), 9],
319e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#bbb7fc", offset: 0 }, { color: "#564af7", offset: 1 }]), 8],
320e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#f5b5c2", offset: 0 }, { color: "#e64566", offset: 1 }]), 7],
321e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#f8c5a6", offset: 0 }, { color: "#ed6f21", offset: 1 }]), 6],
322e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#fceb99", offset: 0 }, { color: "#f7ce00", offset: 1 }]), 5],
323e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#dbefa5", offset: 0 }, { color: "#a5d61d", offset: 1 }]), 4],
324e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#c1e4be", offset: 0 }, { color: "#64bb5c", offset: 1 }]), 3],
325e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#c0ece5", offset: 0 }, { color: "#61cfbe", offset: 1 }]), 2],
326e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#b5e0f4", offset: 0 }, { color: "#46b1e3", offset: 1 }]), 1]])
327e41f4b71Sopenharmony_ci      .width('80%')
328e41f4b71Sopenharmony_ci      .height('80%')
329e41f4b71Sopenharmony_ci      .strokeWidth(18)
330e41f4b71Sopenharmony_ci      .trackShadow({ radius: 7, offsetX: 7, offsetY: 7 })
331e41f4b71Sopenharmony_ci      .description(this.descriptionBuilder)
332e41f4b71Sopenharmony_ci      .padding(18)
333e41f4b71Sopenharmony_ci    }.margin({ top: 40 }).width('100%').height('100%')
334e41f4b71Sopenharmony_ci  }
335e41f4b71Sopenharmony_ci}
336e41f4b71Sopenharmony_ci```
337e41f4b71Sopenharmony_ci![gauge](figures/gauge-image1.png)
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci### 示例2
340e41f4b71Sopenharmony_ci示例使用当前数值、图标。
341e41f4b71Sopenharmony_ci```ts
342e41f4b71Sopenharmony_ci@Entry
343e41f4b71Sopenharmony_ci@Component
344e41f4b71Sopenharmony_cistruct Gauge2 {
345e41f4b71Sopenharmony_ci  @Builder descriptionBuilderImage() {
346e41f4b71Sopenharmony_ci    Image($r('sys.media.ohos_ic_public_clock')).width(72).height(72)
347e41f4b71Sopenharmony_ci  }
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci  build() {
350e41f4b71Sopenharmony_ci    Column() {
351e41f4b71Sopenharmony_ci      Gauge({ value: 50, min: 1, max: 100 }) {
352e41f4b71Sopenharmony_ci        Column() {
353e41f4b71Sopenharmony_ci          Text('50')
354e41f4b71Sopenharmony_ci            .fontWeight(FontWeight.Medium)
355e41f4b71Sopenharmony_ci            .width('62%')
356e41f4b71Sopenharmony_ci            .fontColor("#ff182431")
357e41f4b71Sopenharmony_ci            .maxFontSize("60.0vp")
358e41f4b71Sopenharmony_ci            .minFontSize("30.0vp")
359e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
360e41f4b71Sopenharmony_ci            .margin({ top: '35%' })
361e41f4b71Sopenharmony_ci            .textOverflow({ overflow: TextOverflow.Ellipsis })
362e41f4b71Sopenharmony_ci            .maxLines(1)
363e41f4b71Sopenharmony_ci        }.width('100%').height('100%')
364e41f4b71Sopenharmony_ci      }
365e41f4b71Sopenharmony_ci      .startAngle(210)
366e41f4b71Sopenharmony_ci      .endAngle(150)
367e41f4b71Sopenharmony_ci      .colors('#cca5d61d')
368e41f4b71Sopenharmony_ci      .width('80%')
369e41f4b71Sopenharmony_ci      .height('80%')
370e41f4b71Sopenharmony_ci      .strokeWidth(18)
371e41f4b71Sopenharmony_ci      .description(this.descriptionBuilderImage)
372e41f4b71Sopenharmony_ci      .padding(18)
373e41f4b71Sopenharmony_ci    }.margin({ top: 40 }).width('100%').height('100%')
374e41f4b71Sopenharmony_ci  }
375e41f4b71Sopenharmony_ci}
376e41f4b71Sopenharmony_ci```
377e41f4b71Sopenharmony_ci![gauge](figures/gauge-image2.png)
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci### 示例3
380e41f4b71Sopenharmony_ci示例使用当前数值、说明文本。
381e41f4b71Sopenharmony_ci```ts
382e41f4b71Sopenharmony_ci@Entry
383e41f4b71Sopenharmony_ci@Component
384e41f4b71Sopenharmony_cistruct Gauge3 {
385e41f4b71Sopenharmony_ci  @Builder descriptionBuilder() {
386e41f4b71Sopenharmony_ci    Text('说明文本')
387e41f4b71Sopenharmony_ci      .maxFontSize('30sp')
388e41f4b71Sopenharmony_ci      .minFontSize("10.0vp")
389e41f4b71Sopenharmony_ci      .fontColor("#fffa2a2d")
390e41f4b71Sopenharmony_ci      .fontWeight(FontWeight.Medium)
391e41f4b71Sopenharmony_ci      .width('100%')
392e41f4b71Sopenharmony_ci      .height("100%")
393e41f4b71Sopenharmony_ci      .textAlign(TextAlign.Center)
394e41f4b71Sopenharmony_ci  }
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci  build() {
397e41f4b71Sopenharmony_ci    Column() {
398e41f4b71Sopenharmony_ci      Column() {
399e41f4b71Sopenharmony_ci        Gauge({ value: 50, min: 1, max: 100 }) {
400e41f4b71Sopenharmony_ci          Column() {
401e41f4b71Sopenharmony_ci            Text('50')
402e41f4b71Sopenharmony_ci              .fontWeight(FontWeight.Medium)
403e41f4b71Sopenharmony_ci              .width('62%')
404e41f4b71Sopenharmony_ci              .fontColor("#ff182431")
405e41f4b71Sopenharmony_ci              .maxFontSize("60.0vp")
406e41f4b71Sopenharmony_ci              .minFontSize("30.0vp")
407e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
408e41f4b71Sopenharmony_ci              .margin({ top: '35%' })
409e41f4b71Sopenharmony_ci              .textOverflow({ overflow: TextOverflow.Ellipsis })
410e41f4b71Sopenharmony_ci              .maxLines(1)
411e41f4b71Sopenharmony_ci          }.width('100%').height('100%')
412e41f4b71Sopenharmony_ci        }
413e41f4b71Sopenharmony_ci        .startAngle(210)
414e41f4b71Sopenharmony_ci        .endAngle(150)
415e41f4b71Sopenharmony_ci        .colors([[new LinearGradient([{ color: "#deb6fb", offset: 0 }, { color: "#ac49f5", offset: 1 }]), 9],
416e41f4b71Sopenharmony_ci          [new LinearGradient([{ color: "#bbb7fc", offset: 0 }, { color: "#564af7", offset: 1 }]), 8],
417e41f4b71Sopenharmony_ci          [new LinearGradient([{ color: "#f5b5c2", offset: 0 }, { color: "#e64566", offset: 1 }]), 7],
418e41f4b71Sopenharmony_ci          [new LinearGradient([{ color: "#f8c5a6", offset: 0 }, { color: "#ed6f21", offset: 1 }]), 6],
419e41f4b71Sopenharmony_ci          [new LinearGradient([{ color: "#fceb99", offset: 0 }, { color: "#f7ce00", offset: 1 }]), 5],
420e41f4b71Sopenharmony_ci          [new LinearGradient([{ color: "#dbefa5", offset: 0 }, { color: "#a5d61d", offset: 1 }]), 4],
421e41f4b71Sopenharmony_ci          [new LinearGradient([{ color: "#c1e4be", offset: 0 }, { color: "#64bb5c", offset: 1 }]), 3],
422e41f4b71Sopenharmony_ci          [new LinearGradient([{ color: "#c0ece5", offset: 0 }, { color: "#61cfbe", offset: 1 }]), 2],
423e41f4b71Sopenharmony_ci          [new LinearGradient([{ color: "#b5e0f4", offset: 0 }, { color: "#46b1e3", offset: 1 }]), 1]])
424e41f4b71Sopenharmony_ci        .width('80%')
425e41f4b71Sopenharmony_ci        .height('80%')
426e41f4b71Sopenharmony_ci        .strokeWidth(18)
427e41f4b71Sopenharmony_ci        .description(this.descriptionBuilder)
428e41f4b71Sopenharmony_ci        .trackShadow({ radius: 7, offsetX: 7, offsetY: 7 })
429e41f4b71Sopenharmony_ci        .padding(18)
430e41f4b71Sopenharmony_ci      }.margin({ top: 40 }).width('100%').height('100%')
431e41f4b71Sopenharmony_ci    }
432e41f4b71Sopenharmony_ci  }
433e41f4b71Sopenharmony_ci}
434e41f4b71Sopenharmony_ci```
435e41f4b71Sopenharmony_ci![gauge](figures/gauge-image3.png)
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci### 示例4
438e41f4b71Sopenharmony_ci示例使用当前数值、辅助文本。
439e41f4b71Sopenharmony_ci```ts
440e41f4b71Sopenharmony_ci@Entry
441e41f4b71Sopenharmony_ci@Component
442e41f4b71Sopenharmony_cistruct Gauge4 {
443e41f4b71Sopenharmony_ci  build() {
444e41f4b71Sopenharmony_ci    Column() {
445e41f4b71Sopenharmony_ci      Gauge({ value: 50, min: 1, max: 100 }) {
446e41f4b71Sopenharmony_ci        Column() {
447e41f4b71Sopenharmony_ci          Text('50')
448e41f4b71Sopenharmony_ci            .maxFontSize("72.0vp")
449e41f4b71Sopenharmony_ci            .minFontSize("10.0vp")
450e41f4b71Sopenharmony_ci            .fontColor("#ff182431")
451e41f4b71Sopenharmony_ci            .width('40%')
452e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
453e41f4b71Sopenharmony_ci            .margin({ top: '35%' })
454e41f4b71Sopenharmony_ci            .textOverflow({ overflow: TextOverflow.Ellipsis })
455e41f4b71Sopenharmony_ci            .maxLines(1)
456e41f4b71Sopenharmony_ci          Text('辅助文本')
457e41f4b71Sopenharmony_ci            .maxFontSize("30.0vp")
458e41f4b71Sopenharmony_ci            .minFontSize("18.0vp")
459e41f4b71Sopenharmony_ci            .fontWeight(FontWeight.Medium)
460e41f4b71Sopenharmony_ci            .fontColor($r('sys.color.ohos_id_color_text_secondary'))
461e41f4b71Sopenharmony_ci            .width('62%')
462e41f4b71Sopenharmony_ci            .height('15.9%')
463e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
464e41f4b71Sopenharmony_ci        }.width('100%').height('100%')
465e41f4b71Sopenharmony_ci      }
466e41f4b71Sopenharmony_ci      .startAngle(210)
467e41f4b71Sopenharmony_ci      .endAngle(150)
468e41f4b71Sopenharmony_ci      .colors([[new LinearGradient([{ color: "#deb6fb", offset: 0 }, { color: "#ac49f5", offset: 1 }]), 9],
469e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#bbb7fc", offset: 0 }, { color: "#564af7", offset: 1 }]), 8],
470e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#f5b5c2", offset: 0 }, { color: "#e64566", offset: 1 }]), 7],
471e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#f8c5a6", offset: 0 }, { color: "#ed6f21", offset: 1 }]), 6],
472e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#fceb99", offset: 0 }, { color: "#f7ce00", offset: 1 }]), 5],
473e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#dbefa5", offset: 0 }, { color: "#a5d61d", offset: 1 }]), 4],
474e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#c1e4be", offset: 0 }, { color: "#64bb5c", offset: 1 }]), 3],
475e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#c0ece5", offset: 0 }, { color: "#61cfbe", offset: 1 }]), 2],
476e41f4b71Sopenharmony_ci        [new LinearGradient([{ color: "#b5e0f4", offset: 0 }, { color: "#46b1e3", offset: 1 }]), 1]])
477e41f4b71Sopenharmony_ci      .width('80%')
478e41f4b71Sopenharmony_ci      .height('80%')
479e41f4b71Sopenharmony_ci      .strokeWidth(18)
480e41f4b71Sopenharmony_ci      .description(null)
481e41f4b71Sopenharmony_ci      .trackShadow({ radius: 7, offsetX: 7, offsetY: 7 })
482e41f4b71Sopenharmony_ci      .padding(18)
483e41f4b71Sopenharmony_ci    }.margin({ top: 40 }).width('100%').height('100%')
484e41f4b71Sopenharmony_ci  }
485e41f4b71Sopenharmony_ci}
486e41f4b71Sopenharmony_ci```
487e41f4b71Sopenharmony_ci![gauge](figures/gauge-image4.png)
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci### 示例5
490e41f4b71Sopenharmony_ci示例使用当前数值、最大最小数值。
491e41f4b71Sopenharmony_ci```ts
492e41f4b71Sopenharmony_ci@Entry
493e41f4b71Sopenharmony_ci@Component
494e41f4b71Sopenharmony_cistruct Gauge5 {
495e41f4b71Sopenharmony_ci  build() {
496e41f4b71Sopenharmony_ci    Column() {
497e41f4b71Sopenharmony_ci      Gauge({ value: 50, min: 1, max: 100 }) {
498e41f4b71Sopenharmony_ci        Column() {
499e41f4b71Sopenharmony_ci          Text('50')
500e41f4b71Sopenharmony_ci            .maxFontSize("80sp")
501e41f4b71Sopenharmony_ci            .minFontSize("60.0vp")
502e41f4b71Sopenharmony_ci            .fontWeight(FontWeight.Medium)
503e41f4b71Sopenharmony_ci            .fontColor("#ff182431")
504e41f4b71Sopenharmony_ci            .width('40%')
505e41f4b71Sopenharmony_ci            .height('30%')
506e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
507e41f4b71Sopenharmony_ci            .margin({ top: '22.2%' })
508e41f4b71Sopenharmony_ci            .textOverflow({ overflow: TextOverflow.Ellipsis })
509e41f4b71Sopenharmony_ci            .maxLines(1)
510e41f4b71Sopenharmony_ci        }.width('100%').height('100%')
511e41f4b71Sopenharmony_ci      }
512e41f4b71Sopenharmony_ci      .startAngle(225)
513e41f4b71Sopenharmony_ci      .endAngle(135)
514e41f4b71Sopenharmony_ci      .colors(new LinearGradient([{ color: "#e84026", offset: 0 },
515e41f4b71Sopenharmony_ci        { color: "#f7ce00", offset: 0.6 },
516e41f4b71Sopenharmony_ci        { color: "#64bb5c", offset: 1 }]))
517e41f4b71Sopenharmony_ci      .width('80%')
518e41f4b71Sopenharmony_ci      .height('80%')
519e41f4b71Sopenharmony_ci      .strokeWidth(18)
520e41f4b71Sopenharmony_ci      .trackShadow({ radius: 7, offsetX: 7, offsetY: 7 })
521e41f4b71Sopenharmony_ci      .padding(18)
522e41f4b71Sopenharmony_ci    }.margin({ top: 40 }).width('100%').height('100%')
523e41f4b71Sopenharmony_ci  }
524e41f4b71Sopenharmony_ci}
525e41f4b71Sopenharmony_ci```
526e41f4b71Sopenharmony_ci![gauge](figures/gauge-image5.png)
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_ci### 示例6
529e41f4b71Sopenharmony_ci示例使用当前数值、最大最小数值、辅助文本。
530e41f4b71Sopenharmony_ci```ts
531e41f4b71Sopenharmony_ci@Entry
532e41f4b71Sopenharmony_ci@Component
533e41f4b71Sopenharmony_cistruct Gauge6 {
534e41f4b71Sopenharmony_ci  build() {
535e41f4b71Sopenharmony_ci    Column() {
536e41f4b71Sopenharmony_ci      Gauge({ value: 50, min: 1, max: 100 }) {
537e41f4b71Sopenharmony_ci        Column() {
538e41f4b71Sopenharmony_ci          Text('50')
539e41f4b71Sopenharmony_ci            .maxFontSize('60sp')
540e41f4b71Sopenharmony_ci            .minFontSize('30.0vp')
541e41f4b71Sopenharmony_ci            .fontWeight(FontWeight.Medium)
542e41f4b71Sopenharmony_ci            .fontColor("#ff182431")
543e41f4b71Sopenharmony_ci            .width('62%')
544e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
545e41f4b71Sopenharmony_ci            .margin({ top: '35%' })
546e41f4b71Sopenharmony_ci            .textOverflow({ overflow: TextOverflow.Ellipsis })
547e41f4b71Sopenharmony_ci            .maxLines(1)
548e41f4b71Sopenharmony_ci          Text('辅助文本')
549e41f4b71Sopenharmony_ci            .maxFontSize('16sp')
550e41f4b71Sopenharmony_ci            .minFontSize("10.0vp")
551e41f4b71Sopenharmony_ci            .fontColor($r('sys.color.ohos_id_color_text_secondary'))
552e41f4b71Sopenharmony_ci            .fontWeight(FontWeight.Regular)
553e41f4b71Sopenharmony_ci            .width('67.4%')
554e41f4b71Sopenharmony_ci            .height('9.5%')
555e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
556e41f4b71Sopenharmony_ci        }.width('100%').height('100%')
557e41f4b71Sopenharmony_ci      }
558e41f4b71Sopenharmony_ci      .startAngle(225)
559e41f4b71Sopenharmony_ci      .endAngle(135)
560e41f4b71Sopenharmony_ci      .colors(Color.Red)
561e41f4b71Sopenharmony_ci      .width('80%')
562e41f4b71Sopenharmony_ci      .height('80%')
563e41f4b71Sopenharmony_ci      .indicator(null)
564e41f4b71Sopenharmony_ci      .strokeWidth(18)
565e41f4b71Sopenharmony_ci      .trackShadow({ radius: 7, offsetX: 7, offsetY: 7 })
566e41f4b71Sopenharmony_ci      .padding(18)
567e41f4b71Sopenharmony_ci    }.margin({ top: 40 }).width('100%').height('100%')
568e41f4b71Sopenharmony_ci  }
569e41f4b71Sopenharmony_ci}
570e41f4b71Sopenharmony_ci```
571e41f4b71Sopenharmony_ci![gauge](figures/gauge-image6.png)
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ci### 示例7
574e41f4b71Sopenharmony_ci示例使用当前数值、最大最小数值。
575e41f4b71Sopenharmony_ci```ts
576e41f4b71Sopenharmony_ci@Entry
577e41f4b71Sopenharmony_ci@Component
578e41f4b71Sopenharmony_cistruct Gauge7 {
579e41f4b71Sopenharmony_ci  build() {
580e41f4b71Sopenharmony_ci    Column() {
581e41f4b71Sopenharmony_ci      Gauge({ value: 50, min: 1, max: 100 }) {
582e41f4b71Sopenharmony_ci        Column() {
583e41f4b71Sopenharmony_ci          Text('50')
584e41f4b71Sopenharmony_ci            .maxFontSize('60sp')
585e41f4b71Sopenharmony_ci            .minFontSize('30.0vp')
586e41f4b71Sopenharmony_ci            .fontWeight(FontWeight.Medium)
587e41f4b71Sopenharmony_ci            .fontColor("#ff182431")
588e41f4b71Sopenharmony_ci            .width('62%')
589e41f4b71Sopenharmony_ci            .textAlign(TextAlign.Center)
590e41f4b71Sopenharmony_ci            .margin({ top: '35%' })
591e41f4b71Sopenharmony_ci            .textOverflow({ overflow: TextOverflow.Ellipsis })
592e41f4b71Sopenharmony_ci            .maxLines(1)
593e41f4b71Sopenharmony_ci        }.width('100%').height('100%')
594e41f4b71Sopenharmony_ci      }
595e41f4b71Sopenharmony_ci      .startAngle(225)
596e41f4b71Sopenharmony_ci      .endAngle(135)
597e41f4b71Sopenharmony_ci      .colors(Color.Red)
598e41f4b71Sopenharmony_ci      .width('80%')
599e41f4b71Sopenharmony_ci      .height('80%')
600e41f4b71Sopenharmony_ci      .indicator(null)
601e41f4b71Sopenharmony_ci      .strokeWidth(18)
602e41f4b71Sopenharmony_ci      .trackShadow({ radius: 7, offsetX: 7, offsetY: 7 })
603e41f4b71Sopenharmony_ci      .padding(18)
604e41f4b71Sopenharmony_ci    }.margin({ top: 40 }).width('100%').height('100%')
605e41f4b71Sopenharmony_ci  }
606e41f4b71Sopenharmony_ci}
607e41f4b71Sopenharmony_ci```
608e41f4b71Sopenharmony_ci![gauge](figures/gauge-image7.png)
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci### 示例8
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci```ts
615e41f4b71Sopenharmony_ci// xxx.ets
616e41f4b71Sopenharmony_ci//该示例实现了Gauge组件使用Builder定制内容区,使用了环形图表组件,按钮和文本框。点击增加按钮,环形图表指针位置会向右偏移,反之点减少按钮环形图表指针位置会向左偏移。
617e41f4b71Sopenharmony_ci@Builder
618e41f4b71Sopenharmony_cifunction buildGauge(config: GaugeConfiguration) {
619e41f4b71Sopenharmony_ci  Column({ space: 30 }) {
620e41f4b71Sopenharmony_ci    Row() {
621e41f4b71Sopenharmony_ci      Text('【ContentModifier】 value:' + JSON.stringify((config.contentModifier as MyGaugeStyle).value) +
622e41f4b71Sopenharmony_ci        '  min:' + JSON.stringify((config.contentModifier as MyGaugeStyle).min) +
623e41f4b71Sopenharmony_ci        '  max:' + JSON.stringify((config.contentModifier as MyGaugeStyle).max))
624e41f4b71Sopenharmony_ci        .fontSize(12)
625e41f4b71Sopenharmony_ci    }
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci    Text('【Config】value:' + config.value + '  min:' + config.min + '  max:' + config.max).fontSize(12)
628e41f4b71Sopenharmony_ci    Gauge({
629e41f4b71Sopenharmony_ci      value: config.value,
630e41f4b71Sopenharmony_ci      min: config.min,
631e41f4b71Sopenharmony_ci      max: config.max
632e41f4b71Sopenharmony_ci    }).width("50%")
633e41f4b71Sopenharmony_ci  }
634e41f4b71Sopenharmony_ci  .width("100%")
635e41f4b71Sopenharmony_ci  .padding(20)
636e41f4b71Sopenharmony_ci  .margin({ top: 5 })
637e41f4b71Sopenharmony_ci  .alignItems(HorizontalAlign.Center)
638e41f4b71Sopenharmony_ci}
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ciclass MyGaugeStyle implements ContentModifier<GaugeConfiguration> {
641e41f4b71Sopenharmony_ci  value: number = 0
642e41f4b71Sopenharmony_ci  min: number = 0
643e41f4b71Sopenharmony_ci  max: number = 0
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci  constructor(value: number, min: number, max: number) {
646e41f4b71Sopenharmony_ci    this.value = value
647e41f4b71Sopenharmony_ci    this.min = min
648e41f4b71Sopenharmony_ci    this.max = max
649e41f4b71Sopenharmony_ci  }
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ci  applyContent(): WrappedBuilder<[GaugeConfiguration]> {
652e41f4b71Sopenharmony_ci    return wrapBuilder(buildGauge)
653e41f4b71Sopenharmony_ci  }
654e41f4b71Sopenharmony_ci}
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci@Entry
657e41f4b71Sopenharmony_ci@Component
658e41f4b71Sopenharmony_cistruct refreshExample {
659e41f4b71Sopenharmony_ci  @State gaugeValue: number = 20
660e41f4b71Sopenharmony_ci  @State gaugeMin: number = 0
661e41f4b71Sopenharmony_ci  @State gaugeMax: number = 100
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci  build() {
664e41f4b71Sopenharmony_ci    Column({ space: 20 }) {
665e41f4b71Sopenharmony_ci      Gauge({
666e41f4b71Sopenharmony_ci        value: this.gaugeValue,
667e41f4b71Sopenharmony_ci        min: this.gaugeMin,
668e41f4b71Sopenharmony_ci        max: this.gaugeMax
669e41f4b71Sopenharmony_ci      })
670e41f4b71Sopenharmony_ci        .contentModifier(new MyGaugeStyle(30, 10, 100))
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci      Column({ space: 20 }) {
673e41f4b71Sopenharmony_ci        Row({ space: 20 }) {
674e41f4b71Sopenharmony_ci          Button('增加').onClick(() => {
675e41f4b71Sopenharmony_ci            if (this.gaugeValue < this.gaugeMax) {
676e41f4b71Sopenharmony_ci              this.gaugeValue += 1
677e41f4b71Sopenharmony_ci            }
678e41f4b71Sopenharmony_ci          })
679e41f4b71Sopenharmony_ci          Button('减少').onClick(() => {
680e41f4b71Sopenharmony_ci            if (this.gaugeValue > this.gaugeMin) {
681e41f4b71Sopenharmony_ci              this.gaugeValue -= 1
682e41f4b71Sopenharmony_ci            }
683e41f4b71Sopenharmony_ci          })
684e41f4b71Sopenharmony_ci        }
685e41f4b71Sopenharmony_ci      }.width('100%')
686e41f4b71Sopenharmony_ci    }.width('100%').margin({ top: 5 })
687e41f4b71Sopenharmony_ci  }
688e41f4b71Sopenharmony_ci}
689e41f4b71Sopenharmony_ci```
690e41f4b71Sopenharmony_ci![gauge](figures/gauge_builder.gif)
691e41f4b71Sopenharmony_ci
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_ci### 示例9
694e41f4b71Sopenharmony_ci
695e41f4b71Sopenharmony_ci该示例展示了如何配置隐私隐藏,效果展示需要卡片框架支持
696e41f4b71Sopenharmony_ci
697e41f4b71Sopenharmony_ci```ts
698e41f4b71Sopenharmony_ci@Entry
699e41f4b71Sopenharmony_ci@Component
700e41f4b71Sopenharmony_cistruct GaugeExample {
701e41f4b71Sopenharmony_ci  build() {
702e41f4b71Sopenharmony_ci    Scroll() {
703e41f4b71Sopenharmony_ci      Column({ space: 15 }) {
704e41f4b71Sopenharmony_ci        Row() {
705e41f4b71Sopenharmony_ci          Gauge({ value: 50, min: 1, max: 100 }) {
706e41f4b71Sopenharmony_ci            Column() {
707e41f4b71Sopenharmony_ci              Text('60')
708e41f4b71Sopenharmony_ci                .maxFontSize("180sp")
709e41f4b71Sopenharmony_ci                .minFontSize("160.0vp")
710e41f4b71Sopenharmony_ci                .fontWeight(FontWeight.Medium)
711e41f4b71Sopenharmony_ci                .fontColor("#ff182431")
712e41f4b71Sopenharmony_ci                .width('40%')
713e41f4b71Sopenharmony_ci                .height('30%')
714e41f4b71Sopenharmony_ci                .textAlign(TextAlign.Center)
715e41f4b71Sopenharmony_ci                .margin({ top: '22.2%' })
716e41f4b71Sopenharmony_ci                .textOverflow({ overflow: TextOverflow.Ellipsis })
717e41f4b71Sopenharmony_ci                .maxLines(1)
718e41f4b71Sopenharmony_ci            }.width('100%').height('100%')
719e41f4b71Sopenharmony_ci          }
720e41f4b71Sopenharmony_ci          .startAngle(225)
721e41f4b71Sopenharmony_ci          .endAngle(135)
722e41f4b71Sopenharmony_ci          .colors(Color.Red)
723e41f4b71Sopenharmony_ci          .width('80%')
724e41f4b71Sopenharmony_ci          .height('80%')
725e41f4b71Sopenharmony_ci          .strokeWidth(18)
726e41f4b71Sopenharmony_ci          .trackShadow({ radius: 7, offsetX: 7, offsetY: 7 })
727e41f4b71Sopenharmony_ci          .padding(18)
728e41f4b71Sopenharmony_ci          .privacySensitive(true)
729e41f4b71Sopenharmony_ci        }
730e41f4b71Sopenharmony_ci      }
731e41f4b71Sopenharmony_ci    }
732e41f4b71Sopenharmony_ci  }
733e41f4b71Sopenharmony_ci}
734e41f4b71Sopenharmony_ci```
735e41f4b71Sopenharmony_ci![gauge](figures/gauge-privacysensitive.gif)