Skip to content

Commit f58afe6

Browse files
committed
add documentation
1 parent fa4c1af commit f58afe6

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

src/views/Chart.vue

+67
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,11 @@ export default {
11831183
this.chartDate = newDate;
11841184
this.chartRange = newRange;
11851185
},
1186+
/**
1187+
* Returns the card subtype based on the given element key.
1188+
* @param {string} elementKey - The key of the element.
1189+
* @returns {string} - The card subtype.
1190+
*/
11861191
getCardSubtype(elementKey) {
11871192
switch (elementKey) {
11881193
case "bat":
@@ -1199,6 +1204,12 @@ export default {
11991204
return "secondary";
12001205
}
12011206
},
1207+
/**
1208+
* Returns the icon for a given element key.
1209+
* @param {string} elementKey - The key of the element.
1210+
* @returns {Array<string>|undefined} - The icon as an array of strings representing the icon class.
1211+
* If the element key is not recognized, undefined is returned.
1212+
*/
12021213
getCardIcon(elementKey) {
12031214
switch (elementKey) {
12041215
case "bat":
@@ -1217,6 +1228,14 @@ export default {
12171228
return undefined;
12181229
}
12191230
},
1231+
/**
1232+
* Hides a dataset in the chart.
1233+
*
1234+
* @param {Object} baseObject - The base object containing the dataset.
1235+
* @param {string} objectKey - The key of the dataset to hide.
1236+
* @param {string} elementKey - The key of the element.
1237+
* @returns {boolean} - True if the dataset should be hidden, false otherwise.
1238+
*/
12201239
hideDataset(baseObject, objectKey, elementKey) {
12211240
// if dataset "all" is present, hide component datasets
12221241
if (["bat", "pv", "cp"].includes(baseObject)) {
@@ -1240,6 +1259,14 @@ export default {
12401259
}
12411260
return false;
12421261
},
1262+
/**
1263+
* Returns the label for the totals.
1264+
*
1265+
* @param {string} groupKey - The key of the group.
1266+
* @param {string} componentKey - The key of the component.
1267+
* @param {string} measurementKey - The key of the measurement.
1268+
* @returns {string} The label for the totals.
1269+
*/
12431270
getTotalsLabel(
12441271
groupKey,
12451272
componentKey = undefined,
@@ -1515,6 +1542,12 @@ export default {
15151542
details.length ? " (" + details.join(", ") + ")" : ""
15161543
}`;
15171544
},
1545+
/**
1546+
* Returns the index of the dataset with the specified dataset key.
1547+
*
1548+
* @param {string} datasetKey - The key of the dataset to find.
1549+
* @returns {number|undefined} - The index of the dataset if found, otherwise undefined.
1550+
*/
15181551
getDatasetIndex(datasetKey) {
15191552
let index = this.chartDatasets.datasets.findIndex((dataset) => {
15201553
return dataset.jsonKey == datasetKey;
@@ -1524,6 +1557,15 @@ export default {
15241557
}
15251558
return;
15261559
},
1560+
/**
1561+
* Adds a dataset to the chart.
1562+
*
1563+
* @param {string} baseObject - The base object for the dataset.
1564+
* @param {string} objectKey - The object key for the dataset.
1565+
* @param {string} elementKey - The element key for the dataset.
1566+
* @param {string} datasetKey - The dataset key.
1567+
* @returns {number|undefined} - The index of the added dataset or undefined if no dataset was added.
1568+
*/
15271569
addDataset(baseObject, objectKey, elementKey, datasetKey) {
15281570
// do not add dataset if objectKey is not present in totals[baseObject]
15291571
if (
@@ -1583,6 +1625,13 @@ export default {
15831625
}
15841626
return;
15851627
},
1628+
/**
1629+
* Initializes a dataset based on the provided parameters.
1630+
*
1631+
* @param {string} baseObject - The base object of the dataset.
1632+
* @param {string} objectKey - The object key of the dataset.
1633+
* @param {string} elementKey - The element key of the dataset.
1634+
*/
15861635
initDataset(baseObject, objectKey, elementKey) {
15871636
var elementKeysToAdd = [];
15881637
if (this.chartRange == "day") {
@@ -1631,6 +1680,10 @@ export default {
16311680
console.debug("skipping dataset:", datasetKey);
16321681
}
16331682
},
1683+
/**
1684+
* Sets up the X scale for the chart.
1685+
* Updates the chart options with the specified X scale properties.
1686+
*/
16341687
setupScaleX() {
16351688
this.chartOptions.scales.x.time.unit = this.chartScaleX.unit;
16361689
this.chartOptions.scales.x.time.tooltipFormat =
@@ -1639,6 +1692,10 @@ export default {
16391692
this.chartOptions.scales.x.ticks.maxTicksLimit =
16401693
this.chartScaleX.maxTicksLimit;
16411694
},
1695+
/**
1696+
* Requests chart data based on the selected chart range.
1697+
* If the chart form is invalid, a warning is logged and the function returns.
1698+
*/
16421699
requestChart() {
16431700
let myForm = document.forms["chartForm"];
16441701
if (!myForm.reportValidity()) {
@@ -1665,15 +1722,25 @@ export default {
16651722
});
16661723
}
16671724
},
1725+
/**
1726+
* Clears the chart data by removing all topics that match the wildcard pattern.
1727+
* Then, it commits the "removeTopic" mutation for each topic in the list.
1728+
*/
16681729
clearChartData() {
16691730
this.getWildcardIndexList(this.baseTopic + "+").forEach((topic) => {
16701731
this.$store.commit("removeTopic", `${this.baseTopic}${topic}`);
16711732
});
16721733
},
1734+
/**
1735+
* Updates the chart by clearing the chart data and then requesting new chart data.
1736+
*/
16731737
updateChart() {
16741738
this.clearChartData();
16751739
this.requestChart();
16761740
},
1741+
/**
1742+
* Initializes the chart by setting the current date and chart date based on the chart range and initial date.
1743+
*/
16771744
init() {
16781745
const today = new Date();
16791746
this.currentDate = String(today.getFullYear());

0 commit comments

Comments
 (0)