环形图

324 阅读1分钟

vue2-移动端

文档与演示

image.png

canvas

import jCanvas from '../components/canvas'

props

参数类型默认值描述
heightNumber300高度
widthNumber300宽度
canvaIdStringcanvaIdid
startNumber-1/2起始角度
configObject配置参数

config

参数类型默认值描述
bgcolorColor#eee背景颜色
lineWidthNumber24环形宽度
data[Number][]每段环形的数值-最终转换为比例
colorList[Color]['#406bff', '#0cc', '#9a90ff']每段环形的颜色
lineCapbutt/round/squarebutt交界处处理

demo

    <circle-canvas
        :width="200"
        :height="200"
        :config="{
          data: [100, 150, 200],
          lineWidth: 36,
          colorList: ['#406bff', '#0cc', '#9a90ff'],
          name: [1, 2, 3],
        }"
      ></circle-canvas>

data() {
    return {
      barList: [
        {
          value: 100,
          title: "100",
          footer: "1",
        },
        {
          value: 200,
          title: "200",
          footer: "2",
        },
        {
          value: 150,
          title: "150",
          footer: "3",
        },
      ],
    };
  }