Giter VIP home page Giter VIP logo

wx-gauge's Introduction

微信小程序仪表盘组件

基于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

名称 类型 默认值 备注

名称 类型 默认值 备注 必填
width Number 750 表盘容器宽度,单位为rpx
height Number 450 表盘容器高度单位为rpx
gaugeid String 'gauge' + Math.random() 表盘容器组件id,即canvasid
r Number 95 表盘半径,单位为px
startAngle Number 80 / 90 * Math.PI 表盘开角,角度制
endAngle Number 10 / 90 * Math.PI 表盘闭角,角度制
bgColor String #f0f0f0 表盘底色
indicatorBgColor Array / String 默认为数组,即渐变色,渐变色格式[{progress:0,value:'#fff'},{progress:1,value:'red'}],详情参见源码 指示器颜色
bgWidth Number 15 表盘宽度
min Number 0 最小值
max Number 1000 最大值
value Number 700 指示器值
animateMsec Number 0 动画时长(毫秒),0表示无动画
indicatorText String - 指示器文本
scale Array [0,200,400,600,800,1000] 指示器标尺刻度
indicatorTextStyle Object {show:false,size:12,color:'#666',text:''} 指示器文本样式
indicatorValueStyle Object {show:false,size:18,color:'#4575e8'} 指示器值样式
indicatorCircleStyle Object {show:false,bgColor:'#00b800',r:9,borderRadius:3,borderColor:'#fff'} borderColor可以为数组,当为数组时采用径向渐变,数组格式同indicatorBgColor
scaleTextStyle Object {show:fasle,size:16,color:#f0f0f0} 指示器标尺样式

wx-gauge's People

Contributors

godotdotdot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.