环形图圆角(原创)

所属分类:UI-图表

 31811  321  查看评论 (9)
分享到微信朋友圈
X
环形图圆角(原创) ie兼容9

本插件使用canvas可以帮助你快速创建一个以圆角交界的环形图

兼容性

适用于所有主流浏览器及移动端的浏览器。IE8及以下不支持

安装

npm install donut-chart

用法

首先需要一个canvas做载体

<canvas id="myCanvas" width="750" height="600"></canvas>

然后创建环形图对象

 var cir = new DonutChart('myCanvas', option)

最后初始化并且可以指定回调函数

cir.init(function (result) {
        // result 选中的选区的相关信息
})

参数

option 示例 (默认值)

var option = {
        type: 'pie', // pie 环形图|| gauge 计量图
        title: {
            show: true,
            text: '总资产(元)',
            textStyle: {
                fontSize: "20px",
                lineHeight: "30px",
                color: '#9f9f9f'
            },
            subtext: '360',
            subtextStyle: {
                fontSize: "30px",
                lineHeight: "35px",
                color: '#e53344'
            },
            x: '50%', // title 位置
            y: "50%",
        },
        tooltip: {
            show: true,
            fontStyle: "normal",    // 	规定字体样式 normal || italic || oblique
            fontVariant: "normal",  // 规定字体变体 normal || small-caps
            fontWeight: 'normal',   // 规定字体的粗细 normal || bold || bolder || lighter || 100 || 200 || 300 || 400 || 500 || 600 || 700 || 800 || 900
            fontSize: "20px",   // 规定字号,以像素计
            lineHeight: "30px", // 规定行高,以像素计
            fontFamily: 'Arial',// 规定字体系列
            color: 'white',     // 字体颜色
            backgroundColor: '#00000099', // tip 背景
            formatter: function (param) {   // 类似echarts 富文本编辑
                var str = "{a|" + param.name + "}" + "{c|" + param.percent + "}" + '\n' + "{b|" + param.value +
                    "元}"
                return str
            },
            rich: {
                a: {
                    fontStyle: "normal",
                    fontVariant: "normal",
                    fontWeight: 'bold',
                    fontSize: "20px",
                    lineHeight: "30px",
                    fontFamily: 'Arial',
                    color: 'white',
                },
                c: {
                    fontStyle: "normal",
                    fontVariant: "normal",
                    fontWeight: 'normal',
                    fontSize: "20px",
                    lineHeight: "30px",
                    fontFamily: 'Arial',
                    color: 'white',
                },
                b: {
                    fontStyle: "normal",
                    fontVariant: "normal",
                    fontWeight: 'bold',
                    fontSize: "30px",
                    lineHeight: "35px",
                    fontFamily: 'Arial',
                    color: '#e53344',
                }
            }
        },
        x: "50%",   // 图标位置
        y: "50%",
        radius: "30%",  // 半径
        lineWidth: "5%", // 圆环宽度
        // {{if type === gauge 计量图}}

        // max: 120, // 映射总值
        // data: [{
        //     name: "已用时长(分钟)",
        //     value: 85, // 映射计量值
        // }],

        // {{else if type === pie 环形图}}

        // data: [{
        //     name: "账户余额(元)",
        //     value: 110,
        // }, {
        //     name: "散标待回(元)",
        //     value: 120,
        // }, {
        //     name: "在途资金(元)",
        //     value: 130,
        // }],

        // {{/if}}
        label: {
            show: true,
            fontStyle: "normal",
            fontVariant: "normal",
            fontWeight: 'bold',
            fontSize: "20px",
            lineHeight: "30px",
            fontFamily: 'Arial',
            color: '#9f9f9f',
            formatter: function (param) {
                var str = "{a|" + param.name + "}" + "{c|" + param.percent + "}" + '\n' + "{b|" + param.value +
                    "元}"
                return str
            },
            rich: {
                a: {
                    fontStyle: "normal",
                    fontVariant: "normal",
                    fontWeight: 'bold',
                    fontSize: "20px",
                    lineHeight: "30px",
                    fontFamily: 'Arial',

                },
                b: {
                    fontStyle: "normal",
                    fontVariant: "normal",
                    fontWeight: 'bold',
                    fontSize: "30px",
                    lineHeight: "35px",
                    fontFamily: 'Arial',
                    color: '#e53344',
                },
                c: {
                    fontStyle: "normal",
                    fontVariant: "normal",
                    fontWeight: 'bold',
                    fontSize: "20px",
                    lineHeight: "30px",
                    fontFamily: 'Arial',

                }
            }
        },
        capType: "round", // 圆角 || butt 平角
        selectedStyle: {  // 选中时的样式
            color: "white", // 包边颜色
            borderWidth: 10 // 包边宽度
        },
        color: ["#fe7c00", "#e83227", "#32a676"],
        labelCoverTitle: true, // label 是否覆盖标题
        backgroundArc: '#999' // 空圆环的颜色
    }
相关插件-图表

类似芝麻信用占比的插件

这是一块款信用占比的插件
  图表
 23984  375

jQuery响应式表格插件ReStable

jQuery restable是一个非常简单轻量级(~ 1KB)的jQuery插件,它可以将表格在指定的响应式断点时,使表格结构切换为无序列表结构,以适应在小屏幕设备中显示表格数据。
  图表
 31622  316

jquery.jqplot 绘图插件

jqPlot是一个jQuery绘图插件,可以利用它制作漂亮的线状图、柱状图和饼图。
  图表
 45140  374

jQuery移动端固定表格表头和任意表列(原创)

jQuery固定表格表头和任意表列,只适用于移动端
  图表
 21714  217

讨论这个项目(9)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

    红鼎科技 0
    2019/8/20 21:20:29
    你好,只能有3个数据吗? 回复
    小疯 0
    2019/8/19 11:20:49
    怎么把canvas环形的方向从顺时针变成逆时针 回复
    忆往昔 回眸一笑 0
    2019/7/23 17:52:43
    这个在vue cli3中怎么使用? 回复
    仰望星空 脚踏实地 0
    2019/1/18 15:54:20
    鼠标移入,tooltip框里的文字会显示不全,怎么解决 回复
    Important 0
    2019/1/10 16:04:09
    动态加载的时候,如果为0,会记住上次的值,想请教大神,你这个怎么处理的
        浪迹灬天涯0
        2019/1/10 18:03:28
        0?记住上次的值?场景不太清楚
        m彬彬0
        2020/12/4 16:56:19
        我的也是这样的,记住上次的值
    回复
    刘冀广 0
    2018/3/29 17:07:27
    怎样可以实现滑到处变大
        浪迹灬天涯0
        2018/3/29 19:29:21
        因为尝试过,选中放大有点难看,就没做,现在只是做了选中有border,2.0.1版本会加上
    回复
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
取消回复