Browse Source

[Fix 0000] 为可配置首页的图表组件兼容非数组数据以避免报错导致的不显示问题

houzekong 1 month ago
parent
commit
ad93677ca8

+ 4 - 1
src/views/vent/home/configurable/components/detail/CustomChart.vue

@@ -56,9 +56,12 @@
     // 该项作为下面所有图表依赖的基准系列数据
     const baseSeries: { name: string; data: [string, string][]; color: string }[] = sorttedData.reduce((res: any[], baseData) => {
       series.forEach((serie) => {
+        // 将读取出的数据转为数组
+        const temp = getData(baseData, serie.readFrom) || [];
+
         res.push({
           name: getFormattedText(baseData, serie.label),
-          data: (getData(baseData, serie.readFrom) || []).map((data) => {
+          data: (Array.isArray(temp) ? temp : [temp]).map((data) => {
             return [getData(data, serie.xprop), getData(data, serie.yprop)]; /** x y */
             // return { name: getData(data, serie.xprop), value: getData(data, serie.yprop) }; /** x y */
           }),