/** * 获取合适的字体大小 */ function fGetChartFontSize() { const dpr = window.devicePixelRatio; let fontSize = 12; if (dpr == 2) { fontSize = 17; } else if (dpr == 3) { fontSize = 24; } else if (dpr > 3) { fontSize = 24; } return fontSize; } function factorLineOption(_xAxis, _series, legends) { var fontSize = fGetChartFontSize(); return { animationEasing: 'elasticOut', animationDelayUpdate: function (idx) { return idx * 5; }, // toolbox: { // bottom: 0, // feature: { // dataZoom: {}, // magicType: { // type: ['line', 'bar'] // }, // restore: {} // } // }, tooltip: { textStyle: { fontSize: fontSize } }, legend: { type: 'scroll', data: legends, left: 0, textStyle: { fontSize: fontSize, color: 'white' } }, xAxis: { name: '时间', data: _xAxis, axisLabel: { textStyle: { fontSize: fontSize }, color: '#ffffff', textBorderColor: '#fff' }, axisTick: { lineStyle: { color: 'white' }, intervel: 0, inside: false }, nameTextStyle: { color: '#ffffff' }, axisLine: { lineStyle: { color: '#ffffff' } } }, yAxis: { name: '浓度(μg/m³)', axisLabel: { textStyle: { fontSize: fontSize } }, axisLine: { show: true, lineStyle: { color: 'white' } }, axisTick: { show: true, lineStyle: { color: 'white' } }, minInterval: 1 }, series: _series }; } export { factorLineOption };