var pmcolors=[{"id":1,"level":1,"lowval_pm25":1,"highval_pm25":35,"lowval_pm10":1,"highval_pm10":50,"description":"\u4f18","bgcolor":"#67ce0b","fgcolor":"#000000","type":"valid","bgcolor4":"#c4f1ff","bgcolor2":"#40FAFF","bgcolor_std":"#00e400","fgcolor2":"#000000"},{"id":2,"level":2,"lowval_pm25":36,"highval_pm25":75,"lowval_pm10":51,"highval_pm10":150,"description":"\u826f","bgcolor":"#f2d62d","fgcolor":"#000000","type":"valid","bgcolor4":"#06c4f1","bgcolor2":"#00EBEB","bgcolor_std":"#ffff00","fgcolor2":"#000000"},{"id":3,"level":3,"lowval_pm25":76,"highval_pm25":115,"lowval_pm10":151,"highval_pm10":250,"description":"\u8f7b\u5ea6\u6c61\u67d3","bgcolor":"#fa8a04","fgcolor":"#000000","type":"valid","bgcolor4":"#5cea04","bgcolor2":"#00EB00","bgcolor_std":"#ff7e00","fgcolor2":"#000000"},{"id":4,"level":4,"lowval_pm25":116,"highval_pm25":150,"lowval_pm10":251,"highval_pm10":350,"description":"\u4e2d\u5ea6\u6c61\u67d3","bgcolor":"#f80302","fgcolor":"#ffffff","type":"valid","bgcolor4":"#fbe700","bgcolor2":"#FFC800","bgcolor_std":"#ff0000","fgcolor2":"#000000"},{"id":5,"level":5,"lowval_pm25":151,"highval_pm25":250,"lowval_pm10":351,"highval_pm10":420,"description":"\u91cd\u5ea6\u6c61\u67d3","bgcolor":"#cf0000","fgcolor":"#ffffff","type":"valid","bgcolor4":"#ffa400","bgcolor2":"#FC9600","bgcolor_std":"#99004c","fgcolor2":"#000000"},{"id":6,"level":6,"lowval_pm25":251,"highval_pm25":350,"lowval_pm10":421,"highval_pm10":500,"description":"\u4e25\u91cd\u6c61\u67d3","bgcolor":"#970454","fgcolor":"#ffffff","type":"valid","bgcolor4":"#fa0300","bgcolor2":"#FA0000","bgcolor_std":"#7e0023","fgcolor2":"#ffffff"},{"id":7,"level":7,"lowval_pm25":351,"highval_pm25":500,"lowval_pm10":501,"highval_pm10":600,"description":"\u4e25\u91cd\u6c61\u67d3","bgcolor":"#5f021d","fgcolor":"#ffffff","type":"valid","bgcolor4":"#5f021d","bgcolor2":"#C800FA","bgcolor_std":"","fgcolor2":"#ffffff"},{"id":8,"level":8,"lowval_pm25":501,"highval_pm25":700,"lowval_pm10":601,"highval_pm10":700,"description":"\u4e25\u91cd\u6c61\u67d3","bgcolor":"#4d120a","fgcolor":"#ffffff","type":"valid","bgcolor4":"#4d120a","bgcolor2":"#FF64FF","bgcolor_std":"","fgcolor2":"#000000"}] window.pmcolors=pmcolors var pmcolor_range=[{"id":1,"value":"no_f","min":0,"max":500},{"id":2,"value":"co","min":0,"max":60000},{"id":3,"value":"no2","min":0,"max":940},{"id":4,"value":"o3","min":0,"max":1200},{"id":5,"value":"so2_f","min":0,"max":2620},{"id":6,"value":"tvoc","min":0,"max":15000},{"id":7,"value":"pm10","min":0,"max":700},{"id":8,"value":"pm25","min":0,"max":700},{"id":9,"value":"co_f","min":0,"max":60},{"id":10,"value":"cod","min":0,"max":700},{"id":11,"value":"ammonia_nitrogen","min":0,"max":700},{"id":12,"value":"turbidity","min":0,"max":700},{"id":13,"value":"temperature","min":0,"max":700},{"id":14,"value":"conductivity","min":0,"max":700},{"id":15,"value":"dissolved_oxygen","min":0,"max":700},{"id":16,"value":"ph","min":0,"max":700},{"id":17,"value":"pm100","min":0,"max":4000},{"id":18,"value":"dust","min":0,"max":30},{"id":19,"value":"chentu","min":0,"max":30}] window.pmcolor_range=pmcolor_range var pm_invalid={"id":9,"level":0,"lowval_pm25":-2,"highval_pm25":0,"lowval_pm10":-2,"highval_pm10":0,"description":"\u65e0\u6548\u6570\u636e","bgcolor":"#666666","fgcolor":"#ffffff","type":"invalid","bgcolor4":null,"bgcolor2":null,"bgcolor_std":"","fgcolor2":null} function getPMInfo(pmval,type){ var pm = parseInt(pmval) if(isNaN(pm)){ return pm_invalid } if (pm > 700){ return pmcolors[pmcolors.length-1] } for(var i=0;i=pv.lowval_pm25 && pm<=pv.highval_pm25){ return pv } } if(type=="pm10"){ if(pm>=pv.lowval_pm10&& pm<=pv.highval_pm10){ return pv } } } return pm_invalid } var info=getPMInfo(10,"pm25") console.log(info)