鍍金池/ 問答/HTML/ 如何改變echarts折線圖折點位置

如何改變echarts折線圖折點位置

圖片描述

這是需求
圖片描述

這是我做的,但是這個折線圖的點集中在一個柱狀圖上面了!
求問怎么解決?

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    .main {
        width: 1200px;
        height: 1000px;
    }
</style>

<body>
    <div id="main" class="main"></div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="echarts.min.js"></script>
<script type="text/javascript">
    var myChart = echarts.init(document.getElementById('main'));
    var option = {
        color: ['#2AB2F7', '#75BF55', '#777DB4'],
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                }
            }
        },
        legend: {
            data: ['在線', '出庫', '已處理']
        },
        xAxis: [
            {
                type: 'category',
                data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '車輛數(shù)量趨勢',
                min: 0,
                max: 200,
                interval: 50,
                axisLabel: {
                    formatter: '{value} '
                }
            }
        ],
        series: [
            {
                name: '在線',
                type: 'bar',
                data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
            },
            {
                name: '在線',
                type: 'line',
                data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
            },
            {
                name: '出庫',
                type: 'bar',
                data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
            },
            {
                name: '出庫',
                type: 'line',
                data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
            },
            {
                name: '已處理',
                type: 'bar',
                data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
            },
            {
                name: '已處理',
                type: 'line',
                data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
            }
          
        ]
    };
    myChart.setOption(option);

</script>

</html>
回答
編輯回答
還吻

無法直接支持,不過有其他實現(xiàn)方式
https://github.com/apache/inc...

以下是我的做的一種實現(xiàn),加入一個不顯示的類型為value的x軸,根據(jù)第一個x軸的數(shù)據(jù)length設置max值,然后改寫線的數(shù)據(jù)格式,手工對齊一下:
http://gallery.echartsjs.com/...

2017年3月27日 07:24