diff --git a/frontend/taipy-gui/public/stylekit/controls/metric.css b/frontend/taipy-gui/public/stylekit/controls/metric.css new file mode 100644 index 0000000000..5b00661b6e --- /dev/null +++ b/frontend/taipy-gui/public/stylekit/controls/metric.css @@ -0,0 +1,26 @@ +/* + * Copyright 2021-2024 Avaiga Private Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +/************************************************************** + + TAIPY METRIC + +***************************************************************/ + +/************************************************* + OVERRIDES / NORMALIZATION +**************************************************/ + +.taipy-metric { + max-width: 100%; +} diff --git a/frontend/taipy-gui/public/stylekit/stylekit.css b/frontend/taipy-gui/public/stylekit/stylekit.css index 604a7815b8..5e46a197d0 100644 --- a/frontend/taipy-gui/public/stylekit/stylekit.css +++ b/frontend/taipy-gui/public/stylekit/stylekit.css @@ -32,6 +32,7 @@ @import 'controls/expandable.css'; @import 'controls/image.css'; @import 'controls/input.css'; +@import 'controls/metric.css'; @import 'controls/navbar.css'; @import 'controls/number.css'; @import 'controls/slider.css'; diff --git a/frontend/taipy-gui/src/components/Taipy/Metric.tsx b/frontend/taipy-gui/src/components/Taipy/Metric.tsx index f65fc40a8a..daa544899f 100644 --- a/frontend/taipy-gui/src/components/Taipy/Metric.tsx +++ b/frontend/taipy-gui/src/components/Taipy/Metric.tsx @@ -29,6 +29,7 @@ import { } from "./utils"; import Box from "@mui/material/Box"; import Skeleton from "@mui/material/Skeleton"; +import Tooltip from "@mui/material/Tooltip"; const Plot = lazy(() => import("react-plotly.js")); @@ -67,13 +68,14 @@ const Metric = (props: MetricProps) => { const className = useClassNames(props.libClassName, props.dynamicClassName, props.className); const baseLayout = useDynamicJsonProperty(props.layout, props.defaultLayout || "", emptyLayout); const baseStyle = useDynamicJsonProperty(props.style, props.defaultStyle || "", defaultStyle); + const hover = useDynamicProperty(props.hoverText, props.defaultHoverText, undefined); const data = useMemo(() => ([ { domain: {x: [0, 1], y: [0, 1]}, value: value, type: "indicator", - mode: "gauge" + (showValue ? "+number" : "") + (delta !== undefined ? "+delta" : ""), + mode: "gauge" + (showValue ? "+number" : "") + (delta !== undefined ? "+delta" : ""), delta: { reference: typeof value === 'number' && typeof delta === 'number' ? value - delta : undefined, }, @@ -114,13 +116,15 @@ const Metric = (props: MetricProps) => { return ( - }> - - + + }> + + + ); }