zmiana kolorow wykresow
This commit is contained in:
11
app.py
11
app.py
@@ -796,16 +796,11 @@ def get_admin_expense_summary():
|
||||
"""
|
||||
|
||||
def category_to_color(name):
|
||||
# Hashuj nazwę kategorii, aby uzyskać deterministyczną barwę
|
||||
hash_val = int(hashlib.md5(name.encode("utf-8")).hexdigest(), 16)
|
||||
# Ustal odcień (hue) — pseudo-losowo, ale unikalnie dla każdej nazwy
|
||||
hue = (hash_val % 360) / 360.0 # 0..1
|
||||
# Wysoka saturacja (nasycenie, żeby kolor był wyrazisty, nie pastelowy)
|
||||
saturation = 0.75 + ((hash_val >> 8) % 20) / 100.0 # 0.75 - 0.95
|
||||
# Średnia jasność — nie za jasno, by nie kontrastować z białym tekstem, ale wyraźnie na ciemnym tle
|
||||
lightness = 0.40 + ((hash_val >> 16) % 15) / 100.0 # 0.40 - 0.55
|
||||
hue = (hash_val % 360) / 360.0
|
||||
saturation = 0.60 + ((hash_val >> 8) % 17) / 100.0
|
||||
lightness = 0.28 + ((hash_val >> 16) % 11) / 100.0
|
||||
|
||||
# Zamiana HLS → RGB
|
||||
r, g, b = colorsys.hls_to_rgb(hue, lightness, saturation)
|
||||
return f"#{int(r*255):02x}{int(g*255):02x}{int(b*255):02x}"
|
||||
|
||||
|
Reference in New Issue
Block a user