JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://axibase.com/atsd/atsdClient.bundle.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="staticPlotContainer" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
JavaScript
$(function() {
var startTime = Date.now() - 1 * 3600 * 1000,
endTime = Date.now();
var postData = [{
startTime: startTime,
endTime: endTime,
entity: "atsd",
metric: "jvm_memory_used",
timeFormat: "milliseconds",
tags: {
host: ["NURSWGVML007"]
},
type: "HISTORY",
aggregate: {
types: ["DETAIL", "AVG"],
period: {
count: 2,
unit: "MINUTE"
}
}
}];
var client = axibase.atsdClient("https://axibase.com");
client.series.queries(postData)
.then(function(response) {
return response.reduce(function(previousValue, currentValue, index, array) {
if (currentValue.aggregate.type === "DETAIL") {
previousValue["memoryUsedDetail"] = currentValue;
} else if (currentValue.aggregate.type === "AVG") {
previousValue["memoryUsedAvg"] = currentValue;
} else {
throw new Error("Unrecognised type found!");
}
return previousValue;
}, {});
})
.then(function(seriesMap) {
var memoryUsedDetail = seriesMap["memoryUsedDetail"],
memoryUsedAvg = seriesMap["memoryUsedAvg"];
$('#staticPlotContainer').highcharts({
chart: {
type: 'area'
},
title: {
text: 'JVM memory used'
},
xAxis: {
type:...