From d04c138e1204263d393a73e11c2574c1bc61fef2 Mon Sep 17 00:00:00 2001 From: nikogu <644506165@qq.com> Date: Thu, 9 Nov 2017 16:11:03 +0800 Subject: [PATCH] Fixed: https://github.com/ant-design/ant-design-pro/issues/130 --- src/components/Charts/TimelineChart/index.js | 8 ++++++++ src/components/Charts/demo/timeline-chart.md | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Charts/TimelineChart/index.js b/src/components/Charts/TimelineChart/index.js index 242d2871..65048b85 100644 --- a/src/components/Charts/TimelineChart/index.js +++ b/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, }, }); diff --git a/src/components/Charts/demo/timeline-chart.md b/src/components/Charts/demo/timeline-chart.md index d22c2fd9..60773b57 100644 --- a/src/components/Charts/demo/timeline-chart.md +++ b/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, }); } -- GitLab