chart-utilities.stories.js 2.5 KB

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