mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: React Graph & Show message on no data (#16278)
This commit is contained in:
parent
9fd824960f
commit
236074ea47
@ -14,36 +14,46 @@ export class GraphPanel extends PureComponent<Props> {
|
|||||||
const { showLines, showBars, showPoints } = this.props.options;
|
const { showLines, showBars, showPoints } = this.props.options;
|
||||||
|
|
||||||
const graphs: GraphSeriesXY[] = [];
|
const graphs: GraphSeriesXY[] = [];
|
||||||
for (const series of data) {
|
if (data) {
|
||||||
const timeColumn = getFirstTimeField(series);
|
for (const series of data) {
|
||||||
if (timeColumn < 0) {
|
const timeColumn = getFirstTimeField(series);
|
||||||
continue;
|
if (timeColumn < 0) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < series.fields.length; i++) {
|
for (let i = 0; i < series.fields.length; i++) {
|
||||||
const field = series.fields[i];
|
const field = series.fields[i];
|
||||||
|
|
||||||
// Show all numeric columns
|
// Show all numeric columns
|
||||||
if (field.type === FieldType.number) {
|
if (field.type === FieldType.number) {
|
||||||
// Use external calculator just to make sure it works :)
|
// Use external calculator just to make sure it works :)
|
||||||
const points = getFlotPairs({
|
const points = getFlotPairs({
|
||||||
series,
|
series,
|
||||||
xIndex: timeColumn,
|
xIndex: timeColumn,
|
||||||
yIndex: i,
|
yIndex: i,
|
||||||
nullValueMode: NullValueMode.Null,
|
nullValueMode: NullValueMode.Null,
|
||||||
});
|
|
||||||
|
|
||||||
if (points.length > 0) {
|
|
||||||
graphs.push({
|
|
||||||
label: field.name,
|
|
||||||
data: points,
|
|
||||||
color: colors[graphs.length % colors.length],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (points.length > 0) {
|
||||||
|
graphs.push({
|
||||||
|
label: field.name,
|
||||||
|
data: points,
|
||||||
|
color: colors[graphs.length % colors.length],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (graphs.length < 1) {
|
||||||
|
return (
|
||||||
|
<div className="panel-empty">
|
||||||
|
<p>No data found in response</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Graph
|
<Graph
|
||||||
series={graphs}
|
series={graphs}
|
||||||
|
Loading…
Reference in New Issue
Block a user