Ver código fonte

fix TimelineChart: deal with non-array data (#3385)

何乐 7 anos atrás
pai
commit
186abaca0b
1 arquivos alterados com 3 adições e 7 exclusões
  1. 3 7
      src/components/Charts/TimelineChart/index.js

+ 3 - 7
src/components/Charts/TimelineChart/index.js

@@ -17,15 +17,11 @@ class TimelineChart extends React.Component {
         y2: 'y2',
         y2: 'y2',
       },
       },
       borderWidth = 2,
       borderWidth = 2,
-      data = [
-        {
-          x: 0,
-          y1: 0,
-          y2: 0,
-        },
-      ],
+      data: sourceData,
     } = this.props;
     } = this.props;
 
 
+    const data = Array.isArray(sourceData) ? sourceData : [{ x: 0, y1: 0, y2: 0 }];
+
     data.sort((a, b) => a.x - b.x);
     data.sort((a, b) => a.x - b.x);
 
 
     let max;
     let max;