Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
iCity
EnergyDashboard
Commits
91b9dc0d
Commit
91b9dc0d
authored
Jul 19, 2021
by
Pithon Kabiro
Browse files
Edit function: chart type selection callback
parent
6db57cbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/js/dropDownList.js
View file @
91b9dc0d
...
...
@@ -173,6 +173,13 @@ const getSelectedOptionsFromDropDownLists = function () {
"
#drop-down--sampling-rate
"
).
value
;
if
(
selectedBuilding
===
"
--Select--
"
||
selectedSensor
===
""
||
selectedSamplingRate
===
""
)
return
;
return
[
selectedBuilding
,
selectedSensor
,
selectedSamplingRate
];
};
...
...
@@ -223,10 +230,12 @@ const getBuildingSensorSamplingRateAbbreviation = function (
return
[
buildingAbbrev
,
phenomenonAbbrev
,
samplingRateAbbrev
];
};
const
runFromOptionThree
=
async
function
()
{
const
selectChartTypeFromDropDown
=
async
function
()
{
try
{
const
selectedOptions
=
getSelectedOptionsFromDropDownLists
();
if
(
selectedOptions
===
undefined
)
return
;
const
abbreviationsArr
=
getBuildingSensorSamplingRateAbbreviation
(
...
selectedOptions
);
...
...
@@ -235,6 +244,12 @@ const runFromOptionThree = async function () {
...
abbreviationsArr
);
const
selectedChartType
=
document
.
querySelector
(
"
#drop-down--chart-type
"
).
value
;
if
(
selectedChartType
===
"
--Select--
"
)
return
;
const
URL_DATASTREAM
=
getDatastreamUrl
(
BASE_URL
,
selectedDatastream
);
const
URL_OBSERVATIONS
=
getObservationsUrl
(
BASE_URL
,
selectedDatastream
);
...
...
@@ -255,15 +270,17 @@ const runFromOptionThree = async function () {
const
combinedObs
=
metadataPlusObservations
[
0
];
const
datastreamMetadata
=
metadataPlusObservations
[
1
];
drawLineChartHC
(
formatSTAResponseForLineChart
(
combinedObs
),
formatDatastreamMetadataForChart
(
datastreamMetadata
)
);
drawHeatMapHC
(
formatSTAResponseForHeatMap
(
combinedObs
),
formatDatastreamMetadataForChart
(
datastreamMetadata
)
);
if
(
selectedChartType
===
"
Line
"
)
{
drawLineChartHC
(
formatSTAResponseForLineChart
(
combinedObs
),
formatDatastreamMetadataForChart
(
datastreamMetadata
)
);
}
else
if
(
selectedChartType
===
"
Heatmap
"
)
{
drawHeatMapHC
(
formatSTAResponseForHeatMap
(
combinedObs
),
formatDatastreamMetadataForChart
(
datastreamMetadata
)
);
}
}
catch
(
err
)
{
console
.
error
(
err
);
}
...
...
@@ -271,4 +288,4 @@ const runFromOptionThree = async function () {
document
.
querySelector
(
"
#drop-down--chart-type
"
)
.
addEventListener
(
"
change
"
,
runFromOptionThree
);
.
addEventListener
(
"
change
"
,
selectChartTypeFromDropDown
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment