ExploreGraphLabel.tsx 965 B

123456789101112131415161718192021222324252627282930313233
  1. import { css } from '@emotion/css';
  2. import React from 'react';
  3. import { SelectableValue } from '@grafana/data';
  4. import { RadioButtonGroup } from '@grafana/ui';
  5. import { EXPLORE_GRAPH_STYLES, ExploreGraphStyle } from '../../types';
  6. const ALL_GRAPH_STYLE_OPTIONS: Array<SelectableValue<ExploreGraphStyle>> = EXPLORE_GRAPH_STYLES.map((style) => ({
  7. value: style,
  8. // capital-case it and switch `_` to ` `
  9. label: style[0].toUpperCase() + style.slice(1).replace(/_/, ' '),
  10. }));
  11. const spacing = css({
  12. display: 'flex',
  13. justifyContent: 'space-between',
  14. });
  15. type Props = {
  16. graphStyle: ExploreGraphStyle;
  17. onChangeGraphStyle: (style: ExploreGraphStyle) => void;
  18. };
  19. export function ExploreGraphLabel(props: Props) {
  20. const { graphStyle, onChangeGraphStyle } = props;
  21. return (
  22. <div className={spacing}>
  23. Graph
  24. <RadioButtonGroup size="sm" options={ALL_GRAPH_STYLE_OPTIONS} value={graphStyle} onChange={onChangeGraphStyle} />
  25. </div>
  26. );
  27. }