Update CardChart_History.js

add const 'factor' for big value and negativ value on panel
This commit is contained in:
Thomas
2025-02-23 03:10:01 +01:00
committed by GitHub
parent ac07dbb185
commit b395a08b6e

View File

@@ -1,8 +1,9 @@
var sourceDP = 'alias.0.Wohnzimmer.Heizung.ACTUAL'; const sourceDP = 'alias.0.Wohnzimmer.Heizung.ACTUAL';
var targetDP = '0_userdata.0.Test.chartTest'; const targetDP = '0_userdata.0.Test.chartTest';
var rangeHours = 24; const rangeHours = 24;
var maxXAchsisTicks = 6; const maxXAchsisTicks = 6;
var historyInstance = 'history.0'; const historyInstance = 'history.0';
const factor = 1; // Bei zu großen Werten und negativen Anzeigen im Panel um das 10fache erhöhen
on({id: sourceDP, change: "any"}, async function (obj) { on({id: sourceDP, change: "any"}, async function (obj) {
sendTo(historyInstance, 'getHistory', { sendTo(historyInstance, 'getHistory', {
@@ -25,7 +26,7 @@ on({id: sourceDP, change: "any"}, async function (obj) {
//Check history items for requested hours //Check history items for requested hours
for (var j = 0, targetValue = 0; j < result.result.length; j++) { for (var j = 0, targetValue = 0; j < result.result.length; j++) {
var valueDate = new Date(result.result[j].ts); var valueDate = new Date(result.result[j].ts);
var value = (Math.round(result.result[j].val * 10) / 10); var value = Math.round(result.result[j].val / factor * 10);
if (valueDate > targetDate){ if (valueDate > targetDate){
if ((targetDate.getHours() % stepXAchsis) == 0){ if ((targetDate.getHours() % stepXAchsis) == 0){
@@ -47,4 +48,4 @@ on({id: sourceDP, change: "any"}, async function (obj) {
setState(targetDP, cardChartString, true); setState(targetDP, cardChartString, true);
} }
}); });
}); });