Open howi42 opened 9 months ago
Same as closed https://github.com/kalkih/mini-graph-card/issues/774
Regardless the state of this issue, the user interface does not look good with this. And , I have not found any settings combination ( language, number format, data format ), which at the end use the same style for numbers.
Up up up
Would be really nice to get this fixed, it looks a bit strange with different number formats on the dash.
This should be treated as a bug, not an enhancement.
Up
No need to "up" here. It only makes sense to prevent "stale". Using "upping" to force someone to implement the feature is inappropriate.
Can you please label this as "bug"? This is not an enhc.
I also agree this is not an enhancement but a bug.
I can set here "bug", but it may not "speed up" implementation... So, 2 labels - enhancement & bug - everyone is happy))))
I found my solution. For those want to use "." as thousand seperator and "," for decimals. I am not a developer so I couldnt do it more generic way but It works anyway
VSCode and copy the entire js code: "/config/www/community/mini-graph-card/mini-graph-card-bundle.js"
https://beautifier.io/ and beuatify the code. Copy it and paste back into the file "/config/www/community/mini-graph-card/mini-graph-card-bundle.js"
delete the ".gz" file: /config/www/community/mini-graph-card/mini-graph-card-bundle.js.gz
edit dashboard -> manage resources: delete all lines related with "graph" and relink one of them as "local/community/mini-graph-card/mini-graph-card-bundle.js"
go VScode and find the line
numberFormat(a, b, c) {
return !O(+a) && Intl ? new Intl.NumberFormat(b, {
minimumFractionDigits: c
}).format(+a) : a.toString()
}
change it with the code below. I prefered Turkish. So now my numbers are now formatted like 1.233.444,89 and I am still using HA in English.
numberFormat(a, b, c) {
if (!isNaN(+a)) {
const formattedNumber = (+a).toLocaleString('tr-TR', {
minimumFractionDigits: c
});
return formattedNumber;
} else {
return a.toString();
}
}
I can set here "bug", but it may not "speed up" implementation... So, 2 labels - enhancement & bug - everyone is happy))))
Maybe My last suggestion speed it up ;)
Not really, cat. The addon should be following the Home Assistant defined settings on the Number Format specifically and not just use the default number format of the language chosen for the HA UI. And also not one random language format. For example, I have HA UI language set to "English", but the Number format to "None" because I can not stand having extra thousand separator symbols. It works (almost) everywhere in HA, but this addon just ignores the very explicit Number format setting and instead tries to guess the number format from the UI language, which is a bug.
Not really, cat. The addon should be following the Home Assistant defined settings on the Number Format specifically and not just use the default number format of the language chosen for the HA UI. And also not one random language format. For example, I have HA UI language set to "English", but the Number format to "None" because I can not stand having extra thousand separator symbols. It works (almost) everywhere in HA, but this addon just ignores the very explicit Number format setting and instead tries to guess the number format from the UI language, which is a bug.
Sure, but I at least some of us get what they need. Agree for the rest
I wonder if https://github.com/home-assistant/frontend/pull/17249 can be used to get HA to format the values correctly.
May be I am missing something, see no need to connect “number format” and “language”, imho these are independent settings.
Yes, they are. Currently the code in mini-graph-card just uses "language" setting and then asks an external library to format numbers (and dates) in accordance to the rules of that language. And completely ignores the HA settings for number format and date format.
And in HA itself there are some “connections” between a language and a number format - which makes a code more complex and buggy.
There are indeed, like if I click on a value I get this wonderful screen:
That screen has both correct number formatting preference (None) in the number display location (top right, "1078 ppm"), but at the same time chooses to use the language numbering preference for the Y axis ("2,000")
The second is a bug.
What happens if you start playing with a language, will it affect mini-graph?
Yes, switching from "English" to German, for example, would change the decimal separator from "." to "," and the thousand separator from "," to ".". And switching language to Esperanto would change the thousand separator to " " and decimal separator to ",".
The code in https://github.com/kalkih/mini-graph-card/blob/master/src/main.js#L720 literally just gives the value to the browser function Intl.NumberFormat along with the currently configured system language.
https://developers.home-assistant.io/docs/frontend/data/#hassformatentityattributevaluestateobj-attribute-value describes the function that is there to format the value correctly, according to settings of both HA and of the entity itself (like you can set precision on the entity). It is available to mini-graph-card.
@ildar170975 @kalkih Any development to current issue ? No updates from Feb 20, is this still considered for implementation ?
the number format, as defined in the profile settings, is not honored.