chart-utilities.stories.js 2.5 KB

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