mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
limit number of time series show in explore graph
This commit is contained in:
parent
d07a3a7637
commit
ecf08b060c
@ -603,7 +603,9 @@ export class Explore extends React.Component<any, ExploreState> {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<main className="m-t-2">
|
<main className="m-t-2">
|
||||||
{supportsGraph && showingGraph ? (
|
{supportsGraph &&
|
||||||
|
showingGraph &&
|
||||||
|
graphResult && (
|
||||||
<Graph
|
<Graph
|
||||||
data={graphResult}
|
data={graphResult}
|
||||||
height={graphHeight}
|
height={graphHeight}
|
||||||
@ -612,7 +614,7 @@ export class Explore extends React.Component<any, ExploreState> {
|
|||||||
options={requestOptions}
|
options={requestOptions}
|
||||||
split={split}
|
split={split}
|
||||||
/>
|
/>
|
||||||
) : null}
|
)}
|
||||||
{supportsTable && showingTable ? (
|
{supportsTable && showingTable ? (
|
||||||
<Table className="m-t-3" data={tableResult} loading={loading} onClickCell={this.onClickTableCell} />
|
<Table className="m-t-3" data={tableResult} loading={loading} onClickCell={this.onClickTableCell} />
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -67,6 +67,16 @@ const FLOT_OPTIONS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Graph extends Component<any, any> {
|
class Graph extends Component<any, any> {
|
||||||
|
state = {
|
||||||
|
showAllTimeSeries: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
getGraphData() {
|
||||||
|
const { data } = this.props;
|
||||||
|
|
||||||
|
return this.state.showAllTimeSeries ? data : data.slice(0, 20);
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.draw();
|
this.draw();
|
||||||
}
|
}
|
||||||
@ -82,8 +92,19 @@ class Graph extends Component<any, any> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onShowAllTimeSeries = () => {
|
||||||
|
this.setState(
|
||||||
|
{
|
||||||
|
showAllTimeSeries: true,
|
||||||
|
},
|
||||||
|
this.draw
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
draw() {
|
draw() {
|
||||||
const { data, options: userOptions } = this.props;
|
const { options: userOptions } = this.props;
|
||||||
|
const data = this.getGraphData();
|
||||||
|
|
||||||
const $el = $(`#${this.props.id}`);
|
const $el = $(`#${this.props.id}`);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
$el.empty();
|
$el.empty();
|
||||||
@ -124,8 +145,10 @@ class Graph extends Component<any, any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { data, height, loading } = this.props;
|
const { height, loading } = this.props;
|
||||||
if (!loading && data && data.length === 0) {
|
const data = this.getGraphData();
|
||||||
|
|
||||||
|
if (!loading && data.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="panel-container">
|
<div className="panel-container">
|
||||||
<div className="muted m-a-1">The queries returned no time series to graph.</div>
|
<div className="muted m-a-1">The queries returned no time series to graph.</div>
|
||||||
@ -133,10 +156,22 @@ class Graph extends Component<any, any> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
|
{this.props.data.length > 20 &&
|
||||||
|
!this.state.showAllTimeSeries && (
|
||||||
|
<div className="time-series-disclaimer">
|
||||||
|
<i className="fa fa-fw fa-warning disclaimer-icon" />
|
||||||
|
Showing only 20 time series.{' '}
|
||||||
|
<span className="show-all-time-series" onClick={this.onShowAllTimeSeries}>{`Show all ${
|
||||||
|
this.props.data.length
|
||||||
|
}`}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="panel-container">
|
<div className="panel-container">
|
||||||
<div id={this.props.id} className="explore-graph" style={{ height }} />
|
<div id={this.props.id} className="explore-graph" style={{ height }} />
|
||||||
<Legend data={data} />
|
<Legend data={data} />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,25 @@
|
|||||||
margin-top: 2 * $panel-margin;
|
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 {
|
.elapsed-time {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user