dropDownListChartScatterPlot.mjs 1.35 KB
Newer Older
1
2
"use strict";

3
4
5
6
7
8
import {
  formatSensorThingsApiResponseForScatterPlot,
  drawScatterPlotHighcharts,
} from "./chartScatterPlot.mjs";

/**
9
10
 * Draw a scatter plot based on the selected options from a drop-down list.
 * Currently, this chart type only supports raw observations
11
12
13
14
15
 *
 * @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
 */
16
export const drawScatterPlotBasedOnSelectedOptions = function (
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  observationsComboNestedArr,
  extractedFormattedDatastreamProperties
) {
  // Extract values for x-axis and y-axis
  // x-axis values are first element of nested observations array
  const [obsXAxisArr] = observationsComboNestedArr.slice(0, 1);
  // y-axis values are rest of elements of nested observations array
  const obsYAxisNestedArr = observationsComboNestedArr.slice(1);

  // Create formatted array(s) of observations
  const formattedObservationsScatterPlotArr = obsYAxisNestedArr.map(
    (obsYAxisArr) =>
      formatSensorThingsApiResponseForScatterPlot(obsXAxisArr, obsYAxisArr)
  );

  drawScatterPlotHighcharts(
    formattedObservationsScatterPlotArr,
    extractedFormattedDatastreamProperties
  );
};