chart-utilities.stories.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import React from 'react';
  2. import {action} from '@storybook/addon-actions';
  3. import {withInfo} from '@storybook/addon-info';
  4. import {number, boolean, text} from '@storybook/addon-knobs';
  5. import ChartZoom from 'app/components/charts/chartZoom';
  6. import LineChart from 'app/components/charts/lineChart';
  7. export default {
  8. title: 'Charts/Utilities',
  9. };
  10. export const _ChartZoom = withInfo(`This is a strongly opinionated component that takes a render prop through "children".
  11. It requires the Global Selection Header and will update the date range selector when zooming. It also
  12. has specific behavior to control when the component should update, as well as opinions for
  13. the time interval to use.
  14. `)(() => (
  15. <div style={{backgroundColor: 'white', padding: 12}}>
  16. <ChartZoom onZoom={action('ChartZoom.onZoom')}>
  17. {zoomRenderProps => (
  18. <LineChart
  19. tooltip={{
  20. filter: value => value !== null,
  21. truncate: 80,
  22. }}
  23. {...zoomRenderProps}
  24. legend={{
  25. data: [
  26. text('Line 1 Legend (match Line 1)', 'sentry:user'),
  27. text('Line 2 Legend (match Line 2)', 'environment'),
  28. text('Line 3 Legend (match Line 3)', 'browser'),
  29. ],
  30. type: text('Legend Type', 'scroll'),
  31. }}
  32. height={number('height', 300)}
  33. grid={{
  34. top: text('grid:top', 40),
  35. bottom: text('grid:bottom', 20),
  36. left: text('grid:left', '10%'),
  37. right: text('grid:right', '10%'),
  38. containLabel: boolean('grid:containLabel', true),
  39. }}
  40. series={[
  41. {
  42. seriesName: text('Line 1', 'sentry:user'),
  43. data: [
  44. {value: 18, name: 1531094400000},
  45. {value: 31, name: 1531180800000},
  46. {value: 9, name: 1532070000000},
  47. {value: 100, name: 1532156400000},
  48. {value: 12, name: 1532242800000},
  49. ],
  50. },
  51. {
  52. seriesName: text('Line 2', 'environment'),
  53. data: [
  54. {value: 84, name: 1531094400000},
  55. {value: 1, name: 1531180800000},
  56. {value: 28, name: 1532070000000},
  57. {value: 1, name: 1532156400000},
  58. {value: 1, name: 1532242800000},
  59. ],
  60. },
  61. {
  62. seriesName: text('Line 3', 'browser'),
  63. data: [
  64. {value: 108, name: 1531094400000},
  65. {value: 1, name: 1531180800000},
  66. {value: 36, name: 1532070000000},
  67. {value: 0, name: 1532156400000},
  68. {value: 1, name: 1532242800000},
  69. ],
  70. },
  71. ]}
  72. />
  73. )}
  74. </ChartZoom>
  75. </div>
  76. ));