module.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import _ from 'lodash';
  2. import React, { PureComponent } from 'react';
  3. import Graph from 'app/viz/Graph';
  4. import { Switch } from 'app/core/components/Switch/Switch';
  5. import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
  6. import { PanelProps, PanelOptionsProps, NullValueMode } from 'app/types';
  7. interface Options {
  8. showBars: boolean;
  9. showLines: boolean;
  10. showPoints: boolean;
  11. }
  12. interface Props extends PanelProps<Options> {}
  13. export class Graph2 extends PureComponent<Props> {
  14. constructor(props) {
  15. super(props);
  16. }
  17. render() {
  18. const { timeSeries, timeRange, width, height } = this.props;
  19. const { showLines, showBars, showPoints } = this.props.options;
  20. const vmSeries = getTimeSeriesVMs({
  21. timeSeries: timeSeries,
  22. nullValueMode: NullValueMode.Ignore,
  23. });
  24. return (
  25. <Graph
  26. timeSeries={vmSeries}
  27. timeRange={timeRange}
  28. showLines={showLines}
  29. showPoints={showPoints}
  30. showBars={showBars}
  31. width={width}
  32. height={height}
  33. />
  34. );
  35. }
  36. }
  37. export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
  38. onToggleLines = () => {
  39. this.props.onChange({ ...this.props.options, showLines: !this.props.options.showLines });
  40. };
  41. onToggleBars = () => {
  42. this.props.onChange({ ...this.props.options, showBars: !this.props.options.showBars });
  43. };
  44. onTogglePoints = () => {
  45. this.props.onChange({ ...this.props.options, showPoints: !this.props.options.showPoints });
  46. };
  47. render() {
  48. const { showBars, showPoints, showLines } = this.props.options;
  49. return (
  50. <div>
  51. <div className="form-option-box">
  52. <div className="form-option-box__header">Display Options</div>
  53. <div className="section gf-form-group">
  54. <h5 className="section-heading">Draw Modes</h5>
  55. <Switch label="Lines" labelClass="width-5" checked={showLines} onChange={this.onToggleLines} />
  56. <Switch label="Bars" labelClass="width-5" checked={showBars} onChange={this.onToggleBars} />
  57. <Switch label="Points" labelClass="width-5" checked={showPoints} onChange={this.onTogglePoints} />
  58. </div>
  59. <div className="section gf-form-group">
  60. <h5 className="section-heading">Test Options</h5>
  61. <Switch label="Lines" labelClass="width-5" checked={showLines} onChange={this.onToggleLines} />
  62. <Switch label="Bars" labelClass="width-5" checked={showBars} onChange={this.onToggleBars} />
  63. <Switch label="Points" labelClass="width-5" checked={showPoints} onChange={this.onTogglePoints} />
  64. </div>
  65. </div>
  66. <div className="form-option-box">
  67. <div className="form-option-box__header">Axes</div>
  68. </div>
  69. <div className="form-option-box">
  70. <div className="form-option-box__header">Thresholds</div>
  71. </div>
  72. </div>
  73. );
  74. }
  75. }
  76. export { Graph2 as Panel, GraphOptions as PanelOptions };