echarts图表

需引用最新的最新4.2版本的js(<script src="echarts.min.js"></script>)
1.柱状图

var myChart = echarts.init(document.getElementById('todayRole'));
    var dataAxis = ['物业管理','住户','陌生人','黑名单','租户'];
    var data = [2, 16, 27, 2, 16];
    var yMax = 50;
    var dataShadow = [];
    
    for (var i = 0; i < data.length; i++) {
        dataShadow.push(yMax);
    }
    option = {
        title: {
            text: '今日角色访问统计', 
            textStyle: {
                color: '#999',
                fontSize: 15
            }
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器,坐标轴触发有效
                type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
            }
        },
        xAxis: {
            data: dataAxis,
            axisLabel: {
                // inside: true,
                textStyle: {
                    color: '#999'
                },
                interval:0,//显示所有的类别
            },
            axisTick: {
                show: false
            },
            axisLine: {
                show: false
            },
            z: 10
        },
        yAxis: {
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                textStyle: {
                    color: '#999'
                }
            }
        },
        series: [
            { // For shadow
                type: 'bar',
                itemStyle: {
                    normal: {color: 'rgba(0,0,0,0.05)'}
                },
                barGap:'-100%',
                barCategoryGap:'60%',
                data: dataShadow,
                animation: false
            },
            {
                type: 'bar',
                itemStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: '#83bff6'},
                                {offset: 0.5, color: '#188df0'},
                                {offset: 1, color: '#188df0'}
                            ]
                        )
                    },
                    emphasis: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: '#2378f7'},
                                {offset: 0.7, color: '#2378f7'},
                                {offset: 1, color: '#83bff6'}
                            ]
                        )
                    }
                },
                data: data
            }
        ]
    };

在这里插入图片描述
2.折线图

option = {
        title: {
            text: '过去一周访问次数趋势图', 
            top: 10,
            textStyle: {
                color: '#999',
                fontSize: 15
            }
        },
        tooltip : {
            trigger: 'axis'
        },
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                data : ["03-20", "03-21", "03-22"],
                axisLabel: {
                    textStyle: {
                        color: '#999',//坐标值得具体的颜色
    
                    }
                }
            }
        ],
        yAxis : [
            {
                type : 'value',
                axisLabel: {
                    textStyle: {
                        color: '#999',//坐标值得具体的颜色
    
                    }
                }
            }
        ],
        series : [
            {
                name:'访问次数',
                type:'line',
                smooth:true,
                itemStyle: {
                    normal: {
                        areaStyle: {
                            type: 'default'
                        },
                        color:'#c43fc4'
                    }
                },
                data:[11, 147, 67]
            }
        ]
    };

在这里插入图片描述
3.环形图

var radius = [20, 35];
    option = {
        series: [{
            type: 'pie',
            radius: radius,
            center : ['25%', '45%'],
            color:['#48a4dad3','#2c343c'],
            avoidLabelOverlap: false,
            hoverAnimation:false,
            label: {
                normal: {
                    show: false,
                    position: 'center',
                    textStyle: {
                        fontSize: 12,
                        fontWeight: 'bold',
                        color:'#999'
                    },
                    formatter:'{b}\n{c}%'
                }
            },
            data: [{
                value: 36,
                name: "男",
                label:{
                    normal:{
                        show:true
                    }
                }
            },{
                value: 100-40,
                name: ''
            }]
        },{
            type: 'pie',
            radius: radius,
            center : ['75%', '45%'],
            color:['#ee4f69d3','#2c343c'],
            avoidLabelOverlap: false,
            hoverAnimation:false,
            label: {
                normal: {
                    show: false,
                    position: 'center',
                    textStyle: {
                        fontSize: 12,
                        fontWeight: 'bold',
                        color:'#999'
                    },
                    formatter:'{b}\n{c}%'
                }
            },
            data: [{
                value: 31,
                name: "女",
                label:{
                    normal:{
                        show:true
                    }
                }
            },{
                value: 100-60,
                name: ''
            }]
        }]
    };

在这里插入图片描述
4.饼状图

 option = {
        title: {
            text: '今日访问陌生人占比',
            top: 10,
            textStyle: {
                color: '#999',
                fontSize: 15
            }
        },
        tooltip : {
            trigger: 'item',
            formatter: "{b} : {c} ({d}%)"
        },
        series : [
            {
                type:'pie',
                radius : '55%',
                center: ['53%', '60%'],
                data:[
                    {
                        value:40, 
                        name:'陌生人',
                        itemStyle: {
                            color: '#ee4f69d3'
                        }                    
                    },
                    {
                        value:60, 
                        name:'非陌生人',
                        itemStyle: {
                            color: '#48a4dad3'
                        }                    
                    },
                ].sort(function (a, b) { return a.value - b.value; }),
                roseType: 'radius',
                label: {
                    normal: {
                        textStyle: {//文字颜色
                            color: '#999'
                        }
                    }
                },
                labelLine: {
                    normal: {
                        lineStyle: {
                            color: 'rgba(255, 255, 255, 0.3)'
                        },
                        smooth: 0.2,
                        length: 10,
                        length2: 20
                    }
                },
                itemStyle: {
                    normal: {
                        color: '#c23531',
                        shadowBlur: 200,
                        shadowColor: 'rgba(0, 0, 0, 0.5)',// 阴影颜色
                        label: {
                            show: true,
                            position: 'top'
                        }
                    }
                },
                animationType: 'scale',
                animationEasing: 'elasticOut',
                animationDelay: function (idx) {
                    return Math.random() * 200;
                }
            }
        ]
    };

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值