mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
show all colums in graph
This commit is contained in:
parent
e7a6041d22
commit
0558b17b9e
@ -149,6 +149,16 @@ function convertTimeSeriesToTableData(timeSeries: TimeSeries): TableData {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getFirstTimeColumn = (table: TableData): number => {
|
||||||
|
const { columns } = table;
|
||||||
|
for (let i = 0; i < columns.length; i++) {
|
||||||
|
if (columns[i].type === ColumnType.time) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns a table Returns a copy of the table with the best guess for each column type
|
* @returns a table Returns a copy of the table with the best guess for each column type
|
||||||
*/
|
*/
|
||||||
|
@ -2,14 +2,17 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
|
||||||
// Utils
|
import {
|
||||||
import { processTimeSeries } from '@grafana/ui/src/utils';
|
Graph,
|
||||||
|
PanelProps,
|
||||||
// Components
|
NullValueMode,
|
||||||
import { Graph } from '@grafana/ui';
|
colors,
|
||||||
|
TimeSeriesVMs,
|
||||||
// Types
|
ColumnType,
|
||||||
import { PanelProps, NullValueMode, TimeSeriesVMs } from '@grafana/ui/src/types';
|
guessColumnTypes,
|
||||||
|
getFirstTimeColumn,
|
||||||
|
processTimeSeries,
|
||||||
|
} from '@grafana/ui';
|
||||||
import { Options } from './types';
|
import { Options } from './types';
|
||||||
|
|
||||||
interface Props extends PanelProps<Options> {}
|
interface Props extends PanelProps<Options> {}
|
||||||
@ -19,12 +22,29 @@ export class GraphPanel extends PureComponent<Props> {
|
|||||||
const { data, timeRange, width, height } = this.props;
|
const { data, timeRange, width, height } = this.props;
|
||||||
const { showLines, showBars, showPoints } = this.props.options;
|
const { showLines, showBars, showPoints } = this.props.options;
|
||||||
|
|
||||||
let vmSeries: TimeSeriesVMs;
|
const vmSeries: TimeSeriesVMs = [];
|
||||||
if (data) {
|
for (let t = 0; t < data.length; t++) {
|
||||||
vmSeries = processTimeSeries({
|
const table = guessColumnTypes(data[t]);
|
||||||
data,
|
const timeColumn = getFirstTimeColumn(table);
|
||||||
nullValueMode: NullValueMode.Ignore,
|
if (timeColumn >= 0) {
|
||||||
});
|
for (let i = 0; i < table.columns.length; i++) {
|
||||||
|
const column = table.columns[i];
|
||||||
|
|
||||||
|
// Show all numeric columns
|
||||||
|
if (column.type === ColumnType.number) {
|
||||||
|
const tsvm = processTimeSeries({
|
||||||
|
data: [table],
|
||||||
|
xColumn: timeColumn,
|
||||||
|
yColumn: i,
|
||||||
|
nullValueMode: NullValueMode.Null,
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
const colorIndex = vmSeries.length % colors.length;
|
||||||
|
tsvm.color = colors[colorIndex];
|
||||||
|
vmSeries.push(tsvm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user