소스 검색

Fixed: https://github.com/ant-design/ant-design-pro/issues/130

nikogu 8 년 전
부모
커밋
d04c138e12
2개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 0
      src/components/Charts/TimelineChart/index.js
  2. 1 1
      src/components/Charts/demo/timeline-chart.md

+ 8 - 0
src/components/Charts/TimelineChart/index.js

@@ -64,6 +64,12 @@ class TimelineChart extends Component {
       position: 'top',
     });
 
+    let max;
+    if (data[0] && data[0].y1 && data[0].y2) {
+      max = Math.max(data.sort((a, b) => b.y1 - a.y1)[0].y1,
+        data.sort((a, b) => b.y2 - a.y2)[0].y2);
+    }
+
     chart.source(data, {
       x: {
         type: 'timeCat',
@@ -73,10 +79,12 @@ class TimelineChart extends Component {
       },
       y1: {
         alias: titleMap.y1,
+        max,
         min: 0,
       },
       y2: {
         alias: titleMap.y2,
+        max,
         min: 0,
       },
     });

+ 1 - 1
src/components/Charts/demo/timeline-chart.md

@@ -12,7 +12,7 @@ const chartData = [];
 for (let i = 0; i < 20; i += 1) {
   chartData.push({
     x: (new Date().getTime()) + (1000 * 60 * 30 * i),
-    y1: Math.floor(Math.random() * 100) + 10,
+    y1: Math.floor(Math.random() * 100) + 1000,
     y2: Math.floor(Math.random() * 100) + 10,
   });
 }