Sort tooltips in energy graphs and filter zeros (#17057)

This commit is contained in:
karwosts 2023-06-28 05:00:10 -07:00 committed by GitHub
parent ce9380e4d7
commit 5ac9a6c9cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 0 deletions

View File

@ -217,6 +217,10 @@ export class HuiEnergyGasGraphCard
plugins: {
tooltip: {
position: "nearest",
filter: (val) => val.formattedValue !== "0",
itemSort: function (a, b) {
return b.datasetIndex - a.datasetIndex;
},
callbacks: {
title: (datasets) => {
if (dayDifference > 0) {

View File

@ -213,6 +213,10 @@ export class HuiEnergySolarGraphCard
plugins: {
tooltip: {
position: "nearest",
filter: (val) => val.formattedValue !== "0",
itemSort: function (a, b) {
return b.datasetIndex - a.datasetIndex;
},
callbacks: {
title: (datasets) => {
if (dayDifference > 0) {

View File

@ -209,6 +209,18 @@ export class HuiEnergyUsageGraphCard
tooltip: {
position: "nearest",
filter: (val) => val.formattedValue !== "0",
itemSort: function (a: any, b: any) {
if (a.raw?.y > 0 && b.raw?.y < 0) {
return -1;
}
if (b.raw?.y > 0 && a.raw?.y < 0) {
return 1;
}
if (a.raw?.y > 0) {
return b.datasetIndex - a.datasetIndex;
}
return a.datasetIndex - b.datasetIndex;
},
callbacks: {
title: (datasets) => {
if (dayDifference > 0) {

View File

@ -217,6 +217,10 @@ export class HuiEnergyWaterGraphCard
plugins: {
tooltip: {
position: "nearest",
filter: (val) => val.formattedValue !== "0",
itemSort: function (a, b) {
return b.datasetIndex - a.datasetIndex;
},
callbacks: {
title: (datasets) => {
if (dayDifference > 0) {