Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/queuepro/node_modules/jsvectormap/src/js/ drwxrwxr-x | |
| Viewing file: Select action/file-type: class DataVisualization {
constructor({ scale, values }, map) {
// Private
this._scale = scale
this._values = values
this._fromColor = this.hexToRgb(scale[0])
this._toColor = this.hexToRgb(scale[1])
this._map = map
this.setMinMaxValues(values)
this.visualize()
}
setMinMaxValues(values) {
this.min = Number.MAX_VALUE
this.max = 0
for (let value in values) {
value = parseFloat(values[value])
if (value > this.max) {
this.max = value
}
if (value < this.min) {
this.min = value
}
}
}
visualize() {
let attrs = {}, value
for (let regionCode in this._values) {
value = parseFloat(this._values[regionCode])
if (!isNaN(value)) {
attrs[regionCode] = this.getValue(value)
}
}
this.setAttributes(attrs)
}
setAttributes(attrs) {
for (let code in attrs) {
if (this._map.regions[code]) {
this._map.regions[code].element.setStyle('fill', attrs[code])
}
}
}
getValue(value) {
let hex, color = "#"
for (var i = 0; i < 3; i++) {
hex = Math.round(
this._fromColor[i] + (this._toColor[i] - this._fromColor[i]) * ((value - this.min) / (this.max - this.min))
).toString(16)
color += (hex.length === 1 ? "0" : "") + hex
}
return color
}
hexToRgb(h) {
let r = 0, g = 0, b = 0
if (h.length == 4) {
r = "0x" + h[1] + h[1]
g = "0x" + h[2] + h[2]
b = "0x" + h[3] + h[3]
} else if (h.length == 7) {
r = "0x" + h[1] + h[2]
g = "0x" + h[3] + h[4]
b = "0x" + h[5] + h[6]
}
return [parseInt(r), parseInt(g), parseInt(b)]
}
}
export default DataVisualization
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]-- |