Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • E EnergyDashboard
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • iCity
  • EnergyDashboard
  • Merge requests
  • !8

Add functionality to calculate average of observations

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Pithon Kabiro requested to merge wip_aggregate-3 into master 3 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 14

Add logic for calculating the average (arithmetic mean) of observations

  • Pithon Kabiro @pithon.kabiro assigned to @pithon.kabiro 3 years ago

    assigned to @pithon.kabiro

  • Pithon Kabiro @pithon.kabiro mentioned in commit 4ae783c2 3 years ago

    mentioned in commit 4ae783c2

  • Pithon Kabiro @pithon.kabiro merged 3 years ago

    merged

  • Loading
  • Loading
  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
Compare
  • master (base)

and
  • latest version
    8df4c888
    1 commit, 3 years ago

14 files
+ 930
- 261

    Preferences

    File browser
    Compare changes
publ‎ic/js‎
src_m‎odules‎
aggreg‎ate.mjs‎ +420 -0
baseUrlPlusQu‎eryParams.mjs‎ +0 -0
calculateTempe‎ratureDiff.mjs‎ +106 -0
chartCo‎lumn.mjs‎ +6 -0
chartEx‎port.mjs‎ +9 -0
chartHea‎tmap.mjs‎ +24 -9
chartL‎ine.mjs‎ +24 -8
chartScatt‎erPlot.mjs‎ +16 -4
fetchD‎ata.mjs‎ +2 -194
getDatast‎reamId.mjs‎ +95 -0
loadingInd‎icator.mjs‎ +0 -0
appCh‎art.js‎ +215 -37
dropDow‎nList.js‎ +12 -9
index‎.html‎ +1 -0
public/js/src_modules/aggregate.js → public/js/src_modules/aggregate.mjs
+ 420
- 0
  • View file @ 8df4c888

  • Edit in single-file editor

  • Open in Web IDE


@@ -2,12 +2,12 @@
@@ -2,12 +2,12 @@
/**
/**
* Create 24-hour time strings for a time interval delimited by a start time and an end time. It is assumed that the start time is at "00:00:00" and the end time is at "23:45:00" (when the sampling rate of observations is 15 min) or "23:00:00" (when the sampling rate of observations is 60 min)
* Create 24-hour time strings for a time interval delimited by a start time and an end time. It is assumed that the start time is at "00:00:00" and the end time is at "23:45:00" (when the sampling rate of observations is 15 min) or "23:00:00" (when the sampling rate of observations is 60 min)
* @param {String} phenomenonSamplingRate The sampling rate of the phenomenon of interest represented as a string, e.g. "15 min", "60 min"
* @param {String} phenomenonSamplingRate The sampling rate of the phenomenon of interest represented as a string, e.g. "15min", "60min"
* @returns {Array} An array of two 24-hour strings representing the start time and end time
* @returns {Array} An array of two 24-hour strings representing the start time and end time
*/
*/
const createTimeStringsForInterval = function (phenomenonSamplingRate) {
const createTimeStringsForInterval = function (phenomenonSamplingRate) {
const fifteenMinutes = "15 min";
const fifteenMinutes = "15min";
const sixtyMinutes = "60 min";
const sixtyMinutes = "60min";
const startTime = "00:00:00";
const startTime = "00:00:00";
const endTimeFifteenMinutes = "23:45:00";
const endTimeFifteenMinutes = "23:45:00";
@@ -17,7 +17,9 @@ const createTimeStringsForInterval = function (phenomenonSamplingRate) {
@@ -17,7 +17,9 @@ const createTimeStringsForInterval = function (phenomenonSamplingRate) {
phenomenonSamplingRate !== fifteenMinutes &&
phenomenonSamplingRate !== fifteenMinutes &&
phenomenonSamplingRate !== sixtyMinutes
phenomenonSamplingRate !== sixtyMinutes
)
)
return;
throw new Error(
 
`Check that the provided phenomenon sampling rate string is in this format: "15min" or "60min"`
 
);
// 15 min sampling rate
// 15 min sampling rate
if (phenomenonSamplingRate === fifteenMinutes) {
if (phenomenonSamplingRate === fifteenMinutes) {
@@ -49,7 +51,7 @@ const createIso8601DateTimeString = function (
@@ -49,7 +51,7 @@ const createIso8601DateTimeString = function (
* @returns {Boolean} true if leap year, false if not
* @returns {Boolean} true if leap year, false if not
*/
*/
const checkIfLeapYear = function (year) {
const checkIfLeapYear = function (year) {
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
};
};
/**
/**
@@ -74,28 +76,22 @@ const getIndexOfTimestamp = function (inputTimestampArr, timestampOfInterest) {
@@ -74,28 +76,22 @@ const getIndexOfTimestamp = function (inputTimestampArr, timestampOfInterest) {
};
};
/**
/**
* Calculate the sum of observation values within a time interval delimited by a start date and end date. The start date may be the same as the end date.
* Calculate the indexes of the start and end timestamps
* @param {Array} obsArray An array of observations (timestamp + value) that is response from SensorThings API
* @param {Array} obsTimestampArr An array of observations timestamps
* @param {String} samplingRate The sampling rate of observations as a string, e.g. "15 min", "60 min"
* @param {String} samplingRate The sampling rate of observations as a string, e.g. "15min", "60min"
* @param {String} startDate A 24-hour date string representing the start date
* @param {String} startDate A 24-hour date string representing the start date
* @param {String} endDate A 24-hour date string representing the end date
* @param {String} endDate A 24-hour date string representing the end date
* @returns {Number} A floating-point number representing the sum of observation values
* @returns {Array} A 1*2 array tht contains integers representing the start index and end index respectively
*/
*/
const calculateSumOfObservationValuesWithinDatesInterval = function (
const calculateIndexStartEndTimestamp = function (
obsArray,
obsTimestampArr,
samplingRate,
samplingRate,
startDate,
startDate,
endDate
endDate
) {
) {
// Extract the timestamps and values from the observations
// Create and extract 24-hour strings for the start and end of interval
const obsTimestampArr = obsArray.map((obs) => obs[0]);
const [startTimeString, endTimeString] =
const obsValuesArr = obsArray.map((obs) => obs[1]);
createTimeStringsForInterval(samplingRate);
// Create array of 24-hour strings for the start and end of interval
const startPlusEndTimeStrings = createTimeStringsForInterval(samplingRate);
// Extract 24-hour strings for the start and end of interval
const [startTimeString, endTimeString] = startPlusEndTimeStrings;
// Create ISO 8601 strings for the start and end of interval
// Create ISO 8601 strings for the start and end of interval
const startIso8601DateTimeString = createIso8601DateTimeString(
const startIso8601DateTimeString = createIso8601DateTimeString(
@@ -117,27 +113,74 @@ const calculateSumOfObservationValuesWithinDatesInterval = function (
@@ -117,27 +113,74 @@ const calculateSumOfObservationValuesWithinDatesInterval = function (
endIso8601DateTimeString
endIso8601DateTimeString
);
);
 
return [indexStartTimestamp, indexEndTimestamp];
 
};
 
 
/**
 
* Extract the set of observation values that fall within a time interval delimited by a start date and end date. The start date may be the same as the end date.
 
* @param {Array} obsArray An array of observations (timestamp + value) that is response from SensorThings API
 
* @param {String} samplingRate The sampling rate of observations as a string, e.g. "15min", "60min"
 
* @param {String} startDate A 24-hour date string representing the start date
 
* @param {String} endDate A 24-hour date string representing the end date
 
* @returns {Array} An array of observation values that fall within our time interval
 
*/
 
const extractObservationValuesWithinDatesInterval = function (
 
obsArray,
 
samplingRate,
 
startDate,
 
endDate
 
) {
 
// Extract the timestamps and values from the observations
 
const obsTimestampArr = obsArray.map((obs) => obs[0]);
 
const obsValuesArr = obsArray.map((obs) => obs[1]);
 
 
// Calculate the indexes of the timestamps for the start and end of interval
 
const [indexStartTimestamp, indexEndTimestamp] =
 
calculateIndexStartEndTimestamp(
 
obsTimestampArr,
 
samplingRate,
 
startDate,
 
endDate
 
);
 
// Extract the observations that fall within our time interval
// Extract the observations that fall within our time interval
const obsValuesForTimeIntervalArr = obsValuesArr.slice(
return obsValuesArr.slice(indexStartTimestamp, indexEndTimestamp + 1);
indexStartTimestamp,
};
indexEndTimestamp + 1
);
return obsValuesForTimeIntervalArr.reduce(
/**
 
* Calculate the sum of observation values that fall within a time interval delimited by a start date and end date
 
* @param {Array} obsValuesForDaysIntervalArr An array of observation values that fall within our time interval
 
* @returns {Number} A floating-point number representing the sum of observation values
 
*/
 
const calculateSumOfObservationValuesWithinDatesInterval = function (
 
obsValuesForDaysIntervalArr
 
) {
 
return obsValuesForDaysIntervalArr.reduce(
(accumulator, currentValue) => accumulator + currentValue
(accumulator, currentValue) => accumulator + currentValue
);
);
};
};
/**
/**
* Calculate the sum of observation values within a time interval delimited by the start date and end date of a calendar month
* Calculate the average (arithmetic mean) of observation values that fall within a time interval delimited by a start date and end date
* @param {Array} obsArray An array of observations (timestamp + value) that is response from SensorThings API
* @param {Array} obsValuesForDaysIntervalArr An array of observation values that fall within our time interval
* @param {String} samplingRate The sampling rate of observations as a string, e.g. "15 min", "60 min"
* @returns {Number} A floating-point number representing the average (arithmetic mean) of observation values
 
*/
 
const calculateAverageOfObservationValuesWithinDatesInterval = function (
 
obsValuesForDaysIntervalArr
 
) {
 
return (
 
calculateSumOfObservationValuesWithinDatesInterval(
 
obsValuesForDaysIntervalArr
 
) / obsValuesForDaysIntervalArr.length
 
);
 
};
 
 
/**
 
* Extract the year and month digits from a calendar month string
* @param {String} calendarMonthStr Calendar month string in "YYYY-MM" format
* @param {String} calendarMonthStr Calendar month string in "YYYY-MM" format
* @returns {Number} A floating-point number representing the sum of observation values
* @returns {Array} A 1*2 array tht contains integers representing the year and month respectively
*/
*/
const calculateSumOfObservationValuesWithinMonthInterval = function (
const extractMonthYearDigitsFromCalendarMonthString = function (
obsArray,
samplingRate,
calendarMonthStr
calendarMonthStr
) {
) {
// Extract year as integer
// Extract year as integer
@@ -146,6 +189,25 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
@@ -146,6 +189,25 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
// Extract month as integer
// Extract month as integer
const monthNum = parseInt(calendarMonthStr.slice(-2), 10);
const monthNum = parseInt(calendarMonthStr.slice(-2), 10);
 
return [yearNum, monthNum];
 
};
 
 
/**
 
* Extract the set of observation values that fall within a time interval delimited by the first day and last day of a calendar month
 
* @param {Array} obsArray An array of observations (timestamp + value) that is response from SensorThings API
 
* @param {String} samplingRate The sampling rate of observations as a string, e.g. "15min", "60min"
 
* @param {String} calendarMonthStr Calendar month string in "YYYY-MM" format
 
* @returns {Array} An array of observation values that fall within one calendar month
 
*/
 
const extractObservationValuesWithinMonthInterval = function (
 
obsArray,
 
samplingRate,
 
calendarMonthStr
 
) {
 
// Extract the year and month digits from the calendar month string
 
const [yearNum, monthNum] =
 
extractMonthYearDigitsFromCalendarMonthString(calendarMonthStr);
 
if (monthNum < 1 || monthNum > 12) return;
if (monthNum < 1 || monthNum > 12) return;
// All the months start on the first
// All the months start on the first
@@ -155,7 +217,7 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
@@ -155,7 +217,7 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
if (monthNum === 2) {
if (monthNum === 2) {
// Leap year
// Leap year
if (checkIfLeapYear(yearNum))
if (checkIfLeapYear(yearNum))
return calculateSumOfObservationValuesWithinDatesInterval(
return extractObservationValuesWithinDatesInterval(
obsArray,
obsArray,
samplingRate,
samplingRate,
startDateStr,
startDateStr,
@@ -163,7 +225,7 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
@@ -163,7 +225,7 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
);
);
// Non-leap year
// Non-leap year
return calculateSumOfObservationValuesWithinDatesInterval(
return extractObservationValuesWithinDatesInterval(
obsArray,
obsArray,
samplingRate,
samplingRate,
startDateStr,
startDateStr,
@@ -173,7 +235,7 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
@@ -173,7 +235,7 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
// Months with 30 days
// Months with 30 days
if (monthNum === 4 || monthNum === 6 || monthNum === 9 || monthNum === 11)
if (monthNum === 4 || monthNum === 6 || monthNum === 9 || monthNum === 11)
return calculateSumOfObservationValuesWithinDatesInterval(
return extractObservationValuesWithinDatesInterval(
obsArray,
obsArray,
samplingRate,
samplingRate,
startDateStr,
startDateStr,
@@ -181,7 +243,7 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
@@ -181,7 +243,7 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
);
);
// Months with 31 days
// Months with 31 days
return calculateSumOfObservationValuesWithinDatesInterval(
return extractObservationValuesWithinDatesInterval(
obsArray,
obsArray,
samplingRate,
samplingRate,
startDateStr,
startDateStr,
@@ -189,6 +251,130 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
@@ -189,6 +251,130 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
);
);
};
};
 
/**
 
* Calculate the sum of observation values that fall within a time interval delimited by the first day and last day of a calendar month
 
* @param {Array} obsValuesForMonthIntervalArr An array of observation values that fall within one calendar month
 
* @returns {Number} A floating-point number representing the sum of observation values within one calendar month
 
*/
 
const calculateSumOfObservationValuesWithinMonthInterval = function (
 
obsValuesForMonthIntervalArr
 
) {
 
return obsValuesForMonthIntervalArr.reduce(
 
(accumulator, currentValue) => accumulator + currentValue
 
);
 
};
 
 
/**
 
* Calculate the average (arithmetic mean) of observation values that fall within a time interval delimited by the first day and last day of a calendar month
 
* @param {Array} obsValuesForMonthIntervalArr An array of observation values that fall within one calendar month
 
* @returns {Number} A floating-point number representing the average (arithmetic mean) of observation values within one calendar month
 
*/
 
const calculateAverageOfObservationValuesWithinMonthInterval = function (
 
obsValuesForMonthIntervalArr
 
) {
 
return (
 
calculateSumOfObservationValuesWithinMonthInterval(
 
obsValuesForMonthIntervalArr
 
) / obsValuesForMonthIntervalArr.length
 
);
 
};
 
 
/**
 
* Calculate the sum of observation values within a time interval delimited by a start date and end date. The time interval may be daily or monthly
 
* @param {Array} obsNestedArr A 1*N array that contains N nested arrays of observations (timestamp + value)
 
* @param {String} samplingRate The sampling rate of observations as a string, e.g. "15min", "60min"
 
* @param {Array} uniqueCalendarDatesOrMonthsArr A 1*N array of unique calendar dates or calendar months strings
 
* @param {String} aggregationInterval The aggregation interval as a string e.g. "daily", "monthly"
 
* @returns {Array} A 1*N array that contains N nested arrays of sum values
 
*/
 
const calculateSumOfObservationValuesWithinInterval = function (
 
obsNestedArr,
 
samplingRate,
 
uniqueCalendarDatesOrMonthsArr,
 
aggregationInterval
 
) {
 
// Calculate sum of values of observations - daily
 
// Note the use of the two nested `map` methods
 
if (aggregationInterval === "daily") {
 
return uniqueCalendarDatesOrMonthsArr.map((uniqueCalendarDatesArr, i) =>
 
uniqueCalendarDatesArr.map((uniqueCalendarDate) =>
 
calculateSumOfObservationValuesWithinDatesInterval(
 
extractObservationValuesWithinDatesInterval(
 
obsNestedArr[i],
 
samplingRate,
 
uniqueCalendarDate,
 
uniqueCalendarDate
 
)
 
)
 
)
 
);
 
}
 
 
// Calculate sum of values of observations - monthly
 
// Note the use of the two nested `map` methods
 
if (aggregationInterval === "monthly") {
 
return uniqueCalendarDatesOrMonthsArr.map((uniqueCalendarMonthsArr, i) =>
 
uniqueCalendarMonthsArr.map((uniqueCalendarMonth) =>
 
calculateSumOfObservationValuesWithinMonthInterval(
 
extractObservationValuesWithinMonthInterval(
 
obsNestedArr[i],
 
samplingRate,
 
uniqueCalendarMonth
 
)
 
)
 
)
 
);
 
}
 
};
 
 
/**
 
* Calculate the average (arithmetic mean) of observation values within a time interval delimited by a start date and end date. The time interval may be daily or monthly
 
* @param {Array} obsNestedArr A 1*N array that contains N nested arrays of observations (timestamp + value)
 
* @param {String} samplingRate The sampling rate of observations as a string, e.g. "15min", "60min"
 
* @param {Array} uniqueCalendarDatesOrMonthsArr A 1*N array of unique calendar dates or calendar months strings
 
* @param {String} aggregationInterval The aggregation interval as a string e.g. "daily", "monthly"
 
* @returns {Array} A 1*N array that contains N nested arrays of average (arithmetic mean) values
 
*/
 
const calculateAverageOfObservationValuesWithinInterval = function (
 
obsNestedArr,
 
samplingRate,
 
uniqueCalendarDatesOrMonthsArr,
 
aggregationInterval
 
) {
 
// Calculate average of values of observations - daily
 
// Note the use of the two nested `map` methods
 
if (aggregationInterval === "daily") {
 
return uniqueCalendarDatesOrMonthsArr.map((uniqueCalendarDatesArr, i) =>
 
uniqueCalendarDatesArr.map((uniqueCalendarDate) =>
 
calculateAverageOfObservationValuesWithinDatesInterval(
 
extractObservationValuesWithinDatesInterval(
 
obsNestedArr[i],
 
samplingRate,
 
uniqueCalendarDate,
 
uniqueCalendarDate
 
)
 
)
 
)
 
);
 
}
 
 
// Calculate average of values of observations - monthly
 
// Note the use of the two nested `map` methods
 
if (aggregationInterval === "monthly") {
 
return uniqueCalendarDatesOrMonthsArr.map((uniqueCalendarMonthsArr, i) =>
 
uniqueCalendarMonthsArr.map((uniqueCalendarMonth) =>
 
calculateAverageOfObservationValuesWithinMonthInterval(
 
extractObservationValuesWithinMonthInterval(
 
obsNestedArr[i],
 
samplingRate,
 
uniqueCalendarMonth
 
)
 
)
 
)
 
);
 
}
 
};
 
/**
/**
* Extract unique calendar dates from date/time strings in ISO 8601 format
* Extract unique calendar dates from date/time strings in ISO 8601 format
* @param {Array} obsArray An array of observations (timestamp + value) that is response from SensorThings API
* @param {Array} obsArray An array of observations (timestamp + value) that is response from SensorThings API
@@ -227,8 +413,8 @@ const extractUniqueCalendarMonthsFromCalendarDates = function (
@@ -227,8 +413,8 @@ const extractUniqueCalendarMonthsFromCalendarDates = function (
};
};
export {
export {
calculateSumOfObservationValuesWithinDatesInterval,
calculateSumOfObservationValuesWithinInterval,
calculateSumOfObservationValuesWithinMonthInterval,
extractUniqueCalendarDatesFromTimestamp,
extractUniqueCalendarDatesFromTimestamp,
extractUniqueCalendarMonthsFromCalendarDates,
extractUniqueCalendarMonthsFromCalendarDates,
 
calculateAverageOfObservationValuesWithinInterval,
};
};
public/js/src_modules/createUrl.js → public/js/src_modules/baseUrlPlusQueryParams.mjs
+ 0
- 0
  • View file @ 8df4c888

  • Edit in single-file editor

  • Open in Web IDE

Unable to load file contents. Try again later.
File renamed with no changes. Show file contents
public/js/src_modules/calculateTemperatureDiff.mjs 0 → 100644
+ 106
- 0
  • View file @ 8df4c888

  • Edit in single-file editor

  • Open in Web IDE

 
"use strict";
 
 
import {
 
extractPhenomenonNameFromDatastreamName,
 
getMetadataPlusObservationsFromSingleOrMultipleDatastreams,
 
} from "./fetchData.mjs";
 
 
/**
 
* Calculate the temperature difference, dT, between Vorlauf temperature [VL] and Rücklauf temperature [RL] (i.e., dT = VL - RL)
 
* @param {String} baseUrl Base URL of the STA server
 
* @param {Object} urlParams The URL parameters to be sent together with the GET request
 
* @param {String} buildingId The building ID as a string
 
* @param {String} samplingRate The sampling rate as a string
 
* @returns {Promise} A promise that contains an array (that is made up of a temperature difference array and a metadata object) when fulfilled
 
*/
 
export const calculateVorlaufMinusRuecklaufTemperature = async function (
 
baseUrl,
 
urlParams,
 
buildingId,
 
samplingRate
 
) {
 
try {
 
const bldgSensorSamplingRateNestedArr = [
 
[buildingId, "vl", samplingRate],
 
[buildingId, "rl", samplingRate],
 
];
 
 
const BUILDING_ID = buildingId;
 
const SAMPLING_RATE = samplingRate;
 
 
const observationsPlusMetadata =
 
await getMetadataPlusObservationsFromSingleOrMultipleDatastreams(
 
baseUrl,
 
urlParams,
 
bldgSensorSamplingRateNestedArr
 
);
 
 
// Extract Vorlauf temperature, Ruecklauf temperature and metadata
 
const [
 
[vorlaufTemperatureObsArr, ruecklaufTemperatureObsArr],
 
[metadataVorlauf, metadataRuecklauf],
 
] = observationsPlusMetadata;
 
 
// Extract the temperature values
 
const vorlaufTemperatureValues = vorlaufTemperatureObsArr.map(
 
(vlTempObs) => vlTempObs[1]
 
);
 
const ruecklaufTemperatureValues = ruecklaufTemperatureObsArr.map(
 
(rlTempObs) => rlTempObs[1]
 
);
 
 
// The arrays have equal length, we need only use one of them for looping
 
// Resulting array contains the following pairs (timestamp + dT)
 
const vorlaufMinusRuecklaufTemperatureObs = vorlaufTemperatureObsArr.map(
 
(vlTempObs, i) => [
 
vlTempObs[0], // timestamp
 
vorlaufTemperatureValues[i] - ruecklaufTemperatureValues[i],
 
]
 
);
 
 
// From Vorlauf metadata, extract `name` and `unitOfMeasurement`
 
const {
 
name: datastreamNameVorlauf,
 
unitOfMeasurement: unitOfMeasurementVorlauf,
 
} = metadataVorlauf;
 
 
// From Ruecklauf metadata, extract `name`
 
const { name: datastreamNameRuecklauf } = metadataRuecklauf;
 
 
// Extract the phenomenon names from the Datastream names
 
const phenomenonNameVorlauf = extractPhenomenonNameFromDatastreamName(
 
datastreamNameVorlauf
 
);
 
const phenomenonNameRuecklauf = extractPhenomenonNameFromDatastreamName(
 
datastreamNameRuecklauf
 
);
 
 
// Create our custom datastream description text
 
// The resulting datastream description string has two `temperature` substrings;
 
// replace the first occurence with an empty string
 
const descriptionTempDifference =
 
`Computed dT: ${phenomenonNameVorlauf} minus ${phenomenonNameRuecklauf}`.replace(
 
"temperature",
 
""
 
);
 
 
// Create our custom datastream name text
 
const nameTempDifference = `BOSCH_${BUILDING_ID} / dT Temperature difference (VL-RL) DS:${SAMPLING_RATE}`;
 
 
// The datastream object that we return needs to have these property names
 
const description = descriptionTempDifference;
 
const name = nameTempDifference;
 
const unitOfMeasurement = unitOfMeasurementVorlauf;
 
 
return [
 
vorlaufMinusRuecklaufTemperatureObs,
 
{
 
description,
 
name,
 
unitOfMeasurement,
 
},
 
];
 
} catch (err) {
 
console.error(err);
 
}
 
};
public/js/src_modules/chartColumn.js → public/js/src_modules/chartColumn.mjs
+ 6
- 0
  • View file @ 8df4c888

  • Edit in single-file editor

  • Open in Web IDE


 
"use strict";
 
 
import { chartExportOptions } from "./chartExport.mjs";
 
/**
/**
* Format a computed aggregation result to make it suitable for a column chart
* Format a computed aggregation result to make it suitable for a column chart
* @param {Array} calendarDatesMonthsStrArr An array of unique calendar dates strings (in "YYYY-MM-DD" fromat) or unique calendar months strings (in "YYYY-MM" format)
* @param {Array} calendarDatesMonthsStrArr An array of unique calendar dates strings (in "YYYY-MM-DD" fromat) or unique calendar months strings (in "YYYY-MM" format)
@@ -123,6 +127,8 @@ const drawColumnChartHighcharts = function (
@@ -123,6 +127,8 @@ const drawColumnChartHighcharts = function (
},
},
},
},
 
exporting: chartExportOptions,
 
series: seriesOptionsArr,
series: seriesOptionsArr,
});
});
};
};
public/js/src_modules/chartExport.mjs 0 → 100644
+ 9
- 0
  • View file @ 8df4c888

  • Edit in single-file editor

  • Open in Web IDE

 
"use strict";
 
 
export const chartExportOptions = {
 
buttons: {
 
contextButton: {
 
menuItems: ["downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG"],
 
},
 
},
 
};
Assignee
Pithon Kabiro's avatar
Pithon Kabiro
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Pithon Kabiro
Reference: icity/energydashboard!8
Source branch: wip_aggregate-3

Menu

Explore Projects Groups Snippets

Dies ist die Gitlab-Instanz des Transferportals der Hochschule für Technik Stuttgart. Hier geht es zurück zum Portal