echarts

2018/05/11 14:26
阅读数 298

一、准备

  1. echarts-3.3.2.min.js

  2. jquery.1.11.1.min.js
二、圆角加多渐变条形(ie8+)统计图

function barChart(id,data1,data2) {

        var colorShow = [
                [
                    {offset: 0, color: '#FDD841'},
                    {offset: 0.5, color: '#FAB84B'},
                    {offset: 1, color: '#F79E55'}
                ],
                [
                    {offset: 0, color: '#65D5FA'},
                    {offset: 0.5, color: '#2A93D6'},
                    {offset: 1, color: '#1868BC'}
                ],
                [
                    {offset: 0, color: '#36CBCE'},
                    {offset: 0.5, color: '#2EC7BF'},
                    {offset: 1, color: '#29C3AE'}
                ],
                [
                    {offset: 0, color: '#EC97A7'},
                    {offset: 0.5, color: '#DA6986'},
                    {offset: 1, color: '#CA426B'}
                ]
            ];
        var colorHover =  [
                {offset: 1, color: '#1868BC'},
                {offset: 0.5, color: '#2A93D6'},
                {offset: 0, color: '#65D5FA'}
            ];

        var chartGradient = function(params,colorList){
            //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
            return new echarts.graphic.LinearGradient(0, 0, 0, 1, colorList[params.dataIndex] )
        };


        var option2 = {
            tooltip: {
                trigger: 'axis'
            },
            calculable: true,
            xAxis: [
                {
                    type: 'category',
                    data: data1
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: ' ',
                    axisLabel: {
                        formatter: '{value} '
                    }
                }
            ],
            grid:{
              left:'8%',
              right:'2%',
                top:'16%',
                bottom:'12%'
            },
            series: [
                {
                    type: 'bar',
                    barWidth: '20%',
                    barCategoryGap: '50%',
                    data: data2,
                    itemStyle: {
                        //柱形图圆角,鼠标移上去效果
                        emphasis: {
                            barBorderRadius:50,
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1,colorHover )
                        },
                        normal: {
                            //柱形图圆角,初始化效果
                            barBorderRadius: 50,
                            color:function(params){
                                return chartGradient(params,colorShow)
                            }
                        }
                    }
                }
            ]
        };

        var Chart2 = echarts.init(document.getElementById(id));
        Chart2.setOption(option2, true);
        $(window).resize(function (event) {
            Chart2.resize();
        });
    }

    barChart('c-device-bar',["关机时长", "运行时长", "空闲时长", "维修时长"],[6, 18, 3, 5]);

效果展示:

        

三、渐变加背景图(ie8+)饼图

.c-line-charts-pie {
    width: 204px;
    height: 204px;
}
<div class="c-line-charts-pie f_left" id="c-device-charts-pie"></div>
//饼状图
function pieChart(id,name,value,color,radius,state){

    var piePatternSrc = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAC5CAYAAABtJnD6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAAAWdEVYdENyZWF0aW9uIFRpbWUAMDUvMDgvMTiekVlbAAAc7klEQVR4nO2dbaxsV3nff89ae8+cl3vute+9foltnGuDwRhjXAwRkRJIQ9SW5EPzXrWhqtq0UduoKqhBkUohLaEf0hQ1QQqpqqQkKCBihNKgCKFESZRC1CAVEhHAxNgY1za28X09955zZvbeaz39sNae2WfO3O1zX86c43ufnzRnZvbs2XvOnvVf63lba0RVMQxjPm6/P4BhHGRMIIbRgwnEMHowgRhGDyYQw+jBBGIYPZhADKMHE4hh9GACMYweTCCG0YMJxDB6MIEYRg8mEMPowQRiGD2YQAyjBxOIYfRgAjGMHkwghtGDCcQwejCBGEYPJhDD6MEEYhg9mEAMowcTiGH0YAIxjB5MIIbRgwnEMHowgRhGDyYQw+jBBGIYPZhADKMHE4hh9GACMYweTCCG0YMJxDB6MIEYRg8mEMPowQRiGD2YQAyjBxOIYfRgAjGMHkwghtGDCcQwejCBGEYPJhDD6MEEYhg9mEAMowcTiGH0YAIxjB5MIIbRgwnEMHowgRhGDyYQw+jBBGIYPZhADKMHE4hh9GACMYweTCCG0YMJxDB6MIEYRg8mEMPowQRiGD2YQAyjBxOIYfRgAjGMHkwghtGDCcQwejCBGEYPJhDD6MEEYhg9mEAMowcTiGH0YAIxjB5MI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PAadCWsj6FIGAZ4tlPiMDPlXkEaQe8d1E3qxxstTZ0jbDKv1tfZKWy/dBpns/Anxk+QS/fdH/y+jFBHIpSA7TCk+I8KHQ8CER3iTwZuANKN9COUnNGaDJqx2O/YA/BP4Q8hz4wFgVFyse0MCDpDL8u9tzdM8HzASPZ16DvwH+L8LnXMH/9rdwpiTHmNsluo3LRvQA1yP/o6f7X1fysiRV/o3AJk3rU0lr9GgEqUjdQMUkxeaA2oG2c8zzctUa21/hYboM9BjaH0mWEsI4r2cbITQz8xyUh/A8hPI60grvJ4HnST+tnH65Sqhp8krqTV4Z3TEWRxWUWpRIiboC1YbGD4jqiZpmWDgKoqZ5KmmyVqBBaNqlJ6RES00zuF5MIA8/sOuv4rrFRpCryxdQvpBnq98FPAScQHkF6bdETqGcQTjLgHOU1ChRlDIU1JKc+VrbHwJYITSBxru8/JBSUeXIF2xR03QWkmOSazm4fd5LDhPIXqE8gfAESpsteTlwn4OXE3kgeG5AOIlyDseGFnm19IYN79hU2MJxFmGdhnUcm6S1utICRu1CQOZH7CkmkEWgQORxhcch+Qc+jQkljttpOOIVQiSIY13hPJELaKesRWaOZ8JYCP8f2TeJlVbyrXAAAAAASUVORK5CYII=';

    var piePatternImg = new Image();
    piePatternImg.src = piePatternSrc;

    /*判读IE8-*/
    var judge = $.support.leadingWhitespace;

    if(state == 1){
        var itemStyle = {
            normal: {
                color: {
                    image: piePatternImg,
                    repeat: 'repeat',
                    //position:'center'
                },
                borderWidth: 0,
                borderColor: 'rgba(0,0,0,0)'
            }
        };
    }else if(state == 0){
        var itemStyle = {
            normal : {
                color:'rgba(0,0,0,0)'
            }
        }
    }
    var labelTop = {
        normal : {
            label : {
                show : true,
                position : 'center',
                formatter : '{b}',
                textStyle: {
                    baseline : 'bottom',
                    fontSize:'20',
                    color:'#777777'
                }
            },
            labelLine : {
                show : false
            }
        }
    };

    var labelBottom = {
        normal : {
            color: 'rgba(0,0,0,0)',
            label : {
                show : true,
                position : 'center',
                textStyle: {
                    fontSize:'20',
                    color:color[1]
                }
            },
            labelLine : {
                show : false
            }
        },
        emphasis: {
            color: '#e9eee8'
        }
    };



    var colorStyle = judge ? new echarts.graphic.LinearGradient(0, 0, 0, 1,[{offset: 0, color: color[0]},{offset: 1, color: color[1]}] ): color[0];

    var option1 = {
        grid:{  
       left:'8%',  
       right:'0',
            top:'10%',
        bottom:'1%',  
        containLabel: true  
        },  
        series : [
            {
                type : 'pie',
                hoverAnimation:false,
                center : ['50%', '50%'],
                radius : ['0%', '70%'],
                x: '0%',
                data : [
                    {name:'', value:0, itemStyle : labelBottom},
                    {name:'', value:100,itemStyle : labelTop}
                ],
                itemStyle: itemStyle
            },
            {
                type : 'pie',
                hoverAnimation:false,
                center : ['50%', '50%'],
                radius : radius,
                x: '0%',
                itemStyle : {
                    normal : {
                        color:'#e9eee8'
                    }
                },
                data : [
                    {name:'', value:0, itemStyle : labelBottom},
                    {name:'', value:100,itemStyle : labelTop}
                ]
            },
            {
                type : 'pie',
                hoverAnimation:true,
                hoverOffset: 6,
                center : ['50%', '50%'],
                radius : radius,
                x: '0%',
                itemStyle : {
                    normal : {
                        color:colorStyle
                    }

                },
                data : [
                    {name:value +'%', value:100 - value, itemStyle : labelBottom},
                    {name:name, value:value,itemStyle : labelTop}
                ]

            },
            
        ]
    };
    var Chart1 = echarts.init(document.getElementById(id));
    Chart1.setOption(option1,true);
    $(window).resize(function(event) {
        Chart1.resize();
    });
}

   pieChart('c-device-charts-pie','OEE',90,['#4ed8ff','#0c5ab5'],['70%', '80%'],1);

效果展示:
           

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部