ts-basic-components-datapanel.md 1.8 KB
Newer Older
Z
zengyawen 已提交
1
# DataPanel
Z
zengyawen 已提交
2

Z
zengyawen 已提交
3

4
The **\<DataPanel>** component displays proportions in a chart.
Z
zengyawen 已提交
5

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

## Required Permissions
Z
zengyawen 已提交
11 12

None
Z
zengyawen 已提交
13

Z
zengyawen 已提交
14 15

## Child Components
Z
zengyawen 已提交
16

17
Not supported
Z
zengyawen 已提交
18

Z
zengyawen 已提交
19 20 21 22 23 24

## APIs

DataPanel(value:{values: number[], max?: number, type?: DataPanelType})

- Parameters
25
  | Name | Type | Mandatory | Default Value | Description |
Z
zengyawen 已提交
26
  | -------- | -------- | -------- | -------- | -------- |
27 28 29
  | values | number[] | Yes | - | Value list. A maximum of nine values are supported. |
  | max | number | No | 100 | - 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. |
  | type<sup>8+</sup> | DataPanelType | No | DataPanelType.Circle | Type of the data panel. |
Z
zengyawen 已提交
30 31 32


- DataPanelType enums
33
  | Name | Description |
Z
zengyawen 已提交
34
  | -------- | -------- |
35
  | Line | Line data panel. |
E
esterzhou 已提交
36
  | Circle | Circle data panel. |
Z
zengyawen 已提交
37 38 39 40


## Example

Z
zengyawen 已提交
41

42 43
```ts
// xxx.ets
Z
zengyawen 已提交
44 45 46
@Entry
@Component
struct DataPanelExample {
Z
zengyawen 已提交
47
  public values1: number[] = [10, 10, 10, 10, 10, 10, 10, 10, 10]
Z
zengyawen 已提交
48 49 50

  build() {
    Column({ space: 5 }) {
Z
zengyawen 已提交
51 52 53 54 55
      Text('Circle').fontSize(9).fontColor(0xCCCCCC).margin({ top: 20, right: '80%' })
      DataPanel({ values: this.values1, max: 100, type: DataPanelType.Circle }).width(200).height(200)

      Text('Line').fontSize(9).fontColor(0xCCCCCC).margin({ bottom: 20, right: '80%' })
      DataPanel({ values: this.values1, max: 100, type: DataPanelType.Line }).width(300).height(10)
Z
zengyawen 已提交
56 57 58 59 60
    }.width('100%').margin({ top: 5 })
  }
}
```

Z
zengyawen 已提交
61
![en-us_image_0000001211898476](figures/en-us_image_0000001211898476.jpg)