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
  • !23

Update logic for drop-down list

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Pithon Kabiro requested to merge wip_select-sensors-dropdown-list-8 into master 3 years ago
  • Overview 0
  • Commits 9
  • Pipelines 0
  • Changes 18

Refactor the logic for the drop-down lists into new module files

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

    assigned to @pithon.kabiro

  • Pithon Kabiro @pithon.kabiro merged 3 years ago

    merged

  • Pithon Kabiro @pithon.kabiro mentioned in commit 398cd5d8 3 years ago

    mentioned in commit 398cd5d8

  • 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
    f7b471cf
    9 commits, 3 years ago

18 files
+ 948
- 952

    Preferences

    File browser
    Compare changes
publ‎ic/js‎
src_m‎odules‎
aggregateH‎elpers.mjs‎ +32 -0
chartCo‎lumn.mjs‎ +4 -29
chartHea‎tmap.mjs‎ +1 -1
chartHel‎pers.mjs‎ +16 -0
chartL‎ine.mjs‎ +6 -33
chartScatt‎erPlot.mjs‎ +19 -21
dropDownListAggre‎gationAverage.mjs‎ +117 -0
dropDownListAggre‎gationMaximum.mjs‎ +117 -0
dropDownListAggre‎gationMinimum.mjs‎ +117 -0
dropDownListAgg‎regationSum.mjs‎ +117 -0
dropDownListC‎hartColumn.mjs‎ +159 -0
dropDownListCh‎artHeatmap.mjs‎ +34 -0
dropDownList‎ChartLine.mjs‎ +159 -0
dropDownListChar‎tScatterPlot.mjs‎ +35 -0
dropDownLis‎tHelpers.mjs‎ +3 -7
dropDownListP‎rocessing.mjs‎ +0 -849
fetchD‎ata.mjs‎ +1 -1
appCh‎art.js‎ +11 -11
public/js/src_modules/aggregateHelpers.mjs
+ 32
- 0
  • View file @ f7b471cf

  • Edit in single-file editor

  • Open in Web IDE


@@ -354,10 +354,42 @@ const extractUniqueCalendarMonthsFromCalendarDates = function (
@@ -354,10 +354,42 @@ const extractUniqueCalendarMonthsFromCalendarDates = function (
return [...uniqueCalendarMonths];
return [...uniqueCalendarMonths];
};
};
 
/**
 
* Format a computed aggregation result to make it suitable for a chart. Currently, only line and column charts are supported
 
* @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} aggregatedValuesArr An array of aggregated values
 
* @returns {Array} An array of formatted aggregation values suitable for use in a column chart
 
*/
 
const formatAggregationResultForChart = function (
 
calendarDatesMonthsStrArr,
 
aggregatedValuesArr
 
) {
 
if (!calendarDatesMonthsStrArr || !aggregatedValuesArr) return;
 
 
// Create an array of Unix timestamp strings
 
const timestampsArr = calendarDatesMonthsStrArr.map((calendarStr) =>
 
new Date(calendarStr).getTime()
 
);
 
 
// Combine timestamp and value pairs
 
// The timestamps array and values array have same lengths, use one for looping
 
if (timestampsArr.length !== aggregatedValuesArr.length) {
 
throw new Error(
 
"The timestamps array and aggregated values array have different lengths"
 
);
 
} else {
 
return timestampsArr.map((timestamp, i) => [
 
timestamp,
 
aggregatedValuesArr[i],
 
]);
 
}
 
};
 
export {
export {
extractObservationsWithinDatesInterval,
extractObservationsWithinDatesInterval,
extractObservationValuesWithinDatesInterval,
extractObservationValuesWithinDatesInterval,
extractObservationValuesWithinMonthInterval,
extractObservationValuesWithinMonthInterval,
extractUniqueCalendarDatesFromTimestamp,
extractUniqueCalendarDatesFromTimestamp,
extractUniqueCalendarMonthsFromCalendarDates,
extractUniqueCalendarMonthsFromCalendarDates,
 
formatAggregationResultForChart,
};
};
public/js/src_modules/chartColumn.mjs
+ 4
- 29
  • View file @ f7b471cf

  • Edit in single-file editor

  • Open in Web IDE


@@ -9,31 +9,6 @@ import {
@@ -9,31 +9,6 @@ import {
createTooltipDateString,
createTooltipDateString,
} from "./chartHelpers.mjs";
} from "./chartHelpers.mjs";
/**
* 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} aggregatedValuesArr An array of aggregated values
* @returns {Array} An array of formatted aggregation values suitable for use in a column chart
*/
const formatAggregationResultForColumnChart = function (
calendarDatesMonthsStrArr,
aggregatedValuesArr
) {
if (!calendarDatesMonthsStrArr || !aggregatedValuesArr) return;
// Create an array of Unix timestamp strings
const timestampsArr = calendarDatesMonthsStrArr.map((calendarStr) =>
new Date(calendarStr).getTime()
);
// Combine timestamp and value pairs
// The timestamps array and values array have same lengths, use one for looping
return timestampsArr.map((timestamp, i) => [
timestamp,
aggregatedValuesArr[i],
]);
};
/**
/**
* Creates an options object for each series drawn in a column chart
* Creates an options object for each series drawn in a column chart
* @param {Array} formattedAggregatedResultForColumnChart An array of formatted aggregated result array(s) from one or more datastreams
* @param {Array} formattedAggregatedResultForColumnChart An array of formatted aggregated result array(s) from one or more datastreams
@@ -96,12 +71,12 @@ const createYAxisTitleTextColumnChart = function (
@@ -96,12 +71,12 @@ const createYAxisTitleTextColumnChart = function (
/**
/**
* Draw a column chart using Highcharts library
* Draw a column chart using Highcharts library
* @param {Array} formattedAggResultArraysForColumnChart An array made up of formatted aggregated result array(s) suitable for use in a column chart
* @param {Array} formattedObsArraysForColumnChart An array made up of formatted observation array(s) suitable for use in a column chart. The observations may either be raw or aggregated
* @param {Object} extractedFormattedDatastreamProperties An object that contains arrays of formatted Datastream properties
* @param {Object} extractedFormattedDatastreamProperties An object that contains arrays of formatted Datastream properties
* @returns {undefined} undefined
* @returns {undefined} undefined
*/
*/
const drawColumnChartHighcharts = function (
const drawColumnChartHighcharts = function (
formattedAggResultArraysForColumnChart,
formattedObsArraysForColumnChart,
extractedFormattedDatastreamProperties
extractedFormattedDatastreamProperties
) {
) {
// Formatted datastream properties
// Formatted datastream properties
@@ -136,7 +111,7 @@ const drawColumnChartHighcharts = function (
@@ -136,7 +111,7 @@ const drawColumnChartHighcharts = function (
// Create the array of series options object(s)
// Create the array of series options object(s)
const seriesOptionsArr = createSeriesOptionsForColumnChart(
const seriesOptionsArr = createSeriesOptionsForColumnChart(
formattedAggResultArraysForColumnChart,
formattedObsArraysForColumnChart,
buildingIdsPhenomenonNamesArr
buildingIdsPhenomenonNamesArr
);
);
@@ -213,4 +188,4 @@ const drawColumnChartHighcharts = function (
@@ -213,4 +188,4 @@ const drawColumnChartHighcharts = function (
});
});
};
};
export { formatAggregationResultForColumnChart, drawColumnChartHighcharts };
export { drawColumnChartHighcharts };
public/js/src_modules/chartHeatmap.mjs
+ 1
- 1
  • View file @ f7b471cf

  • Edit in single-file editor

  • Open in Web IDE


@@ -57,7 +57,7 @@ const calculateMinMaxValuesForHeatmapColorAxis = function (
@@ -57,7 +57,7 @@ const calculateMinMaxValuesForHeatmapColorAxis = function (
/**
/**
* Draw a heatmap using Highcharts library
* Draw a heatmap using Highcharts library
* @param {Array} formattedObsArrayForHeatmap Response from SensorThings API formatted for use in a heatmap
* @param {Array} formattedObsArrayForHeatmap Response from SensorThings API formatted for use in a heatmap. Currently, only raw observations are supported, i.e. no aggregation
* @param {Object} extractedFormattedDatastreamProperties An object that contains arrays of formatted Datastream properties
* @param {Object} extractedFormattedDatastreamProperties An object that contains arrays of formatted Datastream properties
* @returns {undefined} undefined
* @returns {undefined} undefined
*/
*/
public/js/src_modules/chartHelpers.mjs
+ 16
- 0
  • View file @ f7b471cf

  • Edit in single-file editor

  • Open in Web IDE


@@ -177,6 +177,21 @@ const checkForAndDeleteUniqueObservationsFromLargerArray = function (
@@ -177,6 +177,21 @@ const checkForAndDeleteUniqueObservationsFromLargerArray = function (
}
}
};
};
 
/**
 
* Format the response from SensorThings API to make it suitable for use in a line chart or column chart
 
* @param {Array} obsArray Array of observations (timestamp + value) that is response from SensorThings API
 
* @returns {Array} Array of formatted observations suitable for use in a line chart
 
*/
 
const formatSensorThingsApiResponseForLineOrColumnChart = function (obsArray) {
 
if (!obsArray) return;
 
 
return obsArray.map((result) => {
 
const timestampObs = new Date(result[0].slice(0, -1)).getTime(); // slice() removes trailing "Z" character in timestamp
 
const valueObs = result[1];
 
return [timestampObs, valueObs];
 
});
 
};
 
/**
/**
* Convert a hexadecimal color code obtained from the Highcharts object (`Highcharts.getOptions().colors`) to its equivalent RGB color code
* Convert a hexadecimal color code obtained from the Highcharts object (`Highcharts.getOptions().colors`) to its equivalent RGB color code
* @param {String} hexCode Input hex color code
* @param {String} hexCode Input hex color code
@@ -406,6 +421,7 @@ const removeTransparencyFromColor = function (rgbaColor) {
@@ -406,6 +421,7 @@ const removeTransparencyFromColor = function (rgbaColor) {
export {
export {
chartExportOptions,
chartExportOptions,
checkForAndDeleteUniqueObservationsFromLargerArray,
checkForAndDeleteUniqueObservationsFromLargerArray,
 
formatSensorThingsApiResponseForLineOrColumnChart,
createCombinedTextDelimitedByAmpersand,
createCombinedTextDelimitedByAmpersand,
createCombinedTextDelimitedByComma,
createCombinedTextDelimitedByComma,
extractSamplingRateFromDatastreamName,
extractSamplingRateFromDatastreamName,
public/js/src_modules/chartLine.mjs
+ 6
- 33
  • View file @ f7b471cf

  • Edit in single-file editor

  • Open in Web IDE


@@ -7,30 +7,6 @@ import {
@@ -7,30 +7,6 @@ import {
createTooltipDateString,
createTooltipDateString,
} from "./chartHelpers.mjs";
} from "./chartHelpers.mjs";
/**
* Format the response from SensorThings API to make it suitable for use in a line chart or column chart
* @param {Array} obsArray Array of observations (timestamp + value) that is response from SensorThings API
* @returns {Array} Array of formatted observations suitable for use in a line chart
*/
const formatSensorThingsApiResponseForLineOrColumnChart = function (obsArray) {
if (!obsArray) return;
return obsArray.map((result) => {
const timestampObs = new Date(result[0].slice(0, -1)).getTime(); // slice() removes trailing "Z" character in timestamp
const valueObs = result[1];
return [timestampObs, valueObs];
});
};
/**
* Concatenates metadata properties to create a string for either the title or subtitle of a line chart
* @param {Array} phenomenonNamesArr An array of phenomenon name strings
* @returns {String} A string made up of combined phenomenon names
*/
const createCombinedTextForLineChartTitles = function (phenomenonNamesArr) {
return phenomenonNamesArr.join(", ");
};
/**
/**
* Creates an options object for each series drawn in the line chart
* Creates an options object for each series drawn in the line chart
* @param {Array} formattedObsArraysForLineChart An array of formatted observation array(s) from one or more datastreams
* @param {Array} formattedObsArraysForLineChart An array of formatted observation array(s) from one or more datastreams
@@ -42,10 +18,10 @@ const createSeriesOptionsForLineChart = function (
@@ -42,10 +18,10 @@ const createSeriesOptionsForLineChart = function (
buildingIdsPhenomenonNamesArr
buildingIdsPhenomenonNamesArr
) {
) {
// An array of colors, in hexadecimal format, provided by the global Highcharts object
// An array of colors, in hexadecimal format, provided by the global Highcharts object
const seriesColors = Highcharts.getOptions().colors;
const seriesColorsArr = Highcharts.getOptions().colors;
// Create a copy of the colors array
// Create a local copy of the colors array
const seriesColorsArr = [...seriesColors];
const seriesColorsForLineChartArr = [...seriesColorsArr];
// Create an array of seriesOptions objects
// Create an array of seriesOptions objects
// Assumes that the observation array of arrays and building IDs + phenomenon names array are of equal length
// Assumes that the observation array of arrays and building IDs + phenomenon names array are of equal length
@@ -62,7 +38,7 @@ const createSeriesOptionsForLineChart = function (
@@ -62,7 +38,7 @@ const createSeriesOptionsForLineChart = function (
return {
return {
name: `${buildingIdsPhenomenonNamesArr[i]}`,
name: `${buildingIdsPhenomenonNamesArr[i]}`,
data: formattedObsArray,
data: formattedObsArray,
color: seriesColorsArr[i],
color: seriesColorsForLineChartArr[i],
turboThreshold: Number.MAX_VALUE, // #3404, remove after 4.0.5 release
turboThreshold: Number.MAX_VALUE, // #3404, remove after 4.0.5 release
};
};
});
});
@@ -71,7 +47,7 @@ const createSeriesOptionsForLineChart = function (
@@ -71,7 +47,7 @@ const createSeriesOptionsForLineChart = function (
/**
/**
* Draw a line chart using Highcharts library
* Draw a line chart using Highcharts library
* @param {Array} formattedObsArraysForLineChart An array made up of formatted observation array(s) suitable for use in a line chart
* @param {Array} formattedObsArraysForLineChart An array made up of formatted observation array(s) suitable for use in a line chart. The observations may either be raw or aggregated
* @param {Object} extractedFormattedDatastreamPropertiesArr An object that contains arrays of formatted Datastream properties
* @param {Object} extractedFormattedDatastreamPropertiesArr An object that contains arrays of formatted Datastream properties
* @returns {undefined} undefined
* @returns {undefined} undefined
*/
*/
@@ -171,7 +147,4 @@ const drawLineChartHighcharts = function (
@@ -171,7 +147,4 @@ const drawLineChartHighcharts = function (
});
});
};
};
export {
export { drawLineChartHighcharts };
formatSensorThingsApiResponseForLineOrColumnChart,
drawLineChartHighcharts,
};
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!23
Source branch: wip_select-sensors-dropdown-list-8

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