1.2.0 • Published 6 years ago

wx-gauge v1.2.0

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

微信小程序仪表盘组件

基于canvas开发,功能不断叠加

如何使用

第一步:在需要使用该组件地方的配置文件中加入

{
  "usingComponents":{
    "gauge":"../../components/gauge" // 组件地址
  }
}

或者使用官方的npm支持文档中方案 https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html

第二步:在需要引用该组件的地方引入如下所示代码

  <gauge 
      height="750" 
      r="135" 
      bgWidth="13"
      gaugeid="g1"
      animateMsec="700" 
      scaleTextStyle="{{scaleTextStyle}}" 
      indicatorTextStyle='{{indicatorTextStyle}}'
      indicatorValueStyle='{{indicatorValueStyle}}'
      indicatorCircleStyle='{{indicatorCircleStyle}}'
      min="0"
      max="1000"
      value="900"
  />

备注:数据刻度暂时定位人工分段,后期采用自动分割尺度

API

名称 类型 默认值 备注

名称类型默认值备注必填
widthNumber750表盘容器宽度,单位为rpx
heightNumber450表盘容器高度单位为rpx
gaugeidString'gauge' + Math.random()表盘容器组件id,即canvasid
rNumber95表盘半径,单位为px
startAngleNumber80 / 90 * Math.PI表盘开角,角度制
endAngleNumber10 / 90 * Math.PI表盘闭角,角度制
bgColorString#f0f0f0表盘底色
indicatorBgColorArray / String默认为数组,即渐变色,渐变色格式[{progress:0,value:'#fff'},{progress:1,value:'red'}],详情参见源码指示器颜色
bgWidthNumber15表盘宽度
minNumber0最小值
maxNumber1000最大值
valueNumber700指示器值
animateMsecNumber0动画时长(毫秒),0表示无动画
indicatorTextString-指示器文本
scaleArray0,200,400,600,800,1000指示器标尺刻度
indicatorTextStyleObject{show:false,size:12,color:'#666',text:''}指示器文本样式
indicatorValueStyleObject{show:false,size:18,color:'#4575e8'}指示器值样式
indicatorCircleStyleObject{show:false,bgColor:'#00b800',r:9,borderRadius:3,borderColor:'#fff'}borderColor可以为数组,当为数组时采用径向渐变,数组格式同indicatorBgColor
scaleTextStyleObject{show:fasle,size:16,color:#f0f0f0}指示器标尺样式