The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/plugins/panel/graph2/module.tsx

76 lines
2.1 KiB

import _ from 'lodash';
import React, { PureComponent } from 'react';
import Graph from 'app/viz/Graph';
import { Switch } from 'app/core/components/Switch/Switch';
import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
import { PanelProps, PanelOptionsProps, NullValueMode } from 'app/types';
interface Options {
showBars: boolean;
showLines: boolean;
showPoints: boolean;
onChange: (options: Options) => void;
}
interface Props extends PanelProps<Options> {}
export class Graph2 extends PureComponent<Props> {
constructor(props) {
super(props);
}
render() {
const { timeSeries, timeRange } = this.props;
const { showLines, showBars, showPoints } = this.props.options;
7 years ago
const vmSeries = getTimeSeriesVMs({
timeSeries: timeSeries,
nullValueMode: NullValueMode.Ignore,
});
return (
<Graph
timeSeries={vmSeries}
timeRange={timeRange}
showLines={showLines}
showPoints={showPoints}
showBars={showBars}
/>
);
}
}
export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
onToggleLines = () => {
this.props.onChange({ showLines: !this.props.options.showLines, ...this.props.options });
};
onToggleBars = () => {
this.props.onChange({ showBars: !this.props.options.showBars, ...this.props.options });
};
onTogglePoints = () => {
this.props.onChange({ showPoints: !this.props.options.showPoints, ...this.props.options });
};
render() {
const { showBars, showPoints, showLines } = this.props.options;
return (
<div>
<div className="section gf-form-group">
<h5 className="page-heading">Draw Modes</h5>
<Switch label="Lines" labelClass="width-5" checked={showLines} onChange={this.onToggleLines} />
<Switch label="Bars" labelClass="width-5" checked={showBars} onChange={this.onToggleBars} />
<Switch label="Points" labelClass="width-5" checked={showPoints} onChange={this.onTogglePoints} />
</div>
</div>
);
}
}
export { Graph2 as PanelComponent, GraphOptions as PanelOptionsComponent };