chargement dynamique des graphiques

var oEnvironmentOption = {};
var oMethaneOption = {};
was chartInterval;

/ **

  • Infographie du capteur environnemental

  • @param {id: 'ID appareil', type: 'type d'appareil', etype: 'type d'environnement', données: 'informations sur les capteurs', seuils: 'liste de seuils'} paramètres
    * /
    fonction environmentChart (params, refreshtime) { var myChart = echarts.init (document.getElementById ('x-sensor-environment')); var oEnvironment = {} oEnvironment.id = params.id; oEnvironment.type = params.type; oEnvironment.etype = params.etype; oEnvironment .datas = params.datas; oEnvironment.aThresholds = params.thresholds || []; oEnvironmentOption = { title: { text: '' }, info - bulle: { trigger: 'axis' }, xAxis: { data: [], axisLine : { lineStyle: {


















    color: '# 15b5cd'
    }
    },
    axisLabel: { color: '# ffffff', formatter: function (value, index) { // Formater en mois / jour, afficher uniquement l'année sur la première échelle // var date = new Date (valeur); // var textes = [(date.getMonth () + 1), date.getDate ()]; // if (index === 0) { // textes.unshift (date.getYear () ); //} // return textes.join ('/'); var time = value.split ("") [1]; return time } } }, yAxis: { splitLine: { show: true, lineStyle: { color: 'rgba (0,0,0,0.2)' } }, axisLine: { lineStyle: {























    couleur: '# 15b5cd'
    }
    },
    axisLabel: { color: '#ffffff' }, }, grille: { haut: '10% ', gauche:' 0% ', droite:' 4% ', bas:' 0 % ', containLabel: true }, toolbox: { show: false, left:' center ', feature: { dataZoom: { yAxisIndex:' none ' }, restore: {}, saveAsImage: {} } }, visualMap: { show : false, top: 10, right: 10, pieces: [], outOfRange: { color: '# ff4f51' } }, series: {































    name: '',
    type: 'line',
    data: [],
    markLine: { silent: true, data: [] } } } // 设置 阈 值var marklineData = [], piecesData = []; pour (var i = 0; i <oEnvironment.aThresholds.length; i ++) { var oThreshold = oEnvironment.aThresholds [i]; if (oEnvironment.etype == oThreshold.type) { // oEnvironmentOption.yAxis.min = 0; // oEnvironmentOption.yAxis.max = oThreshold.excessValue + 50; piecesData.push ({'gt': 0, 'lte': oThreshold.alertValue, 'color': '# 3ef6ff'}, {'gt': oThreshold.alertValue, 'lte': oThreshold.excessValue, 'color': '# fff100'})













    marklineData.push ({'yAxis': oThreshold.alertValue}, {'yAxis': oThreshold.excessValue});
    break
    }
    }
    oEnvironmentOption.series.markLine.data = marklineData
    oEnvironmentOption.visualMap.pieces = piecesData
    // 设置 系列
    var seriesData = [], xAxisData = [];
    var typename = getEnvironmentName (oEnvironment.etype);
    var typenamezh = nom_type [1];
    var typenameen = typename [0];
    pour (var i = 0; i <oEnvironment.datas.length; i ++) { var oData = oEnvironment.datas [i]; xAxisData.push (oData.createDate); seriesData.push (oData [typenameen]); } var endLen = seriesData.length / 2; oEnvironmentOption.series.name = typenamezh;






    oEnvironmentOption.xAxis.data = xAxisData.splice (0, endLen);
    oEnvironmentOption.series.data = seriesData.splice (0, endLen);
    // oEnvironmentOption.xAxis.data = xAxisData;
    // oEnvironmentOption.series.data = seriesData;
    myChart.setOption (oEnvironmentOption);

    // 隔 1 秒 增减 数值
    var totalNum = xAxisData.length;
    var num = 0;
    var newDatas = [];
    function loopplay () { num ++; if (num == totalNum) { refreshRenderChart (oEnvironment.id, oEnvironment.type, function (datas) { newDatas = datas if (newDatas.length> 0) { for (var i = 0; i <newDatas.length; i ++) { var newData = newDatas [i]; xAxisData.push (newData.createDate); seriesData.push (newData [typenameen]); } totalNum = xAxisData.length; num = 0; } }); } if (num> totalNum) { totalNum = xAxisData.length; num = -1;


















    clearInterval (chartInterval);
    // chartInterval = null;
    setTimeout (function () { chartInterval = setInterval (loopplay, 1100); }, refreshtime) // return } if (totalNum> 1) { var sdata = oEnvironmentOption.series.data; var val = seriesData.splice (0, 1) .toString (); sdata.shift () sdata.push (val);








         var date = xAxisData.splice(0, 1).toString();
         oEnvironmentOption.xAxis.data.shift();
         oEnvironmentOption.xAxis.data.push(date);
         myChart.setOption(oEnvironmentOption);
         // console.log(new Date())
     }
    

    }
    clearInterval (chartInterval);
    chartInterval = setInterval (lecture en boucle, 1100);

    // Déplacez la souris sur le graphique pour arrêter la lecture de
    document.getElementById ('x-sensor-environment'). AddEventListener ('mouseover', function (e) { if (e.currentTarget.id == 'x-sensor-environment' ' ') { clearInterval (chartInterval); } }) // Déplacez la souris hors du graphique pour continuer la lecture document.getElementById (' x-sensor-environment '). addEventListener (' mouseleave ', function (e) { if (e .currentTarget.id == 'x -sensor-environment') { clearInterval (chartInterval); chartInterval = setInterval (loopplay, 1100); } }) } function getEnvironmentName (type) { var name = [] switch (type) { case 1: name = ['ch4', 'Methane'] break; cas 2:



















    name = ['pm25', 'PM 2.5']
    pause;
    cas 3:
    nom = ['pm10', 'PM 10']
    pause;
    cas 4:
    nom = ['tps', 'TSP']
    break;
    cas 5:
    nom = ['humidité', '湿度']
    pause;
    cas 6:
    name = ['noise', '噪音']
    break;
    cas 7:
    nom = ['pression atmosphérique', '气压']
    rupture;
    cas 8:
    nom = ['windSpeed', '风速']
    break;
    cas 9:
    name = ['temperature', '温度']
    break;
    }
    nom de retour;
    }

Je suppose que tu aimes

Origine blog.csdn.net/weixin_42549581/article/details/108731492
conseillé
Classement