Skip to content

metric class

A control that provides a visualization for a specific metric.

Methods

__init__()

__init__(
    value=None,
    type="circular",
    min=0,
    max=100,
    delta=None,
    delta_color=None,
    title=None,
    negative_delta_color=None,
    threshold=None,
    show_value=True,
    format=None,
    delta_format=None,
    bar_color=None,
    color_map=None,
    width="20vw",
    height="20vh",
    layout=None,
    template=None,
    id=None,
    properties=None,
    class_name=None,
    hover_text=None,
) -> None

Create a new metric element.

Parameters:

Name Type Description Default
value dynamic(Union[int, float])

The value to represent.

None
type str

The type of the gauge.
Possible values are:

  • "none"
  • "circular"
  • "linear"
Setting this value to "none" remove the gauge.

circular
min Union[int, float]

The minimum value of the metric control's gauge.

0
max Union[int, float]

The maximum value of the metric control's gauge.

100
delta dynamic(Union[int, float])

The delta value to display.

None
delta_color str

The color that is used to display the value of the delta property.
If negative_delta_color is set, then this property applies for positive values of delta only.
If this property is set to "invert", then values for delta are represented with the color used for negative values if delta is positive and delta is represented with the color used for positive values if it is negative.

None
title str

The title of the metric.

None
negative_delta_color str

If set, this represents the color to be used when the value of delta is negative (or positive if delta_color is set to "invert").

None
threshold dynamic(Union[int, float])

The threshold value to display.

None
show_value bool

If set to False, the value is not displayed.

True
format str

The format to use when displaying the value.
This uses the printf syntax.

None
delta_format str

The format to use when displaying the delta value.
This uses the printf syntax.

None
bar_color str

The color of the bar in the gauge.

None
color_map dict

Indicates what colors should be used for different ranges of the metric. The color_map's keys represent the lower bound of each range, which is a number, while the values represent the color for that range.
If the value associated with a key is set to None, the corresponding range is not assigned any color.

None
width Union[str, int, float]

The width of the metric control, in CSS units

20vw
height Union[str, int, float]

The height of the metric control, in CSS units

20vh
layout dynamic(dict[str, Any])

The plotly.js compatible layout object.

None
template dict

The Plotly layout template.

None
id str

The identifier assigned to the rendered HTML component.
This can be used in callbacks or to target the element for styling.

None
properties dict[str, Any]

A dictionary of additional properties that can be set to the element.

None
class_name dynamic(str)

A space-separated list of CSS class names to be applied to the generated HTML element.
These classes are added to the default taipy-metric class.

None
hover_text dynamic(str)

The text that is displayed when the user hovers over the element.

None