namnguyen 1 anno fa
parent
commit
762cae355c

+ 26 - 0
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%;
+}

+ 3 - 1
frontend/taipy-gui/src/utils/formatConversion.ts

@@ -75,7 +75,7 @@ export const sprintfToD3Converter = (fmt?: string): string => {
         placeholderValue = (sprintf_fmt_arr[objectIndex] as { placeholder: string }).placeholder;
     }
 
-    if (placeholderValue === undefined) {
+    if (!placeholderValue) {
         return "";
     }
 
@@ -106,6 +106,7 @@ export const sprintfToD3Converter = (fmt?: string): string => {
  * a string that represents the prefix of the format string. If no format string is provided, it returns an empty string.
  */
 export const extractPrefix = (fmt?: string): string => {
+    if (!fmt) return "";
     const sprintf_fmt_arr = sprintfParse(fmt);
     const objectIndex = sprintf_fmt_arr.findIndex((element) => typeof element === 'object');
     return sprintf_fmt_arr.slice(0, objectIndex).join('');
@@ -116,6 +117,7 @@ export const extractPrefix = (fmt?: string): string => {
  * a string that represents the suffix of the format string. If no format string is provided, it returns an empty string.
  */
 export const extractSuffix = (fmt?: string): string => {
+    if (!fmt) return "";
     const sprintf_fmt_arr = sprintfParse(fmt);
     const objectIndex = sprintf_fmt_arr.findIndex((element) => typeof element === 'object');
     return sprintf_fmt_arr.slice(objectIndex + 1).join('');