1. 程式人生 > 其它 >echarts學習之----多圖例折線圖

echarts學習之----多圖例折線圖

直接上程式碼:

<template>
    <div id="chart-test1" :style="{ height: '500px',width:'1000px'}"></div>
</template>

<script>
    export default {
        data() {
            return {
                testOption1: {
                    backgroundColor: '', //設定背景色透明
                    legend: {
                        data: [
'蘋果', '梨'], //圖例的資料陣列 selectedMode: 'single' //展示單項 }, xAxis: { type: 'category', data: ['2015年', '2016年', '2017年', '2018年', '2019年', '2020年', '2021年'] }, yAxis: { type:
'value' }, series: [{//資料 name: "蘋果", data: [147, 123, 432, 230, 135, 543, 234], type: 'line' }, { name: "梨", data: [666, 280, 453, 263, 576, 153, 663], type:
'line' }] } }; }, components: {}, mounted() { //測試一 let chartTest1 = this.$echarts.init(document.getElementById("chart-test1"), 'dark'); chartTest1.setOption(this.testOption1) }, methods: {} } </script> <style> </style>

效果: