Spaces:
Paused
Paused
File size: 2,607 Bytes
441a894 0996523 441a894 0996523 441a894 0996523 441a894 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | $(function () {
var mychart;
var previous = null;
var count = 0;
$(window).load(function () {
initiateChart("container");
parseFile();
});
function parseFile() {
// actually skidded from vshield, gonna recode it
$.ajax({
url: "/nginx_status",
dataType: "text",
cache: false,
})
.done(function (data) {
var current = 0;
var part = data.split(" ")[9];
var series = mychart.series[0],
current = parseInt(part);
shift = series.data.length > 40;
if (previous !== null) {
series.addPoint(
[Math.floor($.now()), current - previous],
true,
shift
);
}
previous = current;
count++;
// call it again after one second
setTimeout(parseFile, 1000);
})
.fail(function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
});
}
function initiateChart(divid) {
mychart = Highcharts.chart("container", {
chart: {
type: "area",
backgroundColor: "#242222",
},
title: {
text: "@renzalwaysnt",
},
xAxis: {
type: "datetime",
dateTimeLabelFormats: {
day: "%a",
},
gridLineColor: "#7851a9",
labels: {
style: {
color: "#7851a9",
},
},
},
yAxis: {
allowDecimals: false,
labels: {
formatter: function () {
if (this.value > 1000) {
return this.value / 1000 + "k r/s";
} else {
return this.value + " r/s";
}
},
},
},
tooltip: {
pointFormat: "Requests: {point.y:,.0f}",
},
colors: [
{ linearGradient: [0, 0, 0, 0], stops: [[0, "rgba(120,81,169,1)"]] },
],
plotOptions: {
area: {
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1,
},
stops: [
[0, "#7851a9"],
[1, new Highcharts.Color("#7851a9").setOpacity(0).get("rgba")],
],
},
pointStart: 1940,
marker: {
enabled: true,
symbol: "circle",
radius: 2,
states: {
hover: {
enabled: true,
},
},
},
},
},
series: [
{
name: "Requests",
data: [],
},
],
});
}
});
|