JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="GPS" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="result"></div>
JavaScript
$(document).ready(function() {
var chartGPS = new Highcharts.Chart({
chart: {
renderTo: 'GPS',
type: 'line',
height: 250
},
title: {
text: 'Altitude'
},
xAxis: {
title: 'Arduino Time'
},
yAxis: {
title: {
text: 'Altitude'
}
},
series: [{
name: 'GPS',
data: [[2951, 0], [3545, 50], [4139, 102], [4732, 85], [5326, 73]]
}]
});
var lastUpdate = 0;
var theSeries = chartGPS.series[0].data;
$("#result").append("About to try finding the largest value of X... ");
// Loop to determine last updated timestamp
for (var i = 0, len = theSeries.length; i < len; i++) {
console.log(theSeries[i]);
if (theSeries[i].x > lastUpdate) {
lastUpdate = theSeries[i].x;
}
}
$("#result").append("DONE: ");
$("#result").append(lastUpdate);
$("#result").append("<br>");
});