diff --git a/src/components/Charts/TimelineChart/index.js b/src/components/Charts/TimelineChart/index.js index 242d287148a759d0196d3f0170feb06815f49c31..65048b856af5a469d5df5076de640f17d6f96d37 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 d22c2fd96eb3253cce26194090137e5576f0a1bf..60773b575f84ce50b401a599da03c93bc7fefec2 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, }); }