數(shù)據(jù)面板組件

2024-01-22 17:08 更新

數(shù)據(jù)面板組件,用于將多個(gè)數(shù)據(jù)占比情況使用占比圖進(jìn)行展示。

說明

該組件從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。

子組件

接口

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

從API version 9開始,該接口支持在ArkTS卡片中使用。

參數(shù):

參數(shù)名

參數(shù)類型

必填

參數(shù)描述

values

number[]

數(shù)據(jù)值列表,最多包含9個(gè)數(shù)據(jù),大于9個(gè)數(shù)據(jù)則取前9個(gè)數(shù)據(jù)。若數(shù)據(jù)值小于0則置為0。

max

number

- max大于0,表示數(shù)據(jù)的最大值。

- max小于等于0,max等于value數(shù)組各項(xiàng)的和,按比例顯示。

默認(rèn)值:100

type8+

DataPanelType

數(shù)據(jù)面板的類型(不支持動(dòng)態(tài)修改)。

默認(rèn)值:DataPanelType.Circle

屬性

除支持通用屬性外,還支持以下屬性:

名稱

類型

描述

closeEffect

boolean

關(guān)閉數(shù)據(jù)占比圖表旋轉(zhuǎn)動(dòng)效。

默認(rèn)值:false

DataPanelType枚舉說明

從API version 9開始,該接口支持在ArkTS卡片中使用。

名稱

描述

Line

線型數(shù)據(jù)面板。

Circle

環(huán)形數(shù)據(jù)面板。

示例

  1. // xxx.ets
  2. @Entry
  3. @Component
  4. struct DataPanelExample {
  5. public valueArr: number[] = [10, 10, 10, 10, 10, 10, 10, 10, 10]
  6. build() {
  7. Column({ space: 5 }) {
  8. Row() {
  9. Stack() {
  10. DataPanel({ values: [25], max: 100, type: DataPanelType.Circle }).width(168).height(168)
  11. Column() {
  12. Text('30').fontSize(35).fontColor('#182431')
  13. Text('1.0.0').fontSize(9.33).lineHeight(12.83).fontWeight(500).opacity(0.6)
  14. }
  15. Text('%')
  16. .fontSize(9.33)
  17. .lineHeight(12.83)
  18. .fontWeight(500)
  19. .opacity(0.6)
  20. .position({ x: 104.42, y: 78.17 })
  21. }.margin({ right: 44 })
  22. Stack() {
  23. DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Circle }).width(168).height(168)
  24. Column() {
  25. Text('75').fontSize(35).fontColor('#182431')
  26. Text('已使用98GB/128GB').fontSize(8.17).lineHeight(11.08).fontWeight(500).opacity(0.6)
  27. }
  28. Text('%')
  29. .fontSize(9.33)
  30. .lineHeight(12.83)
  31. .fontWeight(500)
  32. .opacity(0.6)
  33. .position({ x: 104.42, y: 78.17 })
  34. }
  35. }.margin({ bottom: 59 })
  36. DataPanel({ values: this.valueArr, max: 100, type: DataPanelType.Line }).width(300).height(10)
  37. }.width('100%').margin({ top: 5 })
  38. }
  39. }

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)