@@ -1183,6 +1183,11 @@ export default {
1183
1183
this .chartDate = newDate;
1184
1184
this .chartRange = newRange;
1185
1185
},
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
+ */
1186
1191
getCardSubtype (elementKey ) {
1187
1192
switch (elementKey) {
1188
1193
case " bat" :
@@ -1199,6 +1204,12 @@ export default {
1199
1204
return " secondary" ;
1200
1205
}
1201
1206
},
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
+ */
1202
1213
getCardIcon (elementKey ) {
1203
1214
switch (elementKey) {
1204
1215
case " bat" :
@@ -1217,6 +1228,14 @@ export default {
1217
1228
return undefined ;
1218
1229
}
1219
1230
},
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
+ */
1220
1239
hideDataset (baseObject , objectKey , elementKey ) {
1221
1240
// if dataset "all" is present, hide component datasets
1222
1241
if ([" bat" , " pv" , " cp" ].includes (baseObject)) {
@@ -1240,6 +1259,14 @@ export default {
1240
1259
}
1241
1260
return false ;
1242
1261
},
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
+ */
1243
1270
getTotalsLabel (
1244
1271
groupKey,
1245
1272
componentKey = undefined ,
@@ -1515,6 +1542,12 @@ export default {
1515
1542
details .length ? " (" + details .join (" , " ) + " )" : " "
1516
1543
} ` ;
1517
1544
},
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
+ */
1518
1551
getDatasetIndex (datasetKey ) {
1519
1552
let index = this .chartDatasets .datasets .findIndex ((dataset ) => {
1520
1553
return dataset .jsonKey == datasetKey;
@@ -1524,6 +1557,15 @@ export default {
1524
1557
}
1525
1558
return ;
1526
1559
},
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
+ */
1527
1569
addDataset (baseObject , objectKey , elementKey , datasetKey ) {
1528
1570
// do not add dataset if objectKey is not present in totals[baseObject]
1529
1571
if (
@@ -1583,6 +1625,13 @@ export default {
1583
1625
}
1584
1626
return ;
1585
1627
},
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
+ */
1586
1635
initDataset (baseObject , objectKey , elementKey ) {
1587
1636
var elementKeysToAdd = [];
1588
1637
if (this .chartRange == " day" ) {
@@ -1631,6 +1680,10 @@ export default {
1631
1680
console .debug (" skipping dataset:" , datasetKey);
1632
1681
}
1633
1682
},
1683
+ /**
1684
+ * Sets up the X scale for the chart.
1685
+ * Updates the chart options with the specified X scale properties.
1686
+ */
1634
1687
setupScaleX () {
1635
1688
this .chartOptions .scales .x .time .unit = this .chartScaleX .unit ;
1636
1689
this .chartOptions .scales .x .time .tooltipFormat =
@@ -1639,6 +1692,10 @@ export default {
1639
1692
this .chartOptions .scales .x .ticks .maxTicksLimit =
1640
1693
this .chartScaleX .maxTicksLimit ;
1641
1694
},
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
+ */
1642
1699
requestChart () {
1643
1700
let myForm = document .forms [" chartForm" ];
1644
1701
if (! myForm .reportValidity ()) {
@@ -1665,15 +1722,25 @@ export default {
1665
1722
});
1666
1723
}
1667
1724
},
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
+ */
1668
1729
clearChartData () {
1669
1730
this .getWildcardIndexList (this .baseTopic + " +" ).forEach ((topic ) => {
1670
1731
this .$store .commit (" removeTopic" , ` ${ this .baseTopic }${ topic} ` );
1671
1732
});
1672
1733
},
1734
+ /**
1735
+ * Updates the chart by clearing the chart data and then requesting new chart data.
1736
+ */
1673
1737
updateChart () {
1674
1738
this .clearChartData ();
1675
1739
this .requestChart ();
1676
1740
},
1741
+ /**
1742
+ * Initializes the chart by setting the current date and chart date based on the chart range and initial date.
1743
+ */
1677
1744
init () {
1678
1745
const today = new Date ();
1679
1746
this .currentDate = String (today .getFullYear ());
0 commit comments