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

Edit heatmap chart drawing function / Highcharts

parent 4012e285
Showing with 28 additions and 28 deletions
+28 -28
...@@ -19,16 +19,11 @@ const PARAM_FILTER2 = ...@@ -19,16 +19,11 @@ const PARAM_FILTER2 =
"resultTime ge 2020-06-01T00:00:00.000Z and resultTime le 2021-01-01T00:00:00.000Z"; "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 * Format the response from SensorThings API to make it suitable for heatmap
* @param {*} obsArray - Response from SensorThings API as array
* @returns {Array} * @returns {Array}
*/ */
const formatSTAResponseForHeatMap = function () { const formatSTAResponseForHeatMap = function (obsArray) {
const dataSTAFormatted = []; const dataSTAFormatted = [];
obsArray.forEach((obs) => { obsArray.forEach((obs) => {
// Get the date/time string; first element in input array; remove trailing "Z" // Get the date/time string; first element in input array; remove trailing "Z"
...@@ -47,8 +42,14 @@ const drawHeatMapHC = function (obsArray) { ...@@ -47,8 +42,14 @@ const drawHeatMapHC = function (obsArray) {
dataSTAFormatted.push([timestamp, hourOfDay, value]); dataSTAFormatted.push([timestamp, hourOfDay, value]);
}); });
return dataSTAFormatted; return dataSTAFormatted;
}; };
/**
* Draw a heatmap using Highcharts library
* @param {*} obsArray - Response from SensorThings API
* @returns {void}
*/
const drawHeatMapHC = function (obsArray) {
Highcharts.chart("chart-heatmap", { Highcharts.chart("chart-heatmap", {
chart: { chart: {
type: "heatmap", type: "heatmap",
...@@ -122,7 +123,7 @@ const drawHeatMapHC = function (obsArray) { ...@@ -122,7 +123,7 @@ const drawHeatMapHC = function (obsArray) {
series: [ series: [
{ {
data: formatSTAResponseForHeatMap(), data: formatSTAResponseForHeatMap(obsArray),
boostThreshold: 100, boostThreshold: 100,
borderWidth: 0, borderWidth: 0,
nullColor: "#525252", nullColor: "#525252",
...@@ -200,6 +201,5 @@ followNextLink( ...@@ -200,6 +201,5 @@ followNextLink(
console.log(err); console.log(err);
}) })
.then((observationArr) => { .then((observationArr) => {
// drawHeatMapAC2(observationArr);
drawHeatMapHC(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