web_defender/static/malware/js/barMalwareChart.js
2024-12-09 13:43:16 +05:30

95 lines
3.2 KiB
JavaScript

google.charts.load("current", { packages: ['corechart'] });
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
["Element", "Density", { role: "style" }],
["Ramnit", 10, "#000080"],
["Lollipop", 15, "#0000ff"],
["Kelihos_ver3", 20, "#0081ff"],
["Vundo", 9, "#17ffe2"],
["Simda", 12, "#7bff7b"],
["Tracur", 11, "#e3ff15"],
["Kelihos_ver1", 15, "#ff9801"],
["Obfuscator.ACY", 15, "#ff2200"],
["Gatak", 12, "#810000"],
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, 2]);
var options = {
title: "",
// width: 990,
height: 430,
// bar: { groupWidth: "95%" },
legend: { position: "none" },
backgroundColor: '#0c212b',
tooltip: { trigger: 'none' },
vAxis: {
title: 'Count',
viewWindow: {
min: 0,
max: 100
}
},
hAxis: { title: 'Class' },
legend: {
position: 'none' // Disable the default legend
},
};
var chart = new google.visualization.ColumnChart(document.getElementById("barMalwareChart"));
chart.draw(view, options);
function updateData() {
var deviceId = localStorage.getItem('deviceId');
if (deviceId === 'xAq9W1PO5rmAuuQ' || deviceId === 'wzI0R1JqWqV0Lyi'){
var newData = [
["Element", "Density", { role: "style" }],
["Ramnit", Math.floor(Math.random() * 4) + 5, "#000080"],
["Lollipop", Math.floor(Math.random() * 4) + 5, "#0000ff"],
["Kelihos_ver3", Math.floor(Math.random() * 4) + 5, "#0081ff"],
["Vundo", Math.floor(Math.random() * 4) + 5, "#17ffe2"],
["Simda", Math.floor(Math.random() * 4) + 5, "#7bff7b"],
["Tracur", Math.floor(Math.random() * 4) + 5, "#e3ff15"],
["Kelihos_ver1", Math.floor(Math.random() * 4) + 5, "#ff9801"],
["Obfuscator.ACY", Math.floor(Math.random() * 4) + 5, "#ff2200"],
["Gatak", Math.floor(Math.random() * 4) + 5, "#810000"],
];
data = google.visualization.arrayToDataTable(newData);
view = new google.visualization.DataView(data);
view.setColumns([0, 1, 2]);
chart.draw(view, options);
} else {
var newData = [
["Element", "Density", { role: "style" }],
["Ramnit",0, "#000080"],
["Lollipop",0, "#0000ff"],
["Kelihos_ver3",0, "#0081ff"],
["Vundo",0, "#17ffe2"],
["Simda",0, "#7bff7b"],
["Tracur",0, "#e3ff15"],
["Kelihos_ver1",0, "#ff9801"],
["Obfuscator.ACY",0, "#ff2200"],
["Gatak",0, "#810000"],
];
data = google.visualization.arrayToDataTable(newData);
view = new google.visualization.DataView(data);
view.setColumns([0, 1, 2]);
chart.draw(view, options);
}
}
setInterval(updateData, 1000);
$(document).on('click', function() {
updateData();
});
}