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

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

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

Z
zengyawen 已提交
9

Z
zengyawen 已提交
10

Z
zengyawen 已提交
11 12

## Child Components
Z
zengyawen 已提交
13

14
Not supported
Z
zengyawen 已提交
15

Z
zengyawen 已提交
16 17 18

## APIs

E
ester.zhou 已提交
19
DataPanel(options:{values: number[], max?: number, type?: DataPanelType})
Z
zengyawen 已提交
20

E
ester.zhou 已提交
21
**Parameters**
Z
zengyawen 已提交
22

E
ester.zhou 已提交
23 24 25 26 27
| Name           | Type  | Mandatory | Description|
| ----------------- | -------- | ----- | -------- |
| values            | number[]   | Yes   | Value list. A maximum of nine values are supported.|
| 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**|
| type<sup>8+</sup> | DataPanelType | No| Type of the data panel.<br>Default value: **DataPanelType.Circle**|
Z
zengyawen 已提交
28 29


E
ester.zhou 已提交
30 31 32 33 34
## DataPanelType enums
| Name| Description| 
| -------| ------------ |
| Line   | Line data panel.| 
| Circle | Circle data panel.|
Z
zengyawen 已提交
35 36


E
ester.zhou 已提交
37
## Example
Z
zengyawen 已提交
38

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

  build() {
    Column({ space: 5 }) {
Z
zengyawen 已提交
48 49 50 51 52
      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 已提交
53 54 55 56 57
    }.width('100%').margin({ top: 5 })
  }
}
```

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