function (data,params){ // const myChart = this.myChart; const yearData2 = [2020, 2021, 2022, 2023, 2024, 2025]; const personData2 = [820, 932, 901, 934, 1290, 1330, 1320]; data.sort((a, b) => a.nj - b.nj); const yearData = []; const personData = []; data.forEach(item => { yearData.push(item.nj); personData.push(item.count); }) const option = { tooltip: { trigger: 'axis' }, xAxis: { name: '年', nameTextStyle: { color: '#9AA6B8', fontSize: 16 }, type: 'category', boundaryGap: false, data: yearData, axisLabel: { show: true, fontSize: 16, textStyle: { color: '#9AA6B8', } }, }, yAxis: { name: '单位: 人', nameTextStyle: { color: '#9AA6B8', fontSize: 16 }, type: 'value', splitLine: { show: true, lineStyle: { type: 'dashed', // 设置刻度线为虚线个数 } }, axisLabel: { show: true, fontSize: 16, textStyle: { color: '#9AA6B8', } } }, series: [ { data: personData, type: 'line', smooth: true, symbol: 'circle', // 设置曲线两头的形状为圆形 symbolSize: 4, // 大小 showSymbol: false, // 默认不显示圆点 emphasis: { // 鼠标悬浮时显示原点【要配合tooltip: trigger: 'xxx'使用】 focus: 'series', itemStyle: { color: '#FFFFFF', // 鼠标悬浮时折线点的颜色 borderColor: '#FFE04D', borderWidth: 3 } }, lineStyle: { width: 2, color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: '#F45A23' }, // %0 处的颜色 { offset: 0.5, color: '#FFE04D' }, // %50 处的颜色 { offset: 1, color: '#F45A23' }, // 100% 处的颜色 ], global: false // 缺省为 false } }, areaStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: 'rgba(255, 224, 77, 0.75)' }, // 0% 处的颜色 { offset: 1, color: 'rgba(255, 224, 77, 0)' } // 100% 处的颜色 ], global: false // 缺省为 false } }, } ] }; return option; }
标签:false,曲线图,color,data,offset,const,type From: https://www.cnblogs.com/ladybug7/p/18261329