myio-js-library 0.1.72 → 0.1.74
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 +27 -32
- package/dist/index.d.cts +1 -0
- package/dist/index.js +27 -32
- package/dist/myio-js-library.umd.js +27 -32
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10887,9 +10887,7 @@ var STRINGS = {
|
|
|
10887
10887
|
title: "Demanda",
|
|
10888
10888
|
period: "Per\xEDodo",
|
|
10889
10889
|
maximum: "M\xE1xima",
|
|
10890
|
-
at: "
|
|
10891
|
-
atTime: "\xE1s",
|
|
10892
|
-
timeUnit: "hs",
|
|
10890
|
+
at: "em",
|
|
10893
10891
|
exportPdf: "Exportar PDF",
|
|
10894
10892
|
exportCsv: "Exportar CSV",
|
|
10895
10893
|
fullscreen: "Tela cheia",
|
|
@@ -10913,8 +10911,6 @@ var STRINGS = {
|
|
|
10913
10911
|
period: "Period",
|
|
10914
10912
|
maximum: "Maximum",
|
|
10915
10913
|
at: "on",
|
|
10916
|
-
atTime: "at",
|
|
10917
|
-
timeUnit: "",
|
|
10918
10914
|
exportPdf: "Export PDF",
|
|
10919
10915
|
exportCsv: "Export CSV",
|
|
10920
10916
|
fullscreen: "Fullscreen",
|
|
@@ -11372,9 +11368,7 @@ function formatDateTime(date, locale) {
|
|
|
11372
11368
|
return date.toLocaleDateString(locale, {
|
|
11373
11369
|
day: "2-digit",
|
|
11374
11370
|
month: "2-digit",
|
|
11375
|
-
year: "numeric"
|
|
11376
|
-
hour: "2-digit",
|
|
11377
|
-
minute: "2-digit"
|
|
11371
|
+
year: "numeric"
|
|
11378
11372
|
});
|
|
11379
11373
|
}
|
|
11380
11374
|
async function fetchTelemetryData(token, deviceId, startDate, endDate, queryParams) {
|
|
@@ -11401,11 +11395,13 @@ async function fetchTelemetryData(token, deviceId, startDate, endDate, queryPara
|
|
|
11401
11395
|
const data = await response.json();
|
|
11402
11396
|
return data;
|
|
11403
11397
|
}
|
|
11404
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation) {
|
|
11398
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation, timezoneOffset) {
|
|
11405
11399
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11406
11400
|
const seriesData = [];
|
|
11407
11401
|
let globalPeak = null;
|
|
11408
11402
|
let isEmpty = true;
|
|
11403
|
+
const tzOffset = timezoneOffset !== void 0 ? timezoneOffset : -3;
|
|
11404
|
+
const tzOffsetMs = tzOffset * 60 * 60 * 1e3;
|
|
11409
11405
|
const colors = ["#4A148C", "#2196F3", "#4CAF50", "#FF9800", "#F44336", "#9C27B0", "#795548", "#607D8B"];
|
|
11410
11406
|
seriesKeys.forEach((key, index) => {
|
|
11411
11407
|
const rawSeries = rawData[key] || [];
|
|
@@ -11421,7 +11417,7 @@ function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, ag
|
|
|
11421
11417
|
for (let i = 0; i < sortedData.length; i++) {
|
|
11422
11418
|
const current = sortedData[i];
|
|
11423
11419
|
const value = parseFloat(current.value) * correctionFactor;
|
|
11424
|
-
const timestamp = current.ts;
|
|
11420
|
+
const timestamp = current.ts + tzOffsetMs;
|
|
11425
11421
|
points.push({
|
|
11426
11422
|
x: timestamp,
|
|
11427
11423
|
y: value
|
|
@@ -11439,8 +11435,9 @@ function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, ag
|
|
|
11439
11435
|
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11440
11436
|
if (deltaWh > 0 && deltaHours > 0) {
|
|
11441
11437
|
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11438
|
+
const timestamp = currentTs + tzOffsetMs;
|
|
11442
11439
|
points.push({
|
|
11443
|
-
x:
|
|
11440
|
+
x: timestamp,
|
|
11444
11441
|
y: demandKw
|
|
11445
11442
|
});
|
|
11446
11443
|
}
|
|
@@ -11655,10 +11652,10 @@ async function openDemandModal(params) {
|
|
|
11655
11652
|
btn.innerHTML = "<span>\u23F3</span> Gerando CSV...";
|
|
11656
11653
|
try {
|
|
11657
11654
|
const BOM = "\uFEFF";
|
|
11658
|
-
let csv = BOM + "Data
|
|
11655
|
+
let csv = BOM + "Data,S\xE9rie,Valor (kW)\n";
|
|
11659
11656
|
chartData.series.forEach((series) => {
|
|
11660
11657
|
series.points.forEach((point) => {
|
|
11661
|
-
const dateStr2 =
|
|
11658
|
+
const dateStr2 = formatDate2(new Date(point.x), locale);
|
|
11662
11659
|
const value = point.y.toFixed(2);
|
|
11663
11660
|
csv += `${dateStr2},${series.label},${value}
|
|
11664
11661
|
`;
|
|
@@ -11730,12 +11727,12 @@ async function openDemandModal(params) {
|
|
|
11730
11727
|
currentY += 10;
|
|
11731
11728
|
const samplePoints = chartData.series[0].points.slice(0, 10);
|
|
11732
11729
|
doc.setFontSize(10);
|
|
11733
|
-
doc.text("Data
|
|
11730
|
+
doc.text("Data", 20, currentY);
|
|
11734
11731
|
doc.text(params.yAxisLabel || strings.demand, 100, currentY);
|
|
11735
11732
|
currentY += 7;
|
|
11736
11733
|
samplePoints.forEach((point) => {
|
|
11737
11734
|
currentY = ensureRoom(doc, currentY, 10);
|
|
11738
|
-
const dateStr =
|
|
11735
|
+
const dateStr = formatDate2(new Date(point.x), params.locale || "pt-BR");
|
|
11739
11736
|
doc.text(dateStr, 20, currentY);
|
|
11740
11737
|
doc.text(point.y.toFixed(2), 100, currentY);
|
|
11741
11738
|
currentY += 7;
|
|
@@ -11759,8 +11756,14 @@ async function openDemandModal(params) {
|
|
|
11759
11756
|
function initializeDateInputs() {
|
|
11760
11757
|
const startDate = new Date(currentStartDate);
|
|
11761
11758
|
const endDate = new Date(currentEndDate);
|
|
11762
|
-
|
|
11763
|
-
|
|
11759
|
+
const formatLocalDate = (date) => {
|
|
11760
|
+
const year = date.getFullYear();
|
|
11761
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
11762
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
11763
|
+
return `${year}-${month}-${day}`;
|
|
11764
|
+
};
|
|
11765
|
+
dateStartInput.value = formatLocalDate(startDate);
|
|
11766
|
+
dateEndInput.value = formatLocalDate(endDate);
|
|
11764
11767
|
}
|
|
11765
11768
|
async function updatePeriod() {
|
|
11766
11769
|
periodErrorEl.style.display = "none";
|
|
@@ -11830,8 +11833,10 @@ async function openDemandModal(params) {
|
|
|
11830
11833
|
params.telemetryQuery?.keys || "consumption",
|
|
11831
11834
|
params.correctionFactor || 1,
|
|
11832
11835
|
locale,
|
|
11833
|
-
params.telemetryQuery?.agg || "MAX"
|
|
11836
|
+
params.telemetryQuery?.agg || "MAX",
|
|
11834
11837
|
// Pass aggregation type
|
|
11838
|
+
params.timezoneOffset
|
|
11839
|
+
// Pass timezone offset (default: -3)
|
|
11835
11840
|
);
|
|
11836
11841
|
if (chartData.isEmpty) {
|
|
11837
11842
|
errorEl.style.display = "flex";
|
|
@@ -11846,11 +11851,7 @@ async function openDemandModal(params) {
|
|
|
11846
11851
|
month: "2-digit",
|
|
11847
11852
|
year: "numeric"
|
|
11848
11853
|
});
|
|
11849
|
-
|
|
11850
|
-
hour: "2-digit",
|
|
11851
|
-
minute: "2-digit"
|
|
11852
|
-
});
|
|
11853
|
-
peakEl.textContent = `${strings.maximum}: ${peak.formattedValue} kW ${peak.key ? `(${peak.key}) ` : ""}${strings.at} ${dateStr} ${strings.atTime} ${timeStr}${strings.timeUnit}`;
|
|
11854
|
+
peakEl.textContent = `${strings.maximum}: ${peak.formattedValue} kW ${peak.key ? `(${peak.key}) ` : ""}${strings.at} ${dateStr}`;
|
|
11854
11855
|
peakEl.style.display = "block";
|
|
11855
11856
|
}
|
|
11856
11857
|
const Chart = window.Chart;
|
|
@@ -11871,9 +11872,7 @@ async function openDemandModal(params) {
|
|
|
11871
11872
|
return date.toLocaleDateString(locale, {
|
|
11872
11873
|
day: "2-digit",
|
|
11873
11874
|
month: "2-digit",
|
|
11874
|
-
year: "numeric"
|
|
11875
|
-
hour: "2-digit",
|
|
11876
|
-
minute: "2-digit"
|
|
11875
|
+
year: "numeric"
|
|
11877
11876
|
});
|
|
11878
11877
|
},
|
|
11879
11878
|
label: function(context) {
|
|
@@ -11913,9 +11912,7 @@ async function openDemandModal(params) {
|
|
|
11913
11912
|
return date.toLocaleDateString(locale, {
|
|
11914
11913
|
day: "2-digit",
|
|
11915
11914
|
month: "2-digit",
|
|
11916
|
-
year: "numeric"
|
|
11917
|
-
hour: "2-digit",
|
|
11918
|
-
minute: "2-digit"
|
|
11915
|
+
year: "numeric"
|
|
11919
11916
|
});
|
|
11920
11917
|
},
|
|
11921
11918
|
label: function(context) {
|
|
@@ -11951,10 +11948,8 @@ async function openDemandModal(params) {
|
|
|
11951
11948
|
callback: function(value) {
|
|
11952
11949
|
const date = new Date(value);
|
|
11953
11950
|
return date.toLocaleDateString(locale, {
|
|
11954
|
-
month: "2-digit",
|
|
11955
11951
|
day: "2-digit",
|
|
11956
|
-
|
|
11957
|
-
minute: "2-digit"
|
|
11952
|
+
month: "2-digit"
|
|
11958
11953
|
});
|
|
11959
11954
|
}
|
|
11960
11955
|
}
|
package/dist/index.d.cts
CHANGED
package/dist/index.js
CHANGED
|
@@ -10813,9 +10813,7 @@ var STRINGS = {
|
|
|
10813
10813
|
title: "Demanda",
|
|
10814
10814
|
period: "Per\xEDodo",
|
|
10815
10815
|
maximum: "M\xE1xima",
|
|
10816
|
-
at: "
|
|
10817
|
-
atTime: "\xE1s",
|
|
10818
|
-
timeUnit: "hs",
|
|
10816
|
+
at: "em",
|
|
10819
10817
|
exportPdf: "Exportar PDF",
|
|
10820
10818
|
exportCsv: "Exportar CSV",
|
|
10821
10819
|
fullscreen: "Tela cheia",
|
|
@@ -10839,8 +10837,6 @@ var STRINGS = {
|
|
|
10839
10837
|
period: "Period",
|
|
10840
10838
|
maximum: "Maximum",
|
|
10841
10839
|
at: "on",
|
|
10842
|
-
atTime: "at",
|
|
10843
|
-
timeUnit: "",
|
|
10844
10840
|
exportPdf: "Export PDF",
|
|
10845
10841
|
exportCsv: "Export CSV",
|
|
10846
10842
|
fullscreen: "Fullscreen",
|
|
@@ -11298,9 +11294,7 @@ function formatDateTime(date, locale) {
|
|
|
11298
11294
|
return date.toLocaleDateString(locale, {
|
|
11299
11295
|
day: "2-digit",
|
|
11300
11296
|
month: "2-digit",
|
|
11301
|
-
year: "numeric"
|
|
11302
|
-
hour: "2-digit",
|
|
11303
|
-
minute: "2-digit"
|
|
11297
|
+
year: "numeric"
|
|
11304
11298
|
});
|
|
11305
11299
|
}
|
|
11306
11300
|
async function fetchTelemetryData(token, deviceId, startDate, endDate, queryParams) {
|
|
@@ -11327,11 +11321,13 @@ async function fetchTelemetryData(token, deviceId, startDate, endDate, queryPara
|
|
|
11327
11321
|
const data = await response.json();
|
|
11328
11322
|
return data;
|
|
11329
11323
|
}
|
|
11330
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation) {
|
|
11324
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation, timezoneOffset) {
|
|
11331
11325
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11332
11326
|
const seriesData = [];
|
|
11333
11327
|
let globalPeak = null;
|
|
11334
11328
|
let isEmpty = true;
|
|
11329
|
+
const tzOffset = timezoneOffset !== void 0 ? timezoneOffset : -3;
|
|
11330
|
+
const tzOffsetMs = tzOffset * 60 * 60 * 1e3;
|
|
11335
11331
|
const colors = ["#4A148C", "#2196F3", "#4CAF50", "#FF9800", "#F44336", "#9C27B0", "#795548", "#607D8B"];
|
|
11336
11332
|
seriesKeys.forEach((key, index) => {
|
|
11337
11333
|
const rawSeries = rawData[key] || [];
|
|
@@ -11347,7 +11343,7 @@ function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, ag
|
|
|
11347
11343
|
for (let i = 0; i < sortedData.length; i++) {
|
|
11348
11344
|
const current = sortedData[i];
|
|
11349
11345
|
const value = parseFloat(current.value) * correctionFactor;
|
|
11350
|
-
const timestamp = current.ts;
|
|
11346
|
+
const timestamp = current.ts + tzOffsetMs;
|
|
11351
11347
|
points.push({
|
|
11352
11348
|
x: timestamp,
|
|
11353
11349
|
y: value
|
|
@@ -11365,8 +11361,9 @@ function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, ag
|
|
|
11365
11361
|
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11366
11362
|
if (deltaWh > 0 && deltaHours > 0) {
|
|
11367
11363
|
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11364
|
+
const timestamp = currentTs + tzOffsetMs;
|
|
11368
11365
|
points.push({
|
|
11369
|
-
x:
|
|
11366
|
+
x: timestamp,
|
|
11370
11367
|
y: demandKw
|
|
11371
11368
|
});
|
|
11372
11369
|
}
|
|
@@ -11581,10 +11578,10 @@ async function openDemandModal(params) {
|
|
|
11581
11578
|
btn.innerHTML = "<span>\u23F3</span> Gerando CSV...";
|
|
11582
11579
|
try {
|
|
11583
11580
|
const BOM = "\uFEFF";
|
|
11584
|
-
let csv = BOM + "Data
|
|
11581
|
+
let csv = BOM + "Data,S\xE9rie,Valor (kW)\n";
|
|
11585
11582
|
chartData.series.forEach((series) => {
|
|
11586
11583
|
series.points.forEach((point) => {
|
|
11587
|
-
const dateStr2 =
|
|
11584
|
+
const dateStr2 = formatDate2(new Date(point.x), locale);
|
|
11588
11585
|
const value = point.y.toFixed(2);
|
|
11589
11586
|
csv += `${dateStr2},${series.label},${value}
|
|
11590
11587
|
`;
|
|
@@ -11656,12 +11653,12 @@ async function openDemandModal(params) {
|
|
|
11656
11653
|
currentY += 10;
|
|
11657
11654
|
const samplePoints = chartData.series[0].points.slice(0, 10);
|
|
11658
11655
|
doc.setFontSize(10);
|
|
11659
|
-
doc.text("Data
|
|
11656
|
+
doc.text("Data", 20, currentY);
|
|
11660
11657
|
doc.text(params.yAxisLabel || strings.demand, 100, currentY);
|
|
11661
11658
|
currentY += 7;
|
|
11662
11659
|
samplePoints.forEach((point) => {
|
|
11663
11660
|
currentY = ensureRoom(doc, currentY, 10);
|
|
11664
|
-
const dateStr =
|
|
11661
|
+
const dateStr = formatDate2(new Date(point.x), params.locale || "pt-BR");
|
|
11665
11662
|
doc.text(dateStr, 20, currentY);
|
|
11666
11663
|
doc.text(point.y.toFixed(2), 100, currentY);
|
|
11667
11664
|
currentY += 7;
|
|
@@ -11685,8 +11682,14 @@ async function openDemandModal(params) {
|
|
|
11685
11682
|
function initializeDateInputs() {
|
|
11686
11683
|
const startDate = new Date(currentStartDate);
|
|
11687
11684
|
const endDate = new Date(currentEndDate);
|
|
11688
|
-
|
|
11689
|
-
|
|
11685
|
+
const formatLocalDate = (date) => {
|
|
11686
|
+
const year = date.getFullYear();
|
|
11687
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
11688
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
11689
|
+
return `${year}-${month}-${day}`;
|
|
11690
|
+
};
|
|
11691
|
+
dateStartInput.value = formatLocalDate(startDate);
|
|
11692
|
+
dateEndInput.value = formatLocalDate(endDate);
|
|
11690
11693
|
}
|
|
11691
11694
|
async function updatePeriod() {
|
|
11692
11695
|
periodErrorEl.style.display = "none";
|
|
@@ -11756,8 +11759,10 @@ async function openDemandModal(params) {
|
|
|
11756
11759
|
params.telemetryQuery?.keys || "consumption",
|
|
11757
11760
|
params.correctionFactor || 1,
|
|
11758
11761
|
locale,
|
|
11759
|
-
params.telemetryQuery?.agg || "MAX"
|
|
11762
|
+
params.telemetryQuery?.agg || "MAX",
|
|
11760
11763
|
// Pass aggregation type
|
|
11764
|
+
params.timezoneOffset
|
|
11765
|
+
// Pass timezone offset (default: -3)
|
|
11761
11766
|
);
|
|
11762
11767
|
if (chartData.isEmpty) {
|
|
11763
11768
|
errorEl.style.display = "flex";
|
|
@@ -11772,11 +11777,7 @@ async function openDemandModal(params) {
|
|
|
11772
11777
|
month: "2-digit",
|
|
11773
11778
|
year: "numeric"
|
|
11774
11779
|
});
|
|
11775
|
-
|
|
11776
|
-
hour: "2-digit",
|
|
11777
|
-
minute: "2-digit"
|
|
11778
|
-
});
|
|
11779
|
-
peakEl.textContent = `${strings.maximum}: ${peak.formattedValue} kW ${peak.key ? `(${peak.key}) ` : ""}${strings.at} ${dateStr} ${strings.atTime} ${timeStr}${strings.timeUnit}`;
|
|
11780
|
+
peakEl.textContent = `${strings.maximum}: ${peak.formattedValue} kW ${peak.key ? `(${peak.key}) ` : ""}${strings.at} ${dateStr}`;
|
|
11780
11781
|
peakEl.style.display = "block";
|
|
11781
11782
|
}
|
|
11782
11783
|
const Chart = window.Chart;
|
|
@@ -11797,9 +11798,7 @@ async function openDemandModal(params) {
|
|
|
11797
11798
|
return date.toLocaleDateString(locale, {
|
|
11798
11799
|
day: "2-digit",
|
|
11799
11800
|
month: "2-digit",
|
|
11800
|
-
year: "numeric"
|
|
11801
|
-
hour: "2-digit",
|
|
11802
|
-
minute: "2-digit"
|
|
11801
|
+
year: "numeric"
|
|
11803
11802
|
});
|
|
11804
11803
|
},
|
|
11805
11804
|
label: function(context) {
|
|
@@ -11839,9 +11838,7 @@ async function openDemandModal(params) {
|
|
|
11839
11838
|
return date.toLocaleDateString(locale, {
|
|
11840
11839
|
day: "2-digit",
|
|
11841
11840
|
month: "2-digit",
|
|
11842
|
-
year: "numeric"
|
|
11843
|
-
hour: "2-digit",
|
|
11844
|
-
minute: "2-digit"
|
|
11841
|
+
year: "numeric"
|
|
11845
11842
|
});
|
|
11846
11843
|
},
|
|
11847
11844
|
label: function(context) {
|
|
@@ -11877,10 +11874,8 @@ async function openDemandModal(params) {
|
|
|
11877
11874
|
callback: function(value) {
|
|
11878
11875
|
const date = new Date(value);
|
|
11879
11876
|
return date.toLocaleDateString(locale, {
|
|
11880
|
-
month: "2-digit",
|
|
11881
11877
|
day: "2-digit",
|
|
11882
|
-
|
|
11883
|
-
minute: "2-digit"
|
|
11878
|
+
month: "2-digit"
|
|
11884
11879
|
});
|
|
11885
11880
|
}
|
|
11886
11881
|
}
|
|
@@ -10802,9 +10802,7 @@
|
|
|
10802
10802
|
title: "Demanda",
|
|
10803
10803
|
period: "Per\xEDodo",
|
|
10804
10804
|
maximum: "M\xE1xima",
|
|
10805
|
-
at: "
|
|
10806
|
-
atTime: "\xE1s",
|
|
10807
|
-
timeUnit: "hs",
|
|
10805
|
+
at: "em",
|
|
10808
10806
|
exportPdf: "Exportar PDF",
|
|
10809
10807
|
exportCsv: "Exportar CSV",
|
|
10810
10808
|
fullscreen: "Tela cheia",
|
|
@@ -10828,8 +10826,6 @@
|
|
|
10828
10826
|
period: "Period",
|
|
10829
10827
|
maximum: "Maximum",
|
|
10830
10828
|
at: "on",
|
|
10831
|
-
atTime: "at",
|
|
10832
|
-
timeUnit: "",
|
|
10833
10829
|
exportPdf: "Export PDF",
|
|
10834
10830
|
exportCsv: "Export CSV",
|
|
10835
10831
|
fullscreen: "Fullscreen",
|
|
@@ -11287,9 +11283,7 @@
|
|
|
11287
11283
|
return date.toLocaleDateString(locale, {
|
|
11288
11284
|
day: "2-digit",
|
|
11289
11285
|
month: "2-digit",
|
|
11290
|
-
year: "numeric"
|
|
11291
|
-
hour: "2-digit",
|
|
11292
|
-
minute: "2-digit"
|
|
11286
|
+
year: "numeric"
|
|
11293
11287
|
});
|
|
11294
11288
|
}
|
|
11295
11289
|
async function fetchTelemetryData(token, deviceId, startDate, endDate, queryParams) {
|
|
@@ -11316,11 +11310,13 @@
|
|
|
11316
11310
|
const data = await response.json();
|
|
11317
11311
|
return data;
|
|
11318
11312
|
}
|
|
11319
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation) {
|
|
11313
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation, timezoneOffset) {
|
|
11320
11314
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11321
11315
|
const seriesData = [];
|
|
11322
11316
|
let globalPeak = null;
|
|
11323
11317
|
let isEmpty = true;
|
|
11318
|
+
const tzOffset = timezoneOffset !== void 0 ? timezoneOffset : -3;
|
|
11319
|
+
const tzOffsetMs = tzOffset * 60 * 60 * 1e3;
|
|
11324
11320
|
const colors = ["#4A148C", "#2196F3", "#4CAF50", "#FF9800", "#F44336", "#9C27B0", "#795548", "#607D8B"];
|
|
11325
11321
|
seriesKeys.forEach((key, index) => {
|
|
11326
11322
|
const rawSeries = rawData[key] || [];
|
|
@@ -11336,7 +11332,7 @@
|
|
|
11336
11332
|
for (let i = 0; i < sortedData.length; i++) {
|
|
11337
11333
|
const current = sortedData[i];
|
|
11338
11334
|
const value = parseFloat(current.value) * correctionFactor;
|
|
11339
|
-
const timestamp = current.ts;
|
|
11335
|
+
const timestamp = current.ts + tzOffsetMs;
|
|
11340
11336
|
points.push({
|
|
11341
11337
|
x: timestamp,
|
|
11342
11338
|
y: value
|
|
@@ -11354,8 +11350,9 @@
|
|
|
11354
11350
|
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11355
11351
|
if (deltaWh > 0 && deltaHours > 0) {
|
|
11356
11352
|
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11353
|
+
const timestamp = currentTs + tzOffsetMs;
|
|
11357
11354
|
points.push({
|
|
11358
|
-
x:
|
|
11355
|
+
x: timestamp,
|
|
11359
11356
|
y: demandKw
|
|
11360
11357
|
});
|
|
11361
11358
|
}
|
|
@@ -11570,10 +11567,10 @@
|
|
|
11570
11567
|
btn.innerHTML = "<span>\u23F3</span> Gerando CSV...";
|
|
11571
11568
|
try {
|
|
11572
11569
|
const BOM = "\uFEFF";
|
|
11573
|
-
let csv = BOM + "Data
|
|
11570
|
+
let csv = BOM + "Data,S\xE9rie,Valor (kW)\n";
|
|
11574
11571
|
chartData.series.forEach((series) => {
|
|
11575
11572
|
series.points.forEach((point) => {
|
|
11576
|
-
const dateStr2 =
|
|
11573
|
+
const dateStr2 = formatDate2(new Date(point.x), locale);
|
|
11577
11574
|
const value = point.y.toFixed(2);
|
|
11578
11575
|
csv += `${dateStr2},${series.label},${value}
|
|
11579
11576
|
`;
|
|
@@ -11645,12 +11642,12 @@
|
|
|
11645
11642
|
currentY += 10;
|
|
11646
11643
|
const samplePoints = chartData.series[0].points.slice(0, 10);
|
|
11647
11644
|
doc.setFontSize(10);
|
|
11648
|
-
doc.text("Data
|
|
11645
|
+
doc.text("Data", 20, currentY);
|
|
11649
11646
|
doc.text(params.yAxisLabel || strings.demand, 100, currentY);
|
|
11650
11647
|
currentY += 7;
|
|
11651
11648
|
samplePoints.forEach((point) => {
|
|
11652
11649
|
currentY = ensureRoom(doc, currentY, 10);
|
|
11653
|
-
const dateStr =
|
|
11650
|
+
const dateStr = formatDate2(new Date(point.x), params.locale || "pt-BR");
|
|
11654
11651
|
doc.text(dateStr, 20, currentY);
|
|
11655
11652
|
doc.text(point.y.toFixed(2), 100, currentY);
|
|
11656
11653
|
currentY += 7;
|
|
@@ -11674,8 +11671,14 @@
|
|
|
11674
11671
|
function initializeDateInputs() {
|
|
11675
11672
|
const startDate = new Date(currentStartDate);
|
|
11676
11673
|
const endDate = new Date(currentEndDate);
|
|
11677
|
-
|
|
11678
|
-
|
|
11674
|
+
const formatLocalDate = (date) => {
|
|
11675
|
+
const year = date.getFullYear();
|
|
11676
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
11677
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
11678
|
+
return `${year}-${month}-${day}`;
|
|
11679
|
+
};
|
|
11680
|
+
dateStartInput.value = formatLocalDate(startDate);
|
|
11681
|
+
dateEndInput.value = formatLocalDate(endDate);
|
|
11679
11682
|
}
|
|
11680
11683
|
async function updatePeriod() {
|
|
11681
11684
|
periodErrorEl.style.display = "none";
|
|
@@ -11745,8 +11748,10 @@
|
|
|
11745
11748
|
params.telemetryQuery?.keys || "consumption",
|
|
11746
11749
|
params.correctionFactor || 1,
|
|
11747
11750
|
locale,
|
|
11748
|
-
params.telemetryQuery?.agg || "MAX"
|
|
11751
|
+
params.telemetryQuery?.agg || "MAX",
|
|
11749
11752
|
// Pass aggregation type
|
|
11753
|
+
params.timezoneOffset
|
|
11754
|
+
// Pass timezone offset (default: -3)
|
|
11750
11755
|
);
|
|
11751
11756
|
if (chartData.isEmpty) {
|
|
11752
11757
|
errorEl.style.display = "flex";
|
|
@@ -11761,11 +11766,7 @@
|
|
|
11761
11766
|
month: "2-digit",
|
|
11762
11767
|
year: "numeric"
|
|
11763
11768
|
});
|
|
11764
|
-
|
|
11765
|
-
hour: "2-digit",
|
|
11766
|
-
minute: "2-digit"
|
|
11767
|
-
});
|
|
11768
|
-
peakEl.textContent = `${strings.maximum}: ${peak.formattedValue} kW ${peak.key ? `(${peak.key}) ` : ""}${strings.at} ${dateStr} ${strings.atTime} ${timeStr}${strings.timeUnit}`;
|
|
11769
|
+
peakEl.textContent = `${strings.maximum}: ${peak.formattedValue} kW ${peak.key ? `(${peak.key}) ` : ""}${strings.at} ${dateStr}`;
|
|
11769
11770
|
peakEl.style.display = "block";
|
|
11770
11771
|
}
|
|
11771
11772
|
const Chart = window.Chart;
|
|
@@ -11786,9 +11787,7 @@
|
|
|
11786
11787
|
return date.toLocaleDateString(locale, {
|
|
11787
11788
|
day: "2-digit",
|
|
11788
11789
|
month: "2-digit",
|
|
11789
|
-
year: "numeric"
|
|
11790
|
-
hour: "2-digit",
|
|
11791
|
-
minute: "2-digit"
|
|
11790
|
+
year: "numeric"
|
|
11792
11791
|
});
|
|
11793
11792
|
},
|
|
11794
11793
|
label: function(context) {
|
|
@@ -11828,9 +11827,7 @@
|
|
|
11828
11827
|
return date.toLocaleDateString(locale, {
|
|
11829
11828
|
day: "2-digit",
|
|
11830
11829
|
month: "2-digit",
|
|
11831
|
-
year: "numeric"
|
|
11832
|
-
hour: "2-digit",
|
|
11833
|
-
minute: "2-digit"
|
|
11830
|
+
year: "numeric"
|
|
11834
11831
|
});
|
|
11835
11832
|
},
|
|
11836
11833
|
label: function(context) {
|
|
@@ -11866,10 +11863,8 @@
|
|
|
11866
11863
|
callback: function(value) {
|
|
11867
11864
|
const date = new Date(value);
|
|
11868
11865
|
return date.toLocaleDateString(locale, {
|
|
11869
|
-
month: "2-digit",
|
|
11870
11866
|
day: "2-digit",
|
|
11871
|
-
|
|
11872
|
-
minute: "2-digit"
|
|
11867
|
+
month: "2-digit"
|
|
11873
11868
|
});
|
|
11874
11869
|
}
|
|
11875
11870
|
}
|