Skip to content

Commit

Permalink
fix small minor issue
Browse files Browse the repository at this point in the history
  • Loading branch information
namnguyen20999 committed Jun 17, 2024
1 parent a870d68 commit 5f6de86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions doc/gui/examples/controls/metric-color-map.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

# color_map definition:
# - A dictionary mapping metric values to display colors.
# - Keys: Starting point of each range (number)
# - Values: Corresponding color for that range (None implies no color assignment)
# Example:
# - 20.5 maps to "#fd2020"
# - 40 maps to None (default color)
# - 60 maps to "#f3ff26"
# - 80 maps to None
# color_map = {
# # 0-20 - Let Taipy decide
# # 20-40 - red
# 20: "red",
# # 40-60 - Let Taipy decide
# 40: None,
# # 60-80 - blue
# 60: "blue",
# # 80-100 - Let Taipy decide
# 80: None
# }

value = 50
color_map = {
20.5: "#fd2020",
20: "red",
40: None,
60: "#f3ff26",
60: "blue",
80: None
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/src/components/Taipy/Metric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Metric = (props: MetricProps) => {
return keys.sort((a, b) => Number(a) - Number(b)).map((key, index) => {
const nextKey = keys[index + 1] !== undefined ? Number(keys[index + 1]) : props.max || 100;
return {range: [Number(key), nextKey], color: obj[key]};
}).filter(item => item !== null && item.color !== null)
}).filter(item => item.color !== null)
}
} catch (e) {
console.info(`Error parsing color_map value (metric).\n${(e as Error).message || e}`);
Expand Down

0 comments on commit 5f6de86

Please sign in to comment.