From 186abaca0bcc2e57768ea48c276b803a83b1df81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E4=B9=90?= Date: Tue, 15 Jan 2019 16:39:46 +0800 Subject: [PATCH] fix TimelineChart: deal with non-array data (#3385) --- src/components/Charts/TimelineChart/index.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/Charts/TimelineChart/index.js b/src/components/Charts/TimelineChart/index.js index b76e782f..d82623c5 100644 --- a/src/components/Charts/TimelineChart/index.js +++ b/src/components/Charts/TimelineChart/index.js @@ -17,15 +17,11 @@ class TimelineChart extends React.Component { y2: 'y2', }, borderWidth = 2, - data = [ - { - x: 0, - y1: 0, - y2: 0, - }, - ], + data: sourceData, } = this.props; + const data = Array.isArray(sourceData) ? sourceData : [{ x: 0, y1: 0, y2: 0 }]; + data.sort((a, b) => a.x - b.x); let max; -- GitLab