Commit afecef1a authored by Pithon Kabiro's avatar Pithon Kabiro
Browse files

Edit heatmap chart drawing function / Highcharts

parent 4012e285
No related merge requests found
Showing with 28 additions and 28 deletions
+28 -28
......@@ -19,16 +19,11 @@ const PARAM_FILTER2 =
"resultTime ge 2020-06-01T00:00:00.000Z and resultTime le 2021-01-01T00:00:00.000Z";
/**
* Draw a heatmap using Highcharts library
* @param {*} obsArray - Response from SensorThings API as array
* @returns {void}
*/
const drawHeatMapHC = function (obsArray) {
/**
* Format the response from SensorThings API to make it suitable for heatmap
* @param {*} obsArray - Response from SensorThings API as array
* @returns {Array}
*/
const formatSTAResponseForHeatMap = function () {
const formatSTAResponseForHeatMap = function (obsArray) {
const dataSTAFormatted = [];
obsArray.forEach((obs) => {
// Get the date/time string; first element in input array; remove trailing "Z"
......@@ -47,8 +42,14 @@ const drawHeatMapHC = function (obsArray) {
dataSTAFormatted.push([timestamp, hourOfDay, value]);
});
return dataSTAFormatted;
};
};
/**
* Draw a heatmap using Highcharts library
* @param {*} obsArray - Response from SensorThings API
* @returns {void}
*/
const drawHeatMapHC = function (obsArray) {
Highcharts.chart("chart-heatmap", {
chart: {
type: "heatmap",
......@@ -122,7 +123,7 @@ const drawHeatMapHC = function (obsArray) {
series: [
{
data: formatSTAResponseForHeatMap(),
data: formatSTAResponseForHeatMap(obsArray),
boostThreshold: 100,
borderWidth: 0,
nullColor: "#525252",
......@@ -200,6 +201,5 @@ followNextLink(
console.log(err);
})
.then((observationArr) => {
// drawHeatMapAC2(observationArr);
drawHeatMapHC(observationArr);
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment