1e41f4b71Sopenharmony_ci# DataPanel 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **\<DataPanel>** component displays proportions in a chart. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## Child Components 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ciNot supported 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## APIs 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciDataPanel(options: DataPanelOptions) 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Parameters** 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 28e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 29e41f4b71Sopenharmony_ci| options | [DataPanelOptions](#datapaneloptions)| Yes| Parameters of the data panel.| 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci## DataPanelOptions 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description| 36e41f4b71Sopenharmony_ci| ----------------- | -------- | ----- | -------- | 37e41f4b71Sopenharmony_ci| values | number[] | Yes | Data value list. A maximum of nine values are supported. If more than nine values are set, only the first nine ones are used. A value less than 0 evaluates to the value **0**.| 38e41f4b71Sopenharmony_ci| max | number | No | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion.<br>Default value: **100**| 39e41f4b71Sopenharmony_ci| type<sup>8+</sup> | [DataPanelType](#datapaneltype8) | No| Type of the data panel (dynamic modification is not supported).<br>Default value: **DataPanelType.Circle**| 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci## DataPanelType<sup>8+</sup> 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ciThis API can be used in ArkTS widgets since API version 9. 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci| Name| Description| 49e41f4b71Sopenharmony_ci| -------| ------------ | 50e41f4b71Sopenharmony_ci| Line | Line data panel.| 51e41f4b71Sopenharmony_ci| Circle | Circle data panel.| 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci## Attributes 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ciIn addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci### closeEffect 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_cicloseEffect(value: boolean) 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ciSets whether to disable the rotation and shadow effects for the component. This attribute enables or disables the shadow effect only when [trackShadow](#trackshadow10) is not set. The shadow effect enabled through this attribute is in the default style. 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9. 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci**Parameters** 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 73e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------ | 74e41f4b71Sopenharmony_ci| value | boolean | Yes | Whether to disable the rotation and shadow effects for the component.<br>Default value: **false**| 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci### valueColors<sup>10+</sup> 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_civalueColors(value: Array<ResourceColor | LinearGradient>) 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ciSets an array of data segment colors. 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci**Parameters** 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 89e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | 90e41f4b71Sopenharmony_ci| value | Array<[ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient](#lineargradient10)> | Yes | Array of data segment colors. A value of the **ResourceColor** type indicates a solid color, and A value of the **LinearGradient** type indicates a color gradient.| 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci### trackBackgroundColor<sup>10+</sup> 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_citrackBackgroundColor(value: ResourceColor) 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ciSets the background color. 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci**Parameters** 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 105e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------------------------ | 106e41f4b71Sopenharmony_ci| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Background color.<br>The value is in hexadecimal ARGB notation. The first two digits indicate opacity.<br>Default value: **'#08182431'**| 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci### strokeWidth<sup>10+</sup> 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_cistrokeWidth(value: Length) 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ciSets the stroke width of the border. This attribute does not take effect when the data panel type is **DataPanelType.Line**. 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci**Parameters** 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 121e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | ------------------------------------------------------------ | 122e41f4b71Sopenharmony_ci| value | [Length](ts-types.md#length) | Yes | Stroke width of the border.<br>Default value: **24**<br>Unit: vp<br>**NOTE**<br>A value less than 0 evaluates to the default value.| 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci### trackShadow<sup>10+</sup> 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_citrackShadow(value: DataPanelShadowOptions) 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ciSets the shadow style. 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci**Parameters** 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 137e41f4b71Sopenharmony_ci| ------ | ----------------------------------------------------------- | ---- | ----------------------------------------------------- | 138e41f4b71Sopenharmony_ci| value | [DataPanelShadowOptions](#datapanelshadowoptions10) | Yes | Shadow style.<br>**NOTE**<br>If this attribute is set to **null**, the shadow effect is disabled.| 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci### contentModifier<sup>12+</sup> 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_cicontentModifier(modifier: ContentModifier\<DataPanelConfiguration>) 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ciCreates a content modifier. 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci**Parameters** 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 151e41f4b71Sopenharmony_ci| ------ | --------------------------------------------- | ---- | ------------------------------------------------ | 152e41f4b71Sopenharmony_ci| modifier | [ContentModifier\<DataPanelConfiguration>](#datapanelconfiguration12) | Yes | Content modifier to apply to the current component.<br>**modifier**: content modifier. You need a custom class to implement the **ContentModifier** API.| 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci## DataPanelShadowOptions<sup>10+</sup> 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ciInherits from [MultiShadowOptions](ts-types.md#multishadowoptions10) and has all attributes of **MultiShadowOptions**. 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci| Name | Type| Mandatory| Description| 162e41f4b71Sopenharmony_ci| ------------- | ------- | ---- | -------- | 163e41f4b71Sopenharmony_ci| colors | Array<[ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient](#lineargradient10)> | No| Array of shadow colors for data segments.<br>Default value: same as the value of **valueColors**<br>**NOTE**<br>If the number of the set shadow colors is less than that of the data segments, the number of the displayed shadow colors is the same as the former.<br>If the number of the set shadow colors is greater than that of the data segments, the number of the displayed shadow colors is the same as the latter.| 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ci## LinearGradient<sup>10+</sup> 166e41f4b71Sopenharmony_ci 167e41f4b71Sopenharmony_ciDescribes the linear gradient. 168e41f4b71Sopenharmony_ci 169e41f4b71Sopenharmony_ciLinearGradient(colorStops: ColorStop[]) 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci| Name | Type| Mandatory| Description| 174e41f4b71Sopenharmony_ci| ------------- | ------- | ---- | -------- | 175e41f4b71Sopenharmony_ci| colorStops | [ColorStop](#colorstop10)[] | Yes| Gradient colors and color stops.| 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci## ColorStop<sup>10+</sup> 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ciDescribes the gradient color stop. 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ci| Name | Type| Mandatory| Description| 185e41f4b71Sopenharmony_ci| ------------- | ------- | ---- | -------- | 186e41f4b71Sopenharmony_ci| color | [ResourceColor](ts-types.md#resourcecolor) | Yes| Color value.| 187e41f4b71Sopenharmony_ci| offset | [Length](ts-types.md#length) | Yes| Gradient color stop (proportion value between 0 and 1). A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.<br>**NOTE**<br>If the value is a string that represents a number, it will be converted to a number.<br>For example, **'10vp'** is converted to 10, and **'10%'** is converted to 0.1.| 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ci## DataPanelConfiguration<sup>12+</sup> 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ciYou need a custom class to implement the **ContentModifier** API. 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci| Name | Type | Default Value | Description | 194e41f4b71Sopenharmony_ci| ------ | ------ | ------ |-------------------------------- | 195e41f4b71Sopenharmony_ci| values | number[] | - | Current values of the data panel. The maximum length is 9.| 196e41f4b71Sopenharmony_ci| maxValue | number | 100 | Maximum value displayed in the data panel.| 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci## Example 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci### Example 1 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci```ts 203e41f4b71Sopenharmony_ci// xxx.ets 204e41f4b71Sopenharmony_ci@Entry 205e41f4b71Sopenharmony_ci@Component 206e41f4b71Sopenharmony_cistruct DataPanelExample { 207e41f4b71Sopenharmony_ci public valueArr: number[] = [10, 10, 10, 10, 10, 10, 10, 10, 10] 208e41f4b71Sopenharmony_ci 209e41f4b71Sopenharmony_ci build() { 210e41f4b71Sopenharmony_ci Column({ space: 5 }) { 211e41f4b71Sopenharmony_ci Row() { 212e41f4b71Sopenharmony_ci Stack() { 213e41f4b71Sopenharmony_ci DataPanel({ values: [30], max: 100, type: DataPanelType.Circle }).width(168).height(168) 214e41f4b71Sopenharmony_ci Column() { 215e41f4b71Sopenharmony_ci Text('30').fontSize(35).fontColor('#182431') 216e41f4b71Sopenharmony_ci Text('1.0.0').fontSize(9.33).lineHeight(12.83).fontWeight(500).opacity(0.6) 217e41f4b71Sopenharmony_ci } 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ci Text('%') 220e41f4b71Sopenharmony_ci .fontSize(9.33) 221e41f4b71Sopenharmony_ci .lineHeight(12.83) 222e41f4b71Sopenharmony_ci .fontWeight(500) 223e41f4b71Sopenharmony_ci .opacity(0.6) 224e41f4b71Sopenharmony_ci .position({ x: 104.42, y: 78.17 }) 225e41f4b71Sopenharmony_ci }.margin({ right: 44 }) 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci Stack() { 228e41f4b71Sopenharmony_ci DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Circle }).width(168).height(168) 229e41f4b71Sopenharmony_ci Column() { 230e41f4b71Sopenharmony_ci Text('75').fontSize(35).fontColor('#182431') 231e41f4b71Sopenharmony_ci Text('Used: 98 GB/128 GB') .fontSize(8.17).lineHeight(11.08).fontWeight(500).opacity(0.6) 232e41f4b71Sopenharmony_ci } 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci Text('%') 235e41f4b71Sopenharmony_ci .fontSize(9.33) 236e41f4b71Sopenharmony_ci .lineHeight(12.83) 237e41f4b71Sopenharmony_ci .fontWeight(500) 238e41f4b71Sopenharmony_ci .opacity(0.6) 239e41f4b71Sopenharmony_ci .position({ x: 104.42, y: 78.17 }) 240e41f4b71Sopenharmony_ci } 241e41f4b71Sopenharmony_ci }.margin({ bottom: 59 }) 242e41f4b71Sopenharmony_ci 243e41f4b71Sopenharmony_ci DataPanel({ values: this.valueArr, max: 100, type: DataPanelType.Line }).width(300).height(20) 244e41f4b71Sopenharmony_ci }.width('100%').margin({ top: 5 }) 245e41f4b71Sopenharmony_ci } 246e41f4b71Sopenharmony_ci} 247e41f4b71Sopenharmony_ci``` 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci### Example 2 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ci```ts 254e41f4b71Sopenharmony_ci// xxx.ets 255e41f4b71Sopenharmony_ci@Entry 256e41f4b71Sopenharmony_ci@Component 257e41f4b71Sopenharmony_cistruct LinearGradientDataPanelExample { 258e41f4b71Sopenharmony_ci public values1: number[] = [20, 20, 20, 20] 259e41f4b71Sopenharmony_ci public color1: LinearGradient = new LinearGradient([{ color: "#65EEC9A3", offset: 0 }, { color: "#FFEF629F", offset: 1 }]) 260e41f4b71Sopenharmony_ci public color2: LinearGradient = new LinearGradient([{ color: "#FF67F9D4", offset: 0 }, { color: "#FFFF9554", offset: 1 }]) 261e41f4b71Sopenharmony_ci public colorShadow1: LinearGradient = new LinearGradient([{ color: "#65EEC9A3", offset: 0 }, { color: "#65EF629F", offset: 1 }]) 262e41f4b71Sopenharmony_ci public colorShadow2: LinearGradient = new LinearGradient([{ color: "#65e26709", offset: 0 }, { color: "#65efbd08", offset: 1 }]) 263e41f4b71Sopenharmony_ci public colorShadow3: LinearGradient = new LinearGradient([{ color: "#6572B513", offset: 0 }, { color: "#6508efa6", offset: 1 }]) 264e41f4b71Sopenharmony_ci public colorShadow4: LinearGradient = new LinearGradient([{ color: "#65ed08f5", offset: 0 }, { color: "#65ef0849", offset: 1 }]) 265e41f4b71Sopenharmony_ci @State color3: string = '#00FF00' 266e41f4b71Sopenharmony_ci @State color4: string = '#20FF0000' 267e41f4b71Sopenharmony_ci @State bgColor: string = '#08182431' 268e41f4b71Sopenharmony_ci @State offsetX: number = 15 269e41f4b71Sopenharmony_ci @State offsetY: number = 15 270e41f4b71Sopenharmony_ci @State radius: number = 5 271e41f4b71Sopenharmony_ci @State colorArray: Array<LinearGradient | ResourceColor> = [this.color1, this.color2, this.color3, this.color4] 272e41f4b71Sopenharmony_ci @State shadowColorArray: Array<LinearGradient | ResourceColor> = [this.colorShadow1, this.colorShadow2, this.colorShadow3, this.colorShadow4] 273e41f4b71Sopenharmony_ci 274e41f4b71Sopenharmony_ci build() { 275e41f4b71Sopenharmony_ci Column({ space: 5 }) { 276e41f4b71Sopenharmony_ci Text('LinearGradient').fontSize(9).fontColor(0xCCCCCC).textAlign(TextAlign.Start).width('100%').margin({ top: 20, left: 20}) 277e41f4b71Sopenharmony_ci DataPanel({ values: this.values1, max: 100, type: DataPanelType.Circle }) 278e41f4b71Sopenharmony_ci .width(300) 279e41f4b71Sopenharmony_ci .height(300) 280e41f4b71Sopenharmony_ci .valueColors(this.colorArray) 281e41f4b71Sopenharmony_ci .trackShadow({ 282e41f4b71Sopenharmony_ci radius: this.radius, 283e41f4b71Sopenharmony_ci colors: this.shadowColorArray, 284e41f4b71Sopenharmony_ci offsetX: this.offsetX, 285e41f4b71Sopenharmony_ci offsetY: this.offsetY 286e41f4b71Sopenharmony_ci }) 287e41f4b71Sopenharmony_ci .strokeWidth(30) 288e41f4b71Sopenharmony_ci .trackBackgroundColor(this.bgColor) 289e41f4b71Sopenharmony_ci }.width('100%').margin({ top: 5 }) 290e41f4b71Sopenharmony_ci } 291e41f4b71Sopenharmony_ci} 292e41f4b71Sopenharmony_ci``` 293e41f4b71Sopenharmony_ci 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci### Example 3 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ci```ts 299e41f4b71Sopenharmony_ci// xxx.ets 300e41f4b71Sopenharmony_ci@Builder 301e41f4b71Sopenharmony_cifunction buildDataPanel(config: DataPanelConfiguration) { 302e41f4b71Sopenharmony_ci Column() { 303e41f4b71Sopenharmony_ci Column() { 304e41f4b71Sopenharmony_ci ForEach(config.values, (item: number, index: number) => { 305e41f4b71Sopenharmony_ci ChildItem({ item: item, index: index, max:config.maxValue}) 306e41f4b71Sopenharmony_ci }, (item: string) => item) 307e41f4b71Sopenharmony_ci }.padding(10) 308e41f4b71Sopenharmony_ci Line().width(360).backgroundColor("#ff373737").margin({bottom:5}) 309e41f4b71Sopenharmony_ci Row() { 310e41f4b71Sopenharmony_ci Text('Length=' + config.values.length + ' ').margin({ left: 10 }).align(Alignment.Start) 311e41f4b71Sopenharmony_ci Text('Max=' + config.maxValue).margin({ left: 10 }).align(Alignment.Start) 312e41f4b71Sopenharmony_ci } 313e41f4b71Sopenharmony_ci } 314e41f4b71Sopenharmony_ci} 315e41f4b71Sopenharmony_ci 316e41f4b71Sopenharmony_ciclass DataPanelBuilder implements ContentModifier<DataPanelConfiguration> { 317e41f4b71Sopenharmony_ci constructor() { 318e41f4b71Sopenharmony_ci } 319e41f4b71Sopenharmony_ci applyContent () : WrappedBuilder<[DataPanelConfiguration]> { 320e41f4b71Sopenharmony_ci return wrapBuilder(buildDataPanel) 321e41f4b71Sopenharmony_ci } 322e41f4b71Sopenharmony_ci} 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ci@Entry 325e41f4b71Sopenharmony_ci@Component 326e41f4b71Sopenharmony_cistruct Index { 327e41f4b71Sopenharmony_ci build() { 328e41f4b71Sopenharmony_ci Column() { 329e41f4b71Sopenharmony_ci Text("Data panel").margin({ top: 12 }); 330e41f4b71Sopenharmony_ci Row() { 331e41f4b71Sopenharmony_ci DataPanel({ values: [12.3, 21.1, 13.4, 35.2, 26.0, 32.0], max: 140, type: DataPanelType.Circle }) 332e41f4b71Sopenharmony_ci .width(400).height(260) 333e41f4b71Sopenharmony_ci .padding({ top: 10 }) 334e41f4b71Sopenharmony_ci .contentModifier(new DataPanelBuilder()) 335e41f4b71Sopenharmony_ci }.margin(15).backgroundColor("#fff5f5f5") 336e41f4b71Sopenharmony_ci } 337e41f4b71Sopenharmony_ci } 338e41f4b71Sopenharmony_ci} 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci@Component 341e41f4b71Sopenharmony_cistruct ChildItem { 342e41f4b71Sopenharmony_ci @Prop item: number; 343e41f4b71Sopenharmony_ci @Prop index: number; 344e41f4b71Sopenharmony_ci @Prop max: number; 345e41f4b71Sopenharmony_ci public color1: string = "#65ff00dd" 346e41f4b71Sopenharmony_ci public color2: string = "#6500ff99" 347e41f4b71Sopenharmony_ci public color3: string = "#65ffe600" 348e41f4b71Sopenharmony_ci public color4: string = "#6595ff00" 349e41f4b71Sopenharmony_ci public color5: string = "#65000dff" 350e41f4b71Sopenharmony_ci public color6: string = "#650099ff" 351e41f4b71Sopenharmony_ci public colorArray: Array<string> = [this.color1, this.color2, this.color3, this.color4, this.color5, this.color6] 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ci build() { 354e41f4b71Sopenharmony_ci RelativeContainer() { 355e41f4b71Sopenharmony_ci Row() { 356e41f4b71Sopenharmony_ci Rect().height(25).width(this.item * 600 / this.max).foregroundColor(this.colorArray[this.index]).radius(5) 357e41f4b71Sopenharmony_ci .align(Alignment.Start) 358e41f4b71Sopenharmony_ci Text(" "+this.item) 359e41f4b71Sopenharmony_ci .fontSize(17) 360e41f4b71Sopenharmony_ci } 361e41f4b71Sopenharmony_ci }.height(28) 362e41f4b71Sopenharmony_ci } 363e41f4b71Sopenharmony_ci} 364e41f4b71Sopenharmony_ci``` 365e41f4b71Sopenharmony_ci 366