| | |
| | | |
| | | //各监测因子数据分级(标准) |
| | | _legend_r: { |
| | | NO: [0, 100, 200, 700, 1200, 2340], |
| | | NO2: [0, 100, 200, 700, 1200, 2340], |
| | | CO: [0, 5, 10, 35, 60, 90], |
| | | H2S: [0, 150, 500, 650, 800, 1600], |
| | |
| | | |
| | | //各监测因子数据分级(标准)对应颜色 |
| | | _legend_c: { |
| | | NO: [ |
| | | [0, 0.89, 0, 0.75], |
| | | [1, 1, 0, 0.75], |
| | | [1, 0.49, 0, 0.75], |
| | | [1, 0, 0, 0.75], |
| | | [0.6, 0, 0.3, 0.75], |
| | | [0.49, 0, 0.14, 0.75] |
| | | ], |
| | | NO2: [ |
| | | [0, 0.89, 0, 0.75], |
| | | [1, 1, 0, 0.75], |
| | |
| | | ] |
| | | }, |
| | | |
| | | // _custom: [ |
| | | // [0.05, 0.9, 0.03, 0.75], |
| | | // [0.3, 0.65, 0.02, 0.75], |
| | | // [0.87, 0.92, 0.03, 0.75], |
| | | // [0.8, 0.67, 0.04, 0.75], |
| | | // [0.92, 0.28, 0.07, 0.75], |
| | | // [0.6, 0.05, 0.05, 0.75] |
| | | // ], |
| | | _custom: [ |
| | | [0.05, 0.9, 0.03, 0.75], |
| | | [0.3, 0.65, 0.02, 0.75], |
| | | [0.87, 0.92, 0.03, 0.75], |
| | | [0.8, 0.67, 0.04, 0.75], |
| | | [0.92, 0.28, 0.07, 0.75], |
| | | [0.6, 0.05, 0.05, 0.75] |
| | | [0, 0.89, 0, 0.75], |
| | | [1, 1, 0, 0.75], |
| | | [1, 0.49, 0, 0.75], |
| | | [1, 0, 0, 0.75], |
| | | [0.6, 0, 0.3, 0.75], |
| | | [0.49, 0, 0.14, 0.75] |
| | | ], |
| | | |
| | | getStandardRange: function (name) { |
| | |
| | | }, |
| | | |
| | | /** |
| | | * 获取当前颜色上一个等级的颜色 |
| | | * @param {*} name |
| | | * @param {*} type |
| | | * @param {*} color |
| | | */ |
| | | getPreviousColor(name, type, color) { |
| | | let colors; |
| | | if (type == this.S_TYPE) { |
| | | colors = this._legend_c[name]; |
| | | } else { |
| | | colors = this._custom; |
| | | } |
| | | if (colors == undefined) { |
| | | colors = this._legend_c['PM25']; |
| | | } |
| | | let index = colors.indexOf(color); |
| | | index--; |
| | | if (index < 0) index = 0; |
| | | return colors[index]; |
| | | }, |
| | | |
| | | /** |
| | | * 获取监测因子当前浓度对应的颜色 |
| | | * @param name 监测因子名称 |
| | | * @param data 监测因子浓度 |
| | | */ |
| | | getStandardColor: function (name, data) { |
| | | var range = this._legend_r[name]; |
| | | var colors = this._legend_c[name]; |
| | | let range = this._legend_r[name]; |
| | | let colors = this._legend_c[name]; |
| | | if (range == undefined) { |
| | | range = this._legend_r['PM25']; |
| | | colors = this._legend_c['PM25']; |
| | | } |
| | | // return colors[0] |
| | | |
| | | var selected = undefined; |
| | | let selected = undefined; |
| | | for (let i = 0; i < range.length; i++) { |
| | | const d = range[i]; |
| | | var d1 = d; |
| | | let d1 = d; |
| | | if (name == 'CO') { |
| | | d1 *= 1000; |
| | | } |
| | |
| | | |
| | | getCustomColor: function (data, min, max) { |
| | | var per = (max - min) / this._custom.length; |
| | | var i = parseInt(data / per); |
| | | var i = parseInt((data - min) / per); |
| | | if (i >= this._custom.length) { |
| | | i = this._custom.length - 1; |
| | | } |