Explorar el Código

no error when the column desc is undefined (#958) (#960)

* no error when the column desc is undefined
add a message to let the user know that he needs to bind data variables
resolves #466

* Fab's comments

---------

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
(cherry picked from commit 60017012eefd72bc667c5bea6dd823bdee1d86cd)

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide hace 1 año
padre
commit
48149ecedc

+ 8 - 6
frontend/taipy-gui/src/components/Taipy/Chart.tsx

@@ -85,9 +85,11 @@ const defaultStyle = { position: "relative", display: "inline-block" };
 const indexedData = /^(\d+)\/(.*)/;
 const indexedData = /^(\d+)\/(.*)/;
 
 
 const getColNameFromIndexed = (colName: string): string => {
 const getColNameFromIndexed = (colName: string): string => {
-    const reRes = indexedData.exec(colName);
-    if (reRes && reRes.length > 2) {
-        return reRes[2] || colName;
+    if (colName) {
+        const reRes = indexedData.exec(colName);
+        if (reRes && reRes.length > 2) {
+            return reRes[2] || colName;
+        }
     }
     }
     return colName;
     return colName;
 };
 };
@@ -324,14 +326,14 @@ const Chart = (props: ChartProp) => {
             xaxis: {
             xaxis: {
                 title:
                 title:
                     config.traces.length && config.traces[0].length && config.traces[0][0]
                     config.traces.length && config.traces[0].length && config.traces[0][0]
-                        ? getColNameFromIndexed(config.columns[config.traces[0][0]].dfid)
+                        ? getColNameFromIndexed(config.columns[config.traces[0][0]]?.dfid)
                         : undefined,
                         : undefined,
                 ...layout.xaxis,
                 ...layout.xaxis,
             },
             },
             yaxis: {
             yaxis: {
                 title:
                 title:
                     config.traces.length == 1 && config.traces[0].length > 1 && config.columns[config.traces[0][1]]
                     config.traces.length == 1 && config.traces[0].length > 1 && config.columns[config.traces[0][1]]
-                        ? getColNameFromIndexed(config.columns[config.traces[0][1]].dfid)
+                        ? getColNameFromIndexed(config.columns[config.traces[0][1]]?.dfid)
                         : undefined,
                         : undefined,
                 ...layout.yaxis,
                 ...layout.yaxis,
             },
             },
@@ -376,7 +378,7 @@ const Chart = (props: ChartProp) => {
                           getArrayValue(config.names, idx) ||
                           getArrayValue(config.names, idx) ||
                           (config.columns[trace[1]] ? getColNameFromIndexed(config.columns[trace[1]].dfid) : undefined),
                           (config.columns[trace[1]] ? getColNameFromIndexed(config.columns[trace[1]].dfid) : undefined),
                   } as Record<string, unknown>;
                   } as Record<string, unknown>;
-                  ret.marker = getArrayValue(config.markers, idx, ret.marker || {});
+                  ret.marker = {...getArrayValue(config.markers, idx, ret.marker || {})};
                   MARKER_TO_COL.forEach((prop) => {
                   MARKER_TO_COL.forEach((prop) => {
                       const val = (ret.marker as Record<string, unknown>)[prop];
                       const val = (ret.marker as Record<string, unknown>)[prop];
                       if (typeof val === "string") {
                       if (typeof val === "string") {

+ 2 - 0
taipy/gui/_renderers/builder.py

@@ -775,6 +775,8 @@ class _Builder:
                 else:
                 else:
                     self.__set_default_value(var_name, var_type=var_type)
                     self.__set_default_value(var_name, var_type=var_type)
         else:
         else:
+            if var_type == PropertyType.data:
+                _warn(f"{self.__control_type}.data property should be bound.")
             value = self.__attributes.get(var_name)
             value = self.__attributes.get(var_name)
             if value is not None:
             if value is not None:
                 if native_type:
                 if native_type: