mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Sort tooltips in energy graphs and filter zeros (#17057)
This commit is contained in:
parent
ce9380e4d7
commit
5ac9a6c9cc
@ -217,6 +217,10 @@ export class HuiEnergyGasGraphCard
|
|||||||
plugins: {
|
plugins: {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
position: "nearest",
|
position: "nearest",
|
||||||
|
filter: (val) => val.formattedValue !== "0",
|
||||||
|
itemSort: function (a, b) {
|
||||||
|
return b.datasetIndex - a.datasetIndex;
|
||||||
|
},
|
||||||
callbacks: {
|
callbacks: {
|
||||||
title: (datasets) => {
|
title: (datasets) => {
|
||||||
if (dayDifference > 0) {
|
if (dayDifference > 0) {
|
||||||
|
@ -213,6 +213,10 @@ export class HuiEnergySolarGraphCard
|
|||||||
plugins: {
|
plugins: {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
position: "nearest",
|
position: "nearest",
|
||||||
|
filter: (val) => val.formattedValue !== "0",
|
||||||
|
itemSort: function (a, b) {
|
||||||
|
return b.datasetIndex - a.datasetIndex;
|
||||||
|
},
|
||||||
callbacks: {
|
callbacks: {
|
||||||
title: (datasets) => {
|
title: (datasets) => {
|
||||||
if (dayDifference > 0) {
|
if (dayDifference > 0) {
|
||||||
|
@ -209,6 +209,18 @@ export class HuiEnergyUsageGraphCard
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
position: "nearest",
|
position: "nearest",
|
||||||
filter: (val) => val.formattedValue !== "0",
|
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: {
|
callbacks: {
|
||||||
title: (datasets) => {
|
title: (datasets) => {
|
||||||
if (dayDifference > 0) {
|
if (dayDifference > 0) {
|
||||||
|
@ -217,6 +217,10 @@ export class HuiEnergyWaterGraphCard
|
|||||||
plugins: {
|
plugins: {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
position: "nearest",
|
position: "nearest",
|
||||||
|
filter: (val) => val.formattedValue !== "0",
|
||||||
|
itemSort: function (a, b) {
|
||||||
|
return b.datasetIndex - a.datasetIndex;
|
||||||
|
},
|
||||||
callbacks: {
|
callbacks: {
|
||||||
title: (datasets) => {
|
title: (datasets) => {
|
||||||
if (dayDifference > 0) {
|
if (dayDifference > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user