JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://axibase.com/atsd/atsdClient.bundle.js"></script>
<div id="chart_div"></div>
JavaScript
google.charts.load('visualization', {
'packages': ['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var startTime = Date.now() - 24 * 3600 * 1000,
endTime = Date.now();
var postData = [{
startTime: startTime,
endTime: endTime,
entity: "nurswgvml007",
metric: "cpu_busy",
aggregate: {
types: ["AVG"],
period: {
count: 1,
unit: "HOUR"
}
}
}, {
startTime: startTime,
endTime: endTime,
entity: "nurswgvml007",
metric: "cpu_user",
aggregate: {
types: ["AVG"],
period: {
count: 1,
unit: "HOUR"
}
}
}, {
startTime: startTime,
endTime: endTime,
entity: "nurswgvml007",
metric: "cpu_system",
aggregate: {
types: ["AVG"],
period: {
count: 1,
unit: "HOUR"
}
}
}, {
startTime: startTime,
endTime: endTime,
entity: "nurswgvml007",
metric: "cpu_iowait",
aggregate: {
types: ["AVG"],
period: {
count: 1,
unit: "HOUR"
}
}
}];
var client = axibase.atsdClient("https://axibase.com");
client.series.queries(postData)
.then(function(response) {
return response.reduce(function(previousValue, currentValue, index, array) {
if (currentValue.metric == "cpu_user") {
previousValue["usr"] = currentValue.data;
} else if (currentValue.metric == "cpu_iowait") {
previousValue["io"] = currentValue.data;
} else if (currentValue.metric ==...