W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
數(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+ | 否 | 數(shù)據(jù)面板的類型(不支持動(dòng)態(tài)修改)。 默認(rèn)值:DataPanelType.Circle |
從API version 9開始,該接口支持在ArkTS卡片中使用。
名稱 | 描述 |
---|---|
Line | 線型數(shù)據(jù)面板。 |
Circle | 環(huán)形數(shù)據(jù)面板。 |
- // xxx.ets
- @Entry
- @Component
- struct DataPanelExample {
- public valueArr: number[] = [10, 10, 10, 10, 10, 10, 10, 10, 10]
- build() {
- Column({ space: 5 }) {
- Row() {
- Stack() {
- DataPanel({ values: [25], max: 100, type: DataPanelType.Circle }).width(168).height(168)
- Column() {
- Text('30').fontSize(35).fontColor('#182431')
- Text('1.0.0').fontSize(9.33).lineHeight(12.83).fontWeight(500).opacity(0.6)
- }
- Text('%')
- .fontSize(9.33)
- .lineHeight(12.83)
- .fontWeight(500)
- .opacity(0.6)
- .position({ x: 104.42, y: 78.17 })
- }.margin({ right: 44 })
- Stack() {
- DataPanel({ values: [50, 12, 8, 5], max: 100, type: DataPanelType.Circle }).width(168).height(168)
- Column() {
- Text('75').fontSize(35).fontColor('#182431')
- Text('已使用98GB/128GB').fontSize(8.17).lineHeight(11.08).fontWeight(500).opacity(0.6)
- }
- Text('%')
- .fontSize(9.33)
- .lineHeight(12.83)
- .fontWeight(500)
- .opacity(0.6)
- .position({ x: 104.42, y: 78.17 })
- }
- }.margin({ bottom: 59 })
- DataPanel({ values: this.valueArr, max: 100, type: DataPanelType.Line }).width(300).height(10)
- }.width('100%').margin({ top: 5 })
- }
- }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: