duongthienz commited on
Commit
df36e80
·
verified ·
1 Parent(s): 68a3d08

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +7 -4
utils.py CHANGED
@@ -75,12 +75,15 @@ def _load_palette(path="plotly_colorwheel.txt"):
75
  if not line or line.startswith("#"):
76
  continue
77
  parts = [p.strip() for p in line.split(",")]
78
- if len(parts) < 4:
79
- continue
80
  try:
81
  idx = int(parts[0])
82
- hex_color = parts[3]
83
- if hex_color.startswith("#"):
 
 
 
 
 
84
  entries[idx] = hex_color
85
  except ValueError:
86
  continue
 
75
  if not line or line.startswith("#"):
76
  continue
77
  parts = [p.strip() for p in line.split(",")]
 
 
78
  try:
79
  idx = int(parts[0])
80
+ # Support both formats:
81
+ # id, color, shade, hex (4 columns, hex at index 3)
82
+ # id, color_name, hex (3 columns, hex at index 2)
83
+ hex_color = next(
84
+ (p for p in reversed(parts) if p.startswith("#")), None
85
+ )
86
+ if hex_color:
87
  entries[idx] = hex_color
88
  except ValueError:
89
  continue