Echarts-我的仪表盘

Echarts 图表
1、仪表盘
var dataArr = [{
value: 91,
name: ‘需量符合度’
}];
var color = new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
offset: 0,
color: ‘#5CF9FE’ // 0% 处的颜色
},
{
offset: 0.17,
color: ‘#468EFD’ // 100% 处的颜色
},
{
offset: 0.9,
color: ‘#468EFD’ // 100% 处的颜色
},
{
offset: 1,
color: ‘#5CF9FE’ // 100% 处的颜色
}
]);
var colorSet = [
[0.91, color],
[1, ‘#15337C’]
];
var rich = {
white: {
fontSize: 20,
color: ‘#fff’,
fontWeight: ‘500’,
padding: [-40, 0, 0, 0]
},
bule: {
fontSize: 30,
fontFamily: ‘DINBold’,
color: ‘#fff’,
fontWeight: ‘700’,
padding: [-30, 0, 0, 0],
},
radius: {
width: 40,
height: 20,
// lineHeight:80,
borderWidth: 1,
borderColor: ‘#0092F2’,
fontSize: 14,
color: ‘#fff’,
backgroundColor: ‘#1B215B’,
borderRadius: 20,
textAlign: ‘center’,
},
size: {
height: 150,
padding: [-80, 0, 0, 0]
}
};
var title = [{
text: "本月\n达标值 " + “95%”,
top: ‘70%’,
left: ‘25%’,
textStyle: {
fontSize: ‘16’,
color: ‘#ffffff’,
},
textAlign: ‘center’,
}, {
text: "上月\n达标值 " + “95%”,
top: ‘70%’,
left: ‘75%’,
textStyle: {
fontSize: ‘16’,
color: ‘#ffffff’,
align: ‘center’,
},
textAlign: ‘center’,
}];

        var centerLeft = ['25%', '50%'];
        var centerRight = ['75%', '50%'];

option = {

            title: title,
            //backgroundColor: '#0E1327',
            tooltip: {
                formatter: "{a} <br/>{b} : {c}%"
            },

            series: [{ //内圆
                type: 'pie',
                radius: '65%',
                center: centerLeft,
                z: 0,
                itemStyle: {
                    normal: {
                        color: new echarts.graphic.RadialGradient(.5, .5, 1, [{
                            offset: 0,
                            color: 'rgba(17,24,43,0)'
                        },
                            {
                                offset: .5,
                                // color: '#1E2B57'
                                color: 'rgba(28,42,91,.6)'
                            },
                            {
                                offset: 1,
                                color: '#141C33',
                                // color:'rgba(17,24,43,0)'
                            }
                        ], false),
                        label: {
                            show: false
                        },
                        labelLine: {
                            show: false
                        }
                    },
                },
                hoverAnimation: false,
                label: {
                    show: false,
                },
                tooltip: {
                    show: false
                },
                data: [100],
            },
                {
                    type: 'gauge',
                    name: '外层辅助',
                    radius: '54%',
                    center: centerLeft,
                    startAngle: '225',
                    endAngle: '-45',
                    splitNumber: '100',
                    pointer: {
                        show: false
                    },
                    detail: {
                        show: false,
                    },
                    data: [{
                        value: 1
                    }],
                    // data: [{value: 1, name: 90}],
                    title: {
                        show: true,
                        offsetCenter: [0, 30],
                        textStyle: {
                            color: '#fff',
                            fontStyle: 'normal',
                            fontWeight: 'normal',
                            fontFamily: '微软雅黑',
                            fontSize: 20,
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: [
                                [1, '#00FFFF']
                            ],
                            width: 2,
                            opacity: 1
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: true,
                        length: 20,
                        lineStyle: {
                            color: '#051932',
                            width: 0,
                            type: 'solid',
                        },
                    },
                    axisLabel: {
                        show: false
                    }
                },
                {
                    type: 'gauge',
                    radius: '50%',
                    center: centerLeft,
                    startAngle: '225',
                    endAngle: '-45',
                    pointer: {
                        show: false
                    },
                    detail: {
                        formatter: function (value) {
                            var num = Math.round(value);
                            return '{bule|' + num + '}{white|%}' + '{size|' + '}\n{radius|达标}';
                        },
                        rich: rich,
                        offsetCenter: ['0%', "0%"],
                        fontSize: '10'
                    },
                    data: dataArr,
                    title: {
                        show: false,
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: colorSet,
                            width: 25,
                            // shadowBlur: 15,
                            // shadowColor: '#B0C4DE',
                            shadowOffsetX: 0,
                            shadowOffsetY: 0,
                            opacity: 1
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: false,
                        length: 25,
                        lineStyle: {
                            color: '#00377a',
                            width: 2,
                            type: 'solid',
                        },
                    },
                    axisLabel: {
                        show: false
                    },
                },
                {
                    name: '灰色内圈', //刻度背景
                    type: 'gauge',
                    z: 2,
                    radius: '40%',
                    center: centerLeft,
                    startAngle: '225',
                    endAngle: '-45',
                    //center: ["50%", "75%"], //整体的位置设置
                    axisLine: { // 坐标轴线
                        lineStyle: { // 属性lineStyle控制线条样式
                            color: [
                                [1, '#018DFF']
                            ],
                            width: 2,
                            opacity: 1, //刻度背景宽度
                        }
                    },
                    splitLine: {
                        show: false
                    },
                    // data: [{
                    //     show: false,
                    //     value: '80'
                    // }], //作用不清楚
                    axisLabel: {
                        show: false
                    },
                    pointer: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    detail: {
                        show: 0
                    }
                },
                {
                    name: "白色圈刻度",
                    type: "gauge",
                    radius: "40%",
                    center: centerLeft,
                    startAngle: 225, //刻度起始
                    endAngle: -45, //刻度结束
                    z: 4,
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        length: 16, //刻度节点线长度
                        lineStyle: {
                            width: 2,
                            color: 'rgba(1,244,255, 0.9)'
                        } //刻度节点线
                    },
                    axisLabel: {
                        color: 'rgba(255,255,255,0)',
                        fontSize: 12,
                    }, //刻度节点文字颜色
                    pointer: {
                        show: false
                    },
                    axisLine: {
                        lineStyle: {
                            opacity: 0
                        }
                    },
                    detail: {
                        show: false
                    },
                    data: [{
                        value: 0,
                        name: ""
                    }]
                },
                { //内圆
                    type: 'pie',
                    radius: '36%',
                    center: centerLeft,
                    z: 1,
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.RadialGradient(.5, .5, .8, [{
                                offset: 0,
                                color: '#4978EC'
                            },
                                {
                                    offset: .5,
                                    color: '#1E2B57'
                                },
                                {
                                    offset: 1,
                                    color: '#141F3D'
                                }
                            ], false),
                            label: {
                                show: false
                            },
                            labelLine: {
                                show: false
                            }
                        },
                    },
                    hoverAnimation: false,
                    label: {
                        show: false,
                    },
                    tooltip: {
                        show: false
                    },
                    data: [100],
                },


                { //内圆
                    type: 'pie',
                    radius: '65%',
                    center: centerRight,
                    z: 0,
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.RadialGradient(.5, .5, 1, [{
                                offset: 0,
                                color: 'rgba(17,24,43,0)'
                            },
                                {
                                    offset: .5,
                                    // color: '#1E2B57'
                                    color: 'rgba(28,42,91,.6)'
                                },
                                {
                                    offset: 1,
                                    color: '#141C33',
                                    // color:'rgba(17,24,43,0)'
                                }
                            ], false),
                            label: {
                                show: false
                            },
                            labelLine: {
                                show: false
                            }
                        },
                    },
                    hoverAnimation: false,
                    label: {
                        show: false,
                    },
                    tooltip: {
                        show: false
                    },
                    data: [100],
                },
                {
                    type: 'gauge',
                    name: '外层辅助',
                    radius: '54%',
                    center: centerRight,
                    startAngle: '225',
                    endAngle: '-45',
                    splitNumber: '100',
                    pointer: {
                        show: false
                    },
                    detail: {
                        show: false,
                    },
                    data: [{
                        value: 1
                    }],
                    // data: [{value: 1, name: 90}],
                    title: {
                        show: true,
                        offsetCenter: [0, 30],
                        textStyle: {
                            color: '#fff',
                            fontStyle: 'normal',
                            fontWeight: 'normal',
                            fontFamily: '微软雅黑',
                            fontSize: 20,
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: [
                                [1, '#00FFFF']
                            ],
                            width: 2,
                            opacity: 1
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: true,
                        length: 20,
                        lineStyle: {
                            color: '#051932',
                            width: 0,
                            type: 'solid',
                        },
                    },
                    axisLabel: {
                        show: false
                    }
                },
                {
                    type: 'gauge',
                    radius: '50%',
                    center: centerRight,
                    startAngle: '225',
                    endAngle: '-45',
                    pointer: {
                        show: false
                    },
                    detail: {
                        formatter: function (value) {
                            var num = Math.round(value);
                            return '{bule|' + num + '}{white|%}' + '{size|' + '}\n{radius|不达标}';
                        },
                        rich: rich,
                        offsetCenter: ['0%', "0%"],
                        fontSize: '10'
                    },
                    data: dataArr,
                    title: {
                        show: false,
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: colorSet,
                            width: 25,
                            // shadowBlur: 15,
                            // shadowColor: '#B0C4DE',
                            shadowOffsetX: 0,
                            shadowOffsetY: 0,
                            opacity: 1
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: false,
                        length: 25,
                        lineStyle: {
                            color: '#00377a',
                            width: 2,
                            type: 'solid',
                        },
                    },
                    axisLabel: {
                        show: false
                    },
                },
                {
                    name: '灰色内圈', //刻度背景
                    type: 'gauge',
                    z: 2,
                    radius: '40%',
                    center: centerRight,
                    startAngle: '225',
                    endAngle: '-45',
                    //center: ["50%", "75%"], //整体的位置设置
                    axisLine: { // 坐标轴线
                        lineStyle: { // 属性lineStyle控制线条样式
                            color: [
                                [1, '#018DFF']
                            ],
                            width: 2,
                            opacity: 1, //刻度背景宽度
                        }
                    },
                    splitLine: {
                        show: false
                    },
                    // data: [{
                    //     show: false,
                    //     value: '80'
                    // }], //作用不清楚
                    axisLabel: {
                        show: false
                    },
                    pointer: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    detail: {
                        show: 0
                    }
                },
                {
                    name: "白色圈刻度",
                    type: "gauge",
                    radius: "40%",
                    center: centerRight,
                    startAngle: 225, //刻度起始
                    endAngle: -45, //刻度结束
                    z: 4,
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        length: 16, //刻度节点线长度
                        lineStyle: {
                            width: 2,
                            color: 'rgba(1,244,255, 0.9)'
                        } //刻度节点线
                    },
                    axisLabel: {
                        color: 'rgba(255,255,255,0)',
                        fontSize: 12,
                    }, //刻度节点文字颜色
                    pointer: {
                        show: false
                    },
                    axisLine: {
                        lineStyle: {
                            opacity: 0
                        }
                    },
                    detail: {
                        show: false
                    },
                    data: [{
                        value: 0,
                        name: ""
                    }]
                },
                { //内圆
                    type: 'pie',
                    radius: '36%',
                    center: centerRight,
                    z: 1,
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.RadialGradient(.5, .5, .8, [{
                                offset: 0,
                                color: '#4978EC'
                            },
                                {
                                    offset: .5,
                                    color: '#1E2B57'
                                },
                                {
                                    offset: 1,
                                    color: '#141F3D'
                                }
                            ], false),
                            label: {
                                show: false
                            },
                            labelLine: {
                                show: false
                            }
                        },
                    },
                    hoverAnimation: false,
                    label: {
                        show: false,
                    },
                    tooltip: {
                        show: false
                    },
                    data: [100],
                },


            ]
        };

setInterval(function () {
//option.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
myChart.setOption(option, true);
},2000);

2、option = {
backgroundColor: ‘#1b1b1b’,
tooltip : {
show : true,
formatter: “{a}
{c} {b}”
},
series : [
{
name:‘温度’,
type:‘gauge’,
min:0,
max:40,
splitNumber:10,
radius: ‘50%’,
axisLine: { // 坐标轴线
lineStyle: { // 属性lineStyle控制线条样式
color: [[0.09, ‘lime’],[0.82, ‘#1e90ff’],[1, ‘#ff4500’]],
width: 3,
shadowColor : ‘#fff’, //默认透明
shadowBlur: 10
}
},
axisLabel: { // 坐标轴小标记
textStyle: { // 属性lineStyle控制线条样式
fontWeight: ‘bolder’,
color: ‘#fff’,
shadowColor : ‘#fff’, //默认透明
shadowBlur: 10
}
},
axisTick: { // 坐标轴小标记
length :15, // 属性length控制线长
lineStyle: { // 属性lineStyle控制线条样式
color: ‘auto’,
shadowColor : ‘#fff’, //默认透明
shadowBlur: 10
}
},
splitLine: { // 分隔线
length :25, // 属性length控制线长
lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式
width:3,
color: ‘#fff’,
shadowColor : ‘#fff’, //默认透明
shadowBlur: 10
}
},
pointer: { // 分隔线
shadowColor : ‘#fff’, //默认透明
shadowBlur: 5
},
title : {
textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
fontWeight: ‘bolder’,
fontSize: 20,
fontStyle: ‘italic’,
color: ‘#fff’,
shadowColor : ‘#fff’, //默认透明
shadowBlur: 10
}
},
detail : {
backgroundColor: ‘rgba(30,144,255,0.8)’,
borderWidth: 1,
borderColor: ‘#fff’,
shadowColor : ‘#fff’, //默认透明
shadowBlur: 5,
offsetCenter: [0, ‘50%’], // x, y,单位px
textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
fontWeight: ‘bolder’,
color: ‘#fff’
}
},
data:[{value: 26, name: ‘℃’}]
}
]
};

setInterval(function (){
//option.series[0].data[0].value = (Math.random()*30).toFixed(2) - 0;
myChart.setOption(option);
},2000)

3、仪表盘
var dataArr = [{
value: 91,
name: ‘需量符合度’
}];
var color = new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
offset: 0,
color: ‘#5CF9FE’ // 0% 处的颜色
},
{
offset: 0.17,
color: ‘#468EFD’ // 100% 处的颜色
},
{
offset: 0.9,
color: ‘#468EFD’ // 100% 处的颜色
},
{
offset: 1,
color: ‘#5CF9FE’ // 100% 处的颜色
}
]);
var colorSet = [
[0.91, color],
[1, ‘#15337C’]
];
var rich = {
white: {
fontSize: 20,
color: ‘#fff’,
fontWeight: ‘500’,
padding: [-40, 0, 0, 0]
},
bule: {
fontSize: 30,
fontFamily: ‘DINBold’,
color: ‘#fff’,
fontWeight: ‘700’,
padding: [-30, 0, 0, 0],
},
radius: {
width: 60,
height: 24,
// lineHeight:80,
borderWidth: 1,
borderColor: ‘#0092F2’,
fontSize: 14,
color: ‘#fff’,
backgroundColor: ‘#1B215B’,
borderRadius: 20,
textAlign: ‘center’,
padding:2
},
size: {
height: 150,
padding: [-80, 0, 0, 0]
}
};
var title = [{
text: "本月\n达标值 " + “95%”,
top: ‘70%’,
left: ‘50%’,
textStyle: {
fontSize: ‘16’,
color: ‘#ffffff’,
lineHeight : 20
},
textAlign: ‘center’,
} ];

        var centerLeft = ['50%', '50%'];

option = {

            title: title,
            //backgroundColor: '#0E1327',
            tooltip: {
                formatter: "{a} <br/>{b} : {c}%"
            },
            series: [{ //内圆
                type: 'pie',
                radius: '65%',
                center: centerLeft,
                z: 0,
                itemStyle: {
                    normal: {
                        color: new echarts.graphic.RadialGradient(.5, .5, 1, [{
                            offset: 0,
                            color: 'rgba(17,24,43,0)'
                        },
                            {
                                offset: .5,
                                // color: '#1E2B57'
                                color: 'rgba(28,42,91,.6)'
                            },
                            {
                                offset: 1,
                                color: '#141C33',
                                // color:'rgba(17,24,43,0)'
                            }
                        ], false),
                        label: {
                            show: false
                        },
                        labelLine: {
                            show: false
                        }
                    },
                },
                hoverAnimation: false,
                label: {
                    show: false,
                },
                tooltip: {
                    show: false
                },
                data: [100],
            },
                {
                    type: 'gauge',
                    name: '外层辅助',
                    radius: '54%',
                    center: centerLeft,
                    startAngle: '225',
                    endAngle: '-45',
                    splitNumber: '100',
                    pointer: {
                        show: false
                    },
                    detail: {
                        show: false,
                    },
                    data: [{
                        value: 1
                    }],
                    title: {
                        show: true,
                        offsetCenter: [0, 30],
                        textStyle: {
                            color: '#fff',
                            fontStyle: 'normal',
                            fontWeight: 'normal',
                            fontFamily: '微软雅黑',
                            fontSize: 20,
                        }
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: [
                                [1, '#00FFFF']
                            ],
                            width: 2,
                            opacity: 1
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: true,
                        length: 20,
                        lineStyle: {
                            color: '#051932',
                            width: 0,
                            type: 'solid',
                        },
                    },
                    axisLabel: {
                        show: false
                    }
                },
                {
                    type: 'gauge',
                    radius: '50%',
                    center: centerLeft,
                    startAngle: '225',
                    endAngle: '-45',
                    pointer: {
                        show: false
                    },
                    detail: {
                        formatter: function (value) {
                            var num = Math.round(value);
                            return '{bule|' + num + '}{white|%}' + '{size|' + '}\n{radius|达标}';
                        },
                        rich: rich,
                        offsetCenter: ['0%', "0%"],
                        fontSize: '10'
                    },
                    data: dataArr,
                    title: {
                        show: false,
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: colorSet,
                            width: 25,
                            // shadowBlur: 15,
                            // shadowColor: '#B0C4DE',
                            shadowOffsetX: 0,
                            shadowOffsetY: 0,
                            opacity: 1
                        }
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        show: false,
                        length: 25,
                        lineStyle: {
                            color: '#00377a',
                            width: 2,
                            type: 'solid',
                        },
                    },
                    axisLabel: {
                        show: false
                    },
                },
                {
                    name: '灰色内圈', //刻度背景
                    type: 'gauge',
                    z: 2,
                    radius: '40%',
                    center: centerLeft,
                    startAngle: '225',
                    endAngle: '-45',
                    //center: ["50%", "75%"], //整体的位置设置
                    axisLine: { // 坐标轴线
                        lineStyle: { // 属性lineStyle控制线条样式
                            color: [
                                [1, '#018DFF']
                            ],
                            width: 2,
                            opacity: 1, //刻度背景宽度
                        }
                    },
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: false
                    },
                    pointer: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    detail: {
                        show: 0
                    }
                },
                {
                    name: "白色圈刻度",
                    type: "gauge",
                    radius: "40%",
                    center: centerLeft,
                    startAngle: 225, //刻度起始
                    endAngle: -45, //刻度结束
                    z: 4,
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        length: 16, //刻度节点线长度
                        lineStyle: {
                            width: 2,
                            color: 'rgba(1,244,255, 0.9)'
                        } //刻度节点线
                    },
                    axisLabel: {
                        color: 'rgba(255,255,255,0)',
                        fontSize: 12,
                    }, //刻度节点文字颜色
                    pointer: {
                        show: false
                    },
                    axisLine: {
                        lineStyle: {
                            opacity: 0
                        }
                    },
                    detail: {
                        show: false
                    },
                    data: [{
                        value: 0,
                        name: ""
                    }]
                },
                { //内圆
                    type: 'pie',
                    radius: '36%',
                    center: centerLeft,
                    z: 1,
                    itemStyle: {
                        normal: {
                            color: new echarts.graphic.RadialGradient(.5, .5, .8, [{
                                offset: 0,
                                color: '#4978EC'
                            },
                                {
                                    offset: .5,
                                    color: '#1E2B57'
                                },
                                {
                                    offset: 1,
                                    color: '#141F3D'
                                }
                            ], false),
                            label: {
                                show: false
                            },
                            labelLine: {
                                show: false
                            }
                        },
                    },
                    hoverAnimation: false,
                    label: {
                        show: false,
                    },
                    tooltip: {
                        show: false
                    },
                    data: [100],
                } 
            ]
        };

setInterval(function () {
//option.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
myChart.setOption(option, true);
},2000);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值