From ecf08b060c4bdccd34049c0ca8840de389a4fb6b Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 24 Sep 2018 16:35:24 +0200 Subject: [PATCH] limit number of time series show in explore graph --- public/app/features/explore/Explore.tsx | 22 ++++++------ public/app/features/explore/Graph.tsx | 47 +++++++++++++++++++++---- public/sass/pages/_explore.scss | 19 ++++++++++ 3 files changed, 72 insertions(+), 16 deletions(-) diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index 187d68133cd..6b5c2ac9dd2 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -603,16 +603,18 @@ export class Explore extends React.Component {
- {supportsGraph && showingGraph ? ( - - ) : null} + {supportsGraph && + showingGraph && + graphResult && ( + + )} {supportsTable && showingTable ? ( ) : null} diff --git a/public/app/features/explore/Graph.tsx b/public/app/features/explore/Graph.tsx index 9243f612466..29167dcc4c4 100644 --- a/public/app/features/explore/Graph.tsx +++ b/public/app/features/explore/Graph.tsx @@ -67,6 +67,16 @@ const FLOT_OPTIONS = { }; class Graph extends Component { + state = { + showAllTimeSeries: false, + }; + + getGraphData() { + const { data } = this.props; + + return this.state.showAllTimeSeries ? data : data.slice(0, 20); + } + componentDidMount() { this.draw(); } @@ -82,8 +92,19 @@ class Graph extends Component { } } + onShowAllTimeSeries = () => { + this.setState( + { + showAllTimeSeries: true, + }, + this.draw + ); + }; + draw() { - const { data, options: userOptions } = this.props; + const { options: userOptions } = this.props; + const data = this.getGraphData(); + const $el = $(`#${this.props.id}`); if (!data) { $el.empty(); @@ -124,8 +145,10 @@ class Graph extends Component { } render() { - const { data, height, loading } = this.props; - if (!loading && data && data.length === 0) { + const { height, loading } = this.props; + const data = this.getGraphData(); + + if (!loading && data.length === 0) { return (
The queries returned no time series to graph.
@@ -133,9 +156,21 @@ class Graph extends Component { ); } return ( -
-
- +
+ {this.props.data.length > 20 && + !this.state.showAllTimeSeries && ( +
+ + Showing only 20 time series.{' '} + {`Show all ${ + this.props.data.length + }`} +
+ )} +
+
+ +
); } diff --git a/public/sass/pages/_explore.scss b/public/sass/pages/_explore.scss index 903193d8b10..c4a7da46263 100644 --- a/public/sass/pages/_explore.scss +++ b/public/sass/pages/_explore.scss @@ -55,6 +55,25 @@ margin-top: 2 * $panel-margin; } + .time-series-disclaimer { + width: 300px; + margin: 10px auto; + padding: 10px 0; + border-radius: 4px; + text-align: center; + background-color: #212124; + + .disclaimer-icon { + color: $yellow; + margin-right: 5px; + } + + .show-all-time-series { + cursor: pointer; + color: $external-link-color; + } + } + .elapsed-time { position: absolute; left: 0;