GraphOptions.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //// Libraries
  2. import _ from 'lodash';
  3. import React, { PureComponent } from 'react';
  4. // Components
  5. import { Switch } from 'app/core/components/Switch/Switch';
  6. // Types
  7. import { PanelOptionsProps } from '@grafana/ui';
  8. import { Options } from './types';
  9. export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
  10. onToggleLines = () => {
  11. this.props.onChange({ ...this.props.options, showLines: !this.props.options.showLines });
  12. };
  13. onToggleBars = () => {
  14. this.props.onChange({ ...this.props.options, showBars: !this.props.options.showBars });
  15. };
  16. onTogglePoints = () => {
  17. this.props.onChange({ ...this.props.options, showPoints: !this.props.options.showPoints });
  18. };
  19. render() {
  20. const { showBars, showPoints, showLines } = this.props.options;
  21. return (
  22. <div>
  23. <div className="section gf-form-group">
  24. <h5 className="section-heading">Draw Modes</h5>
  25. <Switch label="Lines" labelClass="width-5" checked={showLines} onChange={this.onToggleLines} />
  26. <Switch label="Bars" labelClass="width-5" checked={showBars} onChange={this.onToggleBars} />
  27. <Switch label="Points" labelClass="width-5" checked={showPoints} onChange={this.onTogglePoints} />
  28. </div>
  29. <div className="section gf-form-group">
  30. <h5 className="section-heading">Test Options</h5>
  31. <Switch label="Lines" labelClass="width-5" checked={showLines} onChange={this.onToggleLines} />
  32. <Switch label="Bars" labelClass="width-5" checked={showBars} onChange={this.onToggleBars} />
  33. <Switch label="Points" labelClass="width-5" checked={showPoints} onChange={this.onTogglePoints} />
  34. </div>
  35. </div>
  36. );
  37. }
  38. }