|
|
@@ -1,13 +1,10 @@
|
|
|
-// Libraries
|
|
|
import _ from 'lodash';
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
|
|
-// Components
|
|
|
import Graph from 'app/viz/Graph';
|
|
|
-import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
|
|
|
import { Switch } from 'app/core/components/Switch/Switch';
|
|
|
|
|
|
-// Types
|
|
|
+import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
|
|
|
import { PanelProps, NullValueMode } from 'app/types';
|
|
|
|
|
|
interface Options {
|
|
|
@@ -18,9 +15,7 @@ interface Options {
|
|
|
onChange: (options: Options) => void;
|
|
|
}
|
|
|
|
|
|
-interface Props extends PanelProps {
|
|
|
- options: Options;
|
|
|
-}
|
|
|
+interface Props extends PanelProps<Options> {}
|
|
|
|
|
|
export class Graph2 extends PureComponent<Props> {
|
|
|
constructor(props) {
|
|
|
@@ -29,17 +24,26 @@ export class Graph2 extends PureComponent<Props> {
|
|
|
|
|
|
render() {
|
|
|
const { timeSeries, timeRange } = this.props;
|
|
|
+ const { showLines, showBars, showPoints } = this.props.options;
|
|
|
|
|
|
const vmSeries = getTimeSeriesVMs({
|
|
|
timeSeries: timeSeries,
|
|
|
nullValueMode: NullValueMode.Ignore,
|
|
|
});
|
|
|
|
|
|
- return <Graph timeSeries={vmSeries} timeRange={timeRange} />;
|
|
|
+ return (
|
|
|
+ <Graph
|
|
|
+ timeSeries={vmSeries}
|
|
|
+ timeRange={timeRange}
|
|
|
+ showLines={showLines}
|
|
|
+ showPoints={showPoints}
|
|
|
+ showBars={showBars}
|
|
|
+ />
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export class TextOptions extends PureComponent<Options> {
|
|
|
+export class GraphOptions extends PureComponent<Options> {
|
|
|
onToggleLines = () => {
|
|
|
const options = this.props as Options;
|
|
|
|
|
|
@@ -49,6 +53,15 @@ export class TextOptions extends PureComponent<Options> {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ onTogglePoints = () => {
|
|
|
+ const options = this.props as Options;
|
|
|
+
|
|
|
+ this.props.onChange({
|
|
|
+ ...options,
|
|
|
+ showPoints: !this.props.showPoints,
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
render() {
|
|
|
const { showBars, showPoints, showLines } = this.props;
|
|
|
|
|
|
@@ -58,11 +71,11 @@ export class TextOptions extends PureComponent<Options> {
|
|
|
<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.onToggleLines} />
|
|
|
- <Switch label="Points" labelClass="width-5" checked={showPoints} onChange={this.onToggleLines} />
|
|
|
+ <Switch label="Points" labelClass="width-5" checked={showPoints} onChange={this.onTogglePoints} />
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export { Graph2 as PanelComponent, TextOptions as PanelOptions };
|
|
|
+export { Graph2 as PanelComponent, GraphOptions as PanelOptionsComponent };
|