mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
Update CardChart_History.js
add const 'factor' for big value and negativ value on panel
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user