"use strict";

import {
  formatSensorThingsApiResponseForHeatMap,
  drawHeatMapHighcharts,
} from "./chartHeatmap.mjs";

/**
 * Draw a heatmap based on the selected options from a drop-down list.
 * Currently, this chart type only supports raw observations
 *
 * @param {Array} observationsComboNestedArr An array that contains non-computed (raw) observations and computed (temperature difference, dT) observations
 * @param {Object} extractedFormattedDatastreamProperties An object that contains array(s) of formatted Datastream properties
 * @returns {undefined} undefined
 */
export const drawHeatmapBasedOnSelectedOptions = function (
  observationsComboNestedArr,
  extractedFormattedDatastreamProperties
) {
  // Create formatted array of observations
  const formattedObservationsHeatMapNestedArr = observationsComboNestedArr.map(
    (observationsArr) =>
      formatSensorThingsApiResponseForHeatMap(observationsArr)
  );

  // Note: The resulting array is nested and is not suitable for heatmap,
  // extract the nested array
  const [formattedObservationsHeatMapArr] =
    formattedObservationsHeatMapNestedArr;

  drawHeatMapHighcharts(
    formattedObservationsHeatMapArr,
    extractedFormattedDatastreamProperties
  );
};
