myio-js-library 0.1.70 → 0.1.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +72 -19
- package/dist/index.js +72 -19
- package/dist/myio-js-library.umd.js +72 -19
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11401,7 +11401,7 @@ async function fetchTelemetryData(token, deviceId, startDate, endDate, queryPara
|
|
|
11401
11401
|
const data = await response.json();
|
|
11402
11402
|
return data;
|
|
11403
11403
|
}
|
|
11404
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
11404
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation) {
|
|
11405
11405
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11406
11406
|
const seriesData = [];
|
|
11407
11407
|
let globalPeak = null;
|
|
@@ -11416,25 +11416,38 @@ function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
|
11416
11416
|
isEmpty = false;
|
|
11417
11417
|
const sortedData = rawSeries.sort((a, b) => a.ts - b.ts);
|
|
11418
11418
|
const points = [];
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11419
|
+
const isAggregated = aggregation && aggregation !== "NONE";
|
|
11420
|
+
if (isAggregated) {
|
|
11421
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11422
|
+
const current = sortedData[i];
|
|
11423
|
+
const value = parseFloat(current.value) * correctionFactor;
|
|
11424
|
+
const timestamp = current.ts;
|
|
11425
|
+
points.push({
|
|
11426
|
+
x: timestamp,
|
|
11427
|
+
y: value
|
|
11428
|
+
});
|
|
11429
|
+
}
|
|
11430
|
+
} else {
|
|
11431
|
+
let previousValue = 0;
|
|
11432
|
+
let previousTs = 0;
|
|
11433
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11434
|
+
const current = sortedData[i];
|
|
11435
|
+
const currentValue = parseFloat(current.value);
|
|
11436
|
+
const currentTs = current.ts;
|
|
11437
|
+
if (i > 0) {
|
|
11438
|
+
const deltaWh = currentValue - previousValue;
|
|
11439
|
+
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11440
|
+
if (deltaWh > 0 && deltaHours > 0) {
|
|
11441
|
+
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11442
|
+
points.push({
|
|
11443
|
+
x: currentTs,
|
|
11444
|
+
y: demandKw
|
|
11445
|
+
});
|
|
11446
|
+
}
|
|
11434
11447
|
}
|
|
11448
|
+
previousValue = currentValue;
|
|
11449
|
+
previousTs = currentTs;
|
|
11435
11450
|
}
|
|
11436
|
-
previousValue = currentValue;
|
|
11437
|
-
previousTs = currentTs;
|
|
11438
11451
|
}
|
|
11439
11452
|
let seriesPeak = null;
|
|
11440
11453
|
if (points.length > 0) {
|
|
@@ -11816,7 +11829,9 @@ async function openDemandModal(params) {
|
|
|
11816
11829
|
rawData,
|
|
11817
11830
|
params.telemetryQuery?.keys || "consumption",
|
|
11818
11831
|
params.correctionFactor || 1,
|
|
11819
|
-
locale
|
|
11832
|
+
locale,
|
|
11833
|
+
params.telemetryQuery?.agg || "MAX"
|
|
11834
|
+
// Pass aggregation type
|
|
11820
11835
|
);
|
|
11821
11836
|
if (chartData.isEmpty) {
|
|
11822
11837
|
errorEl.style.display = "flex";
|
|
@@ -11849,6 +11864,24 @@ async function openDemandModal(params) {
|
|
|
11849
11864
|
borderWidth: 1
|
|
11850
11865
|
}));
|
|
11851
11866
|
chart.options.plugins.legend.display = chartData.series.length > 1;
|
|
11867
|
+
chart.options.plugins.tooltip.callbacks = {
|
|
11868
|
+
title: function(context) {
|
|
11869
|
+
const timestamp = context[0].parsed.x;
|
|
11870
|
+
const date = new Date(timestamp);
|
|
11871
|
+
return date.toLocaleDateString(locale, {
|
|
11872
|
+
day: "2-digit",
|
|
11873
|
+
month: "2-digit",
|
|
11874
|
+
year: "numeric",
|
|
11875
|
+
hour: "2-digit",
|
|
11876
|
+
minute: "2-digit"
|
|
11877
|
+
});
|
|
11878
|
+
},
|
|
11879
|
+
label: function(context) {
|
|
11880
|
+
const seriesLabel = context.dataset.label || "";
|
|
11881
|
+
const value = context.parsed.y;
|
|
11882
|
+
return `${seriesLabel}: ${value.toFixed(2)} kW`;
|
|
11883
|
+
}
|
|
11884
|
+
};
|
|
11852
11885
|
chart.update();
|
|
11853
11886
|
} else {
|
|
11854
11887
|
chart = new Chart(chartCanvas, {
|
|
@@ -11872,6 +11905,26 @@ async function openDemandModal(params) {
|
|
|
11872
11905
|
// Show legend only if multiple series
|
|
11873
11906
|
position: "top"
|
|
11874
11907
|
},
|
|
11908
|
+
tooltip: {
|
|
11909
|
+
callbacks: {
|
|
11910
|
+
title: function(context) {
|
|
11911
|
+
const timestamp = context[0].parsed.x;
|
|
11912
|
+
const date = new Date(timestamp);
|
|
11913
|
+
return date.toLocaleDateString(locale, {
|
|
11914
|
+
day: "2-digit",
|
|
11915
|
+
month: "2-digit",
|
|
11916
|
+
year: "numeric",
|
|
11917
|
+
hour: "2-digit",
|
|
11918
|
+
minute: "2-digit"
|
|
11919
|
+
});
|
|
11920
|
+
},
|
|
11921
|
+
label: function(context) {
|
|
11922
|
+
const seriesLabel = context.dataset.label || "";
|
|
11923
|
+
const value = context.parsed.y;
|
|
11924
|
+
return `${seriesLabel}: ${value.toFixed(2)} kW`;
|
|
11925
|
+
}
|
|
11926
|
+
}
|
|
11927
|
+
},
|
|
11875
11928
|
zoom: {
|
|
11876
11929
|
zoom: {
|
|
11877
11930
|
wheel: { enabled: true },
|
package/dist/index.js
CHANGED
|
@@ -11327,7 +11327,7 @@ async function fetchTelemetryData(token, deviceId, startDate, endDate, queryPara
|
|
|
11327
11327
|
const data = await response.json();
|
|
11328
11328
|
return data;
|
|
11329
11329
|
}
|
|
11330
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
11330
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation) {
|
|
11331
11331
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11332
11332
|
const seriesData = [];
|
|
11333
11333
|
let globalPeak = null;
|
|
@@ -11342,25 +11342,38 @@ function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
|
11342
11342
|
isEmpty = false;
|
|
11343
11343
|
const sortedData = rawSeries.sort((a, b) => a.ts - b.ts);
|
|
11344
11344
|
const points = [];
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
|
|
11345
|
+
const isAggregated = aggregation && aggregation !== "NONE";
|
|
11346
|
+
if (isAggregated) {
|
|
11347
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11348
|
+
const current = sortedData[i];
|
|
11349
|
+
const value = parseFloat(current.value) * correctionFactor;
|
|
11350
|
+
const timestamp = current.ts;
|
|
11351
|
+
points.push({
|
|
11352
|
+
x: timestamp,
|
|
11353
|
+
y: value
|
|
11354
|
+
});
|
|
11355
|
+
}
|
|
11356
|
+
} else {
|
|
11357
|
+
let previousValue = 0;
|
|
11358
|
+
let previousTs = 0;
|
|
11359
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11360
|
+
const current = sortedData[i];
|
|
11361
|
+
const currentValue = parseFloat(current.value);
|
|
11362
|
+
const currentTs = current.ts;
|
|
11363
|
+
if (i > 0) {
|
|
11364
|
+
const deltaWh = currentValue - previousValue;
|
|
11365
|
+
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11366
|
+
if (deltaWh > 0 && deltaHours > 0) {
|
|
11367
|
+
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11368
|
+
points.push({
|
|
11369
|
+
x: currentTs,
|
|
11370
|
+
y: demandKw
|
|
11371
|
+
});
|
|
11372
|
+
}
|
|
11360
11373
|
}
|
|
11374
|
+
previousValue = currentValue;
|
|
11375
|
+
previousTs = currentTs;
|
|
11361
11376
|
}
|
|
11362
|
-
previousValue = currentValue;
|
|
11363
|
-
previousTs = currentTs;
|
|
11364
11377
|
}
|
|
11365
11378
|
let seriesPeak = null;
|
|
11366
11379
|
if (points.length > 0) {
|
|
@@ -11742,7 +11755,9 @@ async function openDemandModal(params) {
|
|
|
11742
11755
|
rawData,
|
|
11743
11756
|
params.telemetryQuery?.keys || "consumption",
|
|
11744
11757
|
params.correctionFactor || 1,
|
|
11745
|
-
locale
|
|
11758
|
+
locale,
|
|
11759
|
+
params.telemetryQuery?.agg || "MAX"
|
|
11760
|
+
// Pass aggregation type
|
|
11746
11761
|
);
|
|
11747
11762
|
if (chartData.isEmpty) {
|
|
11748
11763
|
errorEl.style.display = "flex";
|
|
@@ -11775,6 +11790,24 @@ async function openDemandModal(params) {
|
|
|
11775
11790
|
borderWidth: 1
|
|
11776
11791
|
}));
|
|
11777
11792
|
chart.options.plugins.legend.display = chartData.series.length > 1;
|
|
11793
|
+
chart.options.plugins.tooltip.callbacks = {
|
|
11794
|
+
title: function(context) {
|
|
11795
|
+
const timestamp = context[0].parsed.x;
|
|
11796
|
+
const date = new Date(timestamp);
|
|
11797
|
+
return date.toLocaleDateString(locale, {
|
|
11798
|
+
day: "2-digit",
|
|
11799
|
+
month: "2-digit",
|
|
11800
|
+
year: "numeric",
|
|
11801
|
+
hour: "2-digit",
|
|
11802
|
+
minute: "2-digit"
|
|
11803
|
+
});
|
|
11804
|
+
},
|
|
11805
|
+
label: function(context) {
|
|
11806
|
+
const seriesLabel = context.dataset.label || "";
|
|
11807
|
+
const value = context.parsed.y;
|
|
11808
|
+
return `${seriesLabel}: ${value.toFixed(2)} kW`;
|
|
11809
|
+
}
|
|
11810
|
+
};
|
|
11778
11811
|
chart.update();
|
|
11779
11812
|
} else {
|
|
11780
11813
|
chart = new Chart(chartCanvas, {
|
|
@@ -11798,6 +11831,26 @@ async function openDemandModal(params) {
|
|
|
11798
11831
|
// Show legend only if multiple series
|
|
11799
11832
|
position: "top"
|
|
11800
11833
|
},
|
|
11834
|
+
tooltip: {
|
|
11835
|
+
callbacks: {
|
|
11836
|
+
title: function(context) {
|
|
11837
|
+
const timestamp = context[0].parsed.x;
|
|
11838
|
+
const date = new Date(timestamp);
|
|
11839
|
+
return date.toLocaleDateString(locale, {
|
|
11840
|
+
day: "2-digit",
|
|
11841
|
+
month: "2-digit",
|
|
11842
|
+
year: "numeric",
|
|
11843
|
+
hour: "2-digit",
|
|
11844
|
+
minute: "2-digit"
|
|
11845
|
+
});
|
|
11846
|
+
},
|
|
11847
|
+
label: function(context) {
|
|
11848
|
+
const seriesLabel = context.dataset.label || "";
|
|
11849
|
+
const value = context.parsed.y;
|
|
11850
|
+
return `${seriesLabel}: ${value.toFixed(2)} kW`;
|
|
11851
|
+
}
|
|
11852
|
+
}
|
|
11853
|
+
},
|
|
11801
11854
|
zoom: {
|
|
11802
11855
|
zoom: {
|
|
11803
11856
|
wheel: { enabled: true },
|
|
@@ -11316,7 +11316,7 @@
|
|
|
11316
11316
|
const data = await response.json();
|
|
11317
11317
|
return data;
|
|
11318
11318
|
}
|
|
11319
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
11319
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation) {
|
|
11320
11320
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11321
11321
|
const seriesData = [];
|
|
11322
11322
|
let globalPeak = null;
|
|
@@ -11331,25 +11331,38 @@
|
|
|
11331
11331
|
isEmpty = false;
|
|
11332
11332
|
const sortedData = rawSeries.sort((a, b) => a.ts - b.ts);
|
|
11333
11333
|
const points = [];
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11334
|
+
const isAggregated = aggregation !== "NONE";
|
|
11335
|
+
if (isAggregated) {
|
|
11336
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11337
|
+
const current = sortedData[i];
|
|
11338
|
+
const value = parseFloat(current.value) * correctionFactor;
|
|
11339
|
+
const timestamp = current.ts;
|
|
11340
|
+
points.push({
|
|
11341
|
+
x: timestamp,
|
|
11342
|
+
y: value
|
|
11343
|
+
});
|
|
11344
|
+
}
|
|
11345
|
+
} else {
|
|
11346
|
+
let previousValue = 0;
|
|
11347
|
+
let previousTs = 0;
|
|
11348
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11349
|
+
const current = sortedData[i];
|
|
11350
|
+
const currentValue = parseFloat(current.value);
|
|
11351
|
+
const currentTs = current.ts;
|
|
11352
|
+
if (i > 0) {
|
|
11353
|
+
const deltaWh = currentValue - previousValue;
|
|
11354
|
+
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11355
|
+
if (deltaWh > 0 && deltaHours > 0) {
|
|
11356
|
+
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11357
|
+
points.push({
|
|
11358
|
+
x: currentTs,
|
|
11359
|
+
y: demandKw
|
|
11360
|
+
});
|
|
11361
|
+
}
|
|
11349
11362
|
}
|
|
11363
|
+
previousValue = currentValue;
|
|
11364
|
+
previousTs = currentTs;
|
|
11350
11365
|
}
|
|
11351
|
-
previousValue = currentValue;
|
|
11352
|
-
previousTs = currentTs;
|
|
11353
11366
|
}
|
|
11354
11367
|
let seriesPeak = null;
|
|
11355
11368
|
if (points.length > 0) {
|
|
@@ -11731,7 +11744,9 @@
|
|
|
11731
11744
|
rawData,
|
|
11732
11745
|
params.telemetryQuery?.keys || "consumption",
|
|
11733
11746
|
params.correctionFactor || 1,
|
|
11734
|
-
locale
|
|
11747
|
+
locale,
|
|
11748
|
+
params.telemetryQuery?.agg || "MAX"
|
|
11749
|
+
// Pass aggregation type
|
|
11735
11750
|
);
|
|
11736
11751
|
if (chartData.isEmpty) {
|
|
11737
11752
|
errorEl.style.display = "flex";
|
|
@@ -11764,6 +11779,24 @@
|
|
|
11764
11779
|
borderWidth: 1
|
|
11765
11780
|
}));
|
|
11766
11781
|
chart.options.plugins.legend.display = chartData.series.length > 1;
|
|
11782
|
+
chart.options.plugins.tooltip.callbacks = {
|
|
11783
|
+
title: function(context) {
|
|
11784
|
+
const timestamp = context[0].parsed.x;
|
|
11785
|
+
const date = new Date(timestamp);
|
|
11786
|
+
return date.toLocaleDateString(locale, {
|
|
11787
|
+
day: "2-digit",
|
|
11788
|
+
month: "2-digit",
|
|
11789
|
+
year: "numeric",
|
|
11790
|
+
hour: "2-digit",
|
|
11791
|
+
minute: "2-digit"
|
|
11792
|
+
});
|
|
11793
|
+
},
|
|
11794
|
+
label: function(context) {
|
|
11795
|
+
const seriesLabel = context.dataset.label || "";
|
|
11796
|
+
const value = context.parsed.y;
|
|
11797
|
+
return `${seriesLabel}: ${value.toFixed(2)} kW`;
|
|
11798
|
+
}
|
|
11799
|
+
};
|
|
11767
11800
|
chart.update();
|
|
11768
11801
|
} else {
|
|
11769
11802
|
chart = new Chart(chartCanvas, {
|
|
@@ -11787,6 +11820,26 @@
|
|
|
11787
11820
|
// Show legend only if multiple series
|
|
11788
11821
|
position: "top"
|
|
11789
11822
|
},
|
|
11823
|
+
tooltip: {
|
|
11824
|
+
callbacks: {
|
|
11825
|
+
title: function(context) {
|
|
11826
|
+
const timestamp = context[0].parsed.x;
|
|
11827
|
+
const date = new Date(timestamp);
|
|
11828
|
+
return date.toLocaleDateString(locale, {
|
|
11829
|
+
day: "2-digit",
|
|
11830
|
+
month: "2-digit",
|
|
11831
|
+
year: "numeric",
|
|
11832
|
+
hour: "2-digit",
|
|
11833
|
+
minute: "2-digit"
|
|
11834
|
+
});
|
|
11835
|
+
},
|
|
11836
|
+
label: function(context) {
|
|
11837
|
+
const seriesLabel = context.dataset.label || "";
|
|
11838
|
+
const value = context.parsed.y;
|
|
11839
|
+
return `${seriesLabel}: ${value.toFixed(2)} kW`;
|
|
11840
|
+
}
|
|
11841
|
+
}
|
|
11842
|
+
},
|
|
11790
11843
|
zoom: {
|
|
11791
11844
|
zoom: {
|
|
11792
11845
|
wheel: { enabled: true },
|