用echarts繪制面積折線圖和折線

<body>
 <div id="echarts" style="height:300px;"></div>
      <script type="text/javascript">
        var mychartdd = echarts.init(document.getElementById('echarts'));
        option = {
            title: {
                text: '今日',
                left: '50%',
                textAlign: 'center'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    lineStyle: {
                        color: '#ddd'
                    }
                },
                backgroundColor: 'rgba(255,255,255,0.5)',
                padding: [5, 10],
                textStyle: {
                    color: '#7588E4',
                },
                extraCssText: 'box-shadow: 0 0 5px rgba(0,0,0,0.3)'
            },
            dataZoom: [{
                    type:'slider',
                    xAxisIndex:0,
                    height:'15',
                    bottom:'55',
                    show: true,  
                    start: 0,  
                    end: 100,
                    handleStyle:{ /*手柄的樣式*/
                        width:'20',
                        color:"#085ABF",
                        borderColor:"#085ABF"
                    },
                    backgroundColor:"#f7f7f7", /*背景 */
                    dataBackground:{ /*數(shù)據(jù)背景*/
                        lineStyle:{
                            color:"#dfdfdf"
                        },
                        areaStyle:{
                            color:"#dfdfdf"
                        }
                    },
                    fillerColor:"#FFEFBE", /*被start和end遮住的背景*/
                    labelFormatter:function (value,params) { /*拖動時兩端的文字提示*/
                        var str = "";
                        if(params.length > 4){
                            str = params.substring(0,4)+"…";
                        }else {
                            str = params;
                        }
                        return str;
                    }
                }],
            legend: {
                right: 20,
                orient: 'vertical',
                data: ['今日']
            },
            xAxis: {
                type: 'category',
                name:'日期',
                data: ['00:00','2:00','4:00','6:00','8:00','10:00','12:00','14:00','16:00','18:00','20:00',"22:00"],
                boundaryGap: false,
                splitLine: {
                    show: false,
                    interval: 'auto',
                    lineStyle: {
                        color: ['#EEEEEE']
                    }
                },
                axisTick: {
                    show: false
                },
                axisLine: {
                    lineStyle: {
                        color: '#50697A'
                    }
                },
                axisLabel: {
                    margin: 10,
                    textStyle: {
                        color:'#50697A',
                        fontSize: 13
                    }
                }
            },
            yAxis: {
                type: 'value',
                name:'數(shù)量(件)',
                splitLine: {
                    lineStyle: {
                        color: ['#EEEEEE']
                    }
                },
                axisTick: {
                    show: false
                },
                axisLine: {
                    lineStyle: {
                        color: '#50697A'
                    }
                },
                axisLabel: {
                    margin: 10,
                    textStyle: {
                        color:'#50697A',
                        fontSize: 13
                    }
                }
            },
            series: [{
                name: '今日',
                type: 'line',
                smooth: true,
                showSymbol: false,
                symbol: 'circle',
                symbolSize: 6,
                data: ['1200', '1400', '808', '811', '626', '488', '1600', '1100', '500', '300', '1998', '822'],
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba(16, 79, 193,1)'
                        }, {
                            offset: 1,
                            color: 'rgba(125, 178, 244,1)'
                        }], false)
                    }
                },
                itemStyle: {
                    normal: {
                        color: 'rgba(16, 79, 193,1)'
                    }
                },
                lineStyle: {
                    normal: {
                        width: 0
                    }
                }
            },{
                name:'折線',
                type:'line',
                symbol:'circle',
                symbolSize:10,
                data: ['1200', '1400', '808', '811', '626', '488', '1600', '1100', '500', '300', '1998', '822'],
                itemStyle:{  //折線拐點(diǎn)的樣式
                    normal:{
                        color:'#FAC220',  //折線拐點(diǎn)的顏色
                    }
                },
                lineStyle:{  //線條的樣式
                    normal:{
                        color:'#FAC220',  //折線顏色
                    }
                }
            }]
        };
        mychartdd.setOption(option);
    </script>
</body>

實際效果圖如下:


QQ圖片20180108161225.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容