fst – Rev 1
?pathlinks?
(function () {
function getOrigins(data) {
// Get geographic metrics
const geo = data.geo
return Object.keys(geo).map(function (item) {
return {
code: item,
value: geo[item]
}
})
}
// Setup incidents map.
$.getJSON('/metrics', function (data) {
data = getOrigins(data)
// Initiate the chart
var originsMap = Highcharts.mapChart('containerOrigins', {
chart: {
backgroundColor: 'rgba(255, 255, 255, 0.0)',
height: '80%',
map: 'custom/world',
events: {
load: function () {
var series = this.series[0]
var axis = this.colorAxis[0]
setInterval(function () {
$.getJSON('/metrics', function (data) {
// Get geographic metrics
data = getOrigins(data)
// Update series
series.update({
data: data
}, true)
axis.max = Math.max(...data.map(function (item) {
if (item !== null && item.value !== null)
return item.value
return 0
}))
originsMap.redraw()
originsMap.hideLoading()
})
}, 1000)
}
}
},
credits: {
enabled: false
},
title: {
text: ''
},
legend: {
title: {
text: 'Attack density',
style: {
color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
}
}
},
mapNavigation: {
enabled: false,
buttonOptions: {
verticalAlign: 'bottom'
}
},
tooltip: {
backgroundColor: 'none',
borderWidth: 0,
shadow: false,
useHTML: true,
padding: 0,
pointFormat: '<span class="f32"><span class="flag {point.properties.hc-key}">' +
'</span></span> {point.name}<br>' +
'<span style="font-size:12px">Attacks: {point.value}</span>'
},
colorAxis: {
min: 1,
type: 'linear',
minColor: '#ffffff',
maxColor: '#700800'
},
series: [{
data: data,
joinBy: ['iso-a2', 'code'],
name: 'Attack density',
states: {
hover: {
color: '#a4edba'
}
}
}]
})
})
})()
Generated by GNU Enscript 1.6.5.90.