var xData = param.xData;spa
var data = param.yData let option = []; let num =param.num ? param.num : 0; let max = num ? num *100 : 100; //處理精度丟失問題 但不是最佳方案 let startValue = param.startValue; visualMap: [{ show: false, top: 20, right: 10, default:10, pieces:[{ //分層的實現主要是在裏代碼 gt: 0, lte: num, color: '#ffde33' },{ gt: num, lte: max, color: '#f00' }], outOfRange: { // 超出範圍 color: '#f00' } }], title: [{ top: '', left: 'center', text: param.title, }], tooltip: { trigger: 'axis', formatter: function(params){ var text_Unit =''; for(var i = 0;i < params.length;i++){ text_Unit += params[i].value + param.Unit + "</br>" } return params[0].name + "</br>" + text_Unit; } }, xAxis: [{ data: xData, gridIndex: 1, }], yAxis: [{ name: param.yName, splitLine: { show: false }, gridIndex: 1, }], grid: [{ bottom: '', }, { top: '20%', }], series: { type: 'line', showSymbol: false, data: data, markLine: { silent: true, data: [{ yAxis: num },] } }