// 1. 導入 echarts import echarts from 'echarts'
<!-- 2. 為ECharts准備一個具備大小(寬高)的Dom --> <div id="main1" style="width: 100%;height:400px;"></div>
1 // 此時,頁面上的元素,已經被渲染完畢 2 mounted () { 3 // 3. 基於准備好的dom,初始化echarts實例 4 var myChart1 = echarts.init(document.getElementById('main1')) 5 var option1 = { 6 // title: { 7 // text: '折線圖堆疊' 8 // }, 9 tooltip: { 10 trigger: 'axis' 11 }, 12 legend: { 13 data: ['提現人數'], 14 align: 'left', 15 left: 10 16 }, 17 grid: { 18 left: '3%', 19 right: '4%', 20 bottom: '3%', 21 containLabel: true 22 }, 23 toolbox: { 24 feature: { 25 saveAsImage: {} 26 } 27 }, 28 xAxis: { 29 type: 'category', 30 boundaryGap: false, 31 data: ['2019-11-20', '2019-11-21', '2019-11-22', '2019-11-23', '2019-11-24', '2019-11-25', '2019-11-26', '2019-11-27', '2019-11-28', '2019-11-29', '2019-11-30', '2019-12-01', '2019-12-02', '2019-12-03', '2019-12-04', '2019-12-05', '2019-12-06', '2019-12-07', '2019-12-08', '2019-12-09', '2019-12-10', '2019-12-11', '2019-12-12', '2019-12-13', '2019-12-14', '2019-12-15', '2019-12-16', '2019-12-17', '2019-12-18', '2019-12-02'], 32 // X軸數據隔一個顯示 通過設置 interval 33 axisLabel: { 34 interval: 1 35 } 36 }, 37 yAxis: { 38 type: 'value', 39 // 可以矯正Y軸數據和折線圖數據不匹配的問題 40 min: 0, 41 max: 18, 42 data: [0, 3, 6, 9, 12, 15, 18] 43 }, 44 color: ['#61a2ec'], 45 smooth: true, 46 series: [ 47 { 48 name: '提現人數', 49 smooth: false, 50 type: 'line', 51 data: [5, 0, 7, 2, 1, 5, 1, 2, 3, 4, 5, 0, 0, 16, 2, 5, 7, 3, 1, 5, 2, 7, 2, 5, 6, 0, 2, 5, 3, 3], 52 lineStyle: { 53 normal: { 54 color: '#61a2ec', 55 width: 2 56 } 57 } 58 } 59 ] 60 } 61 // 5. 展示數據 62 myChart1.setOption(option1)