Echarts折線圖的折線實線設(shè)置成虛線

主要修改屬性

  itemStyle:{
                normal:{
                    lineStyle:{
                        width:2,
                        type:'dotted'  //'dotted'虛線 'solid'實線
                    }
                }
            },   

實例代碼:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
        <script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js" type="text/javascript"></script>
    </head>
    <body>
        <!-- 為ECharts準備一個具備大小(寬高)的Dom -->
        <div id="main" class="col-md-12  col-sm-12 col-xs-12" style="height: 400px;"></div>
        <script>
            // 折線圖
            var names = []; //類別數(shù)組(實際用來盛放X軸坐標值)    
            var series = [];
            $.ajax({
                url: "test.json",
                data: {},
                type: 'GET',
                success: function(data) {
                    //請求成功時執(zhí)行該函數(shù)內(nèi)容,data即為服務(wù)器返回的json對象           
                    $.each(data.data, function(index, item) {
                        names.push(item.statTime); //挨個取出類別并填入類別數(shù)組
                        series.push(item.noPatrolNum);
                    });
                    hFun(names, series);
                },
            });
            // 心率
            var hrChart = echarts.init(document.getElementById("main"));

            function hFun(x_data, y_data) {
                hrChart.setOption({
                    color: ['#1e63d8'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: { // 坐標軸指示器,坐標軸觸發(fā)有效
                            type: 'shadow' // 默認為直線,可選為:'line' | 'shadow'
                        }
                    },
                    legend: {
                        data: ['漏檢次數(shù)']
                    },
                    grid: {
                        left: '3%',
                        right: '20%',
                        bottom: '20%',
                        containLabel: true
                    },
                    xAxis: {

                        type: 'category',
                        data: x_data,
                    },
                    yAxis: { // 縱軸標尺固定

                        type: 'value',
                        scale: true,
                        name: '漏檢次數(shù)',
                        min: 0, // 就是這兩個 最小值
                        max: 'dataMax', // 最大值
                        splitNumber: 10,

                        boundaryGap: [0.2, 0.2]
                    },
                    series: [{
                        name: '漏檢次數(shù)',
                        type: 'line',
                        symbol: 'circle', // 折線點設(shè)置為實心點
                        symbolSize: 6, // 折線點的大小
                        itemStyle: {
                            normal: {
                                lineStyle: {
                                    width: 2,
                                    type: 'dotted' //'dotted'虛線 'solid'實線
                                }
                            }
                        },

                        data: y_data
                    }]
                }, true);
            }
        </script>
    </body>
</html>

json

{
    "msg": "查詢成功",
    "code": 1,
    "data": [{      
        "statTime": "2021-01",      
        "noPatrolNum": 12
    }, {      
        "statTime": "2021-02",      
        "noPatrolNum": 21
    },{      
        "statTime": "2021-03",      
        "noPatrolNum": 27
    },{        
        "statTime": "2021-04",
        "noPatrolNum": 15
    }]
}

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

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

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