Skip to content

Commit

Permalink
adding default value for showValue
Browse files Browse the repository at this point in the history
  • Loading branch information
namnguyen20999 committed May 21, 2024
1 parent b4491d6 commit ccc9443
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions frontend/taipy-gui/src/components/Taipy/Metric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const defaultStyle = {position: "relative", display: "inline-block"};
const Metric = (props: MetricProps) => {
const {
width = "100%",
height
height,
showValue = true
} = props;
const value = useDynamicProperty(props.value, props.defaultValue, 0)
const threshold = useDynamicProperty(props.threshold, props.defaultThreshold, undefined)
Expand All @@ -72,7 +73,7 @@ const Metric = (props: MetricProps) => {
domain: {x: [0, 1], y: [0, 1]},
value: value,
type: "indicator",
mode: "gauge" + (props.showValue ? "+number" : "") + (delta !== undefined ? "+delta" : ""),
mode: "gauge" + (showValue ? "+number" : "") + (delta !== undefined ? "+delta" : ""),
delta: {
reference: typeof value === 'number' && typeof delta === 'number' ? value - delta : undefined,
},
Expand Down
2 changes: 1 addition & 1 deletion taipy/gui/_renderers/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,13 @@ class _Factory:
("layout", PropertyType.dynamic_dict),
("style", PropertyType.dynamic_dict),
("type", PropertyType.string, "circular"),
("show_value", PropertyType.boolean, True),
("min", PropertyType.number, 0),
("max", PropertyType.number, 100),
("delta", PropertyType.dynamic_number),
("threshold", PropertyType.dynamic_number),
("width", PropertyType.string_or_number),
("height", PropertyType.string_or_number),
("show_value", PropertyType.boolean, True),
]
),
"navbar": lambda gui, control_type, attrs: _Builder(
Expand Down

0 comments on commit ccc9443

Please sign in to comment.