Skip to content

SectorProgress 扇形进度条

介绍

用于展示进度、占比。

引入

ts
import { IBestSectorProgress } from "@ibestservices/ibest-ui";

代码演示

基础用法

基础用法

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State value: number = 30
  build() {
    Column(){
      IBestSectorProgress({
        value: $value,
        text: `${this.value}%`
      })
    }
  }
}

样式定制

样式定制

点我查看代码
ts
import { IBestSlider } from "@ibestservices/ibest-ui"
@Entry
@Component
struct DemoPage {
  @State value: number = 30
  build() {
    Column({space: 20}){
      Flex({wrap: FlexWrap.Wrap, alignItems: ItemAlign.Center, space: { main: LengthMetrics.vp(20), cross: LengthMetrics.vp(20) }}){
        IBestSectorProgress({
          value: $value,
          diameter: 80,
          text: "宽度定制"
        })
        IBestSectorProgress({
          value: $value,
          bgColor: "#ebedf0",
          sectorBgColor: "#ee0a24",
          text: "颜色定制"
        })
        IBestSectorProgress({
          value: $value,
          clockwise: false,
          text: "逆时针"
        })
        IBestSectorProgress({
          value: $value,
          text: "边框",
          outerBorder: {width: 1, color: Color.Green}
        })
        IBestSectorProgress({
          value: $value,
          text: "过渡动画",
          enableAnimation: true
        })
      }
      Row({space: SPACE.SM}){
        IBestSlider({
          value: $value
        })
      }
    }
  }
}

起始位置

起始位置

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State value: number = 30
  build() {
    Flex({wrap: FlexWrap.Wrap, space: { main: LengthMetrics.vp(20), cross: LengthMetrics.vp(20) }}){
      IBestSectorProgress({
        value: $value,
        startPosition: "left",
        text: "左侧"
      })
      IBestSectorProgress({
        value: $value,
        startPosition: "right",
        text: "右侧"
      })
      IBestSectorProgress({
        value: $value,
        startPosition: "bottom",
        text: "底部"
      })
      IBestSectorProgress({
        value: $value,
        startPosition: "left",
        clockwise: false,
        text: "左侧逆时针"
      })
      IBestSectorProgress({
        value: $value,
        startPosition: "right",
        clockwise: false,
        text: "右侧逆时针"
      })
      IBestSectorProgress({
        value: $value,
        startPosition: "bottom",
        clockwise: false,
        text: "底部逆时针"
      })
    }
  }
}

API

@Props

参数说明类型默认值
value进度值, 支持双向绑定number0
diameter进度条直径(宽度)number100
target目标进度number100
text中间文字string''
textColor中间文字颜色ResourceColor#323233
textFontSize中间文字大小number | string16
textFontWeight中间文字字重FontWeight600
clockwise是否顺时针booleantrue
startPosition进度条起始位置, 可选值 left right top bottomstringtop
bgColor底层背景色ResourceColor#fff
sectorBgColor扇形背景色string | number | CanvasGradient | CanvasPattern#1989fa
outerBorder边框BorderOptions{}
enableAnimation是否需要过渡动画booleanfalse

Events

事件名说明回调参数
onReachTarget到达目标值-