areaChart.stories.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import styled from '@emotion/styled';
  2. import {AreaChart} from 'sentry/components/charts/areaChart';
  3. import space from 'sentry/styles/space';
  4. export default {
  5. title: 'Components/Data Visualization/Charts/Area Chart',
  6. component: AreaChart,
  7. parameters: {
  8. controls: {hideNoControlsWarning: true},
  9. },
  10. };
  11. export const _AreaChart = () => {
  12. const TOTAL = 6;
  13. const NOW = new Date().getTime();
  14. const getValue = () => Math.round(Math.random() * 1000);
  15. const getDate = num => NOW - (TOTAL - num) * 86400000;
  16. const getData = num =>
  17. [...Array(num)].map((_v, i) => ({value: getValue(), name: getDate(i)}));
  18. return (
  19. <Container>
  20. <AreaChart
  21. style={{height: 250}}
  22. series={[
  23. {
  24. seriesName: 'Handled',
  25. data: getData(7),
  26. },
  27. {
  28. seriesName: 'Unhandled',
  29. data: getData(7),
  30. },
  31. ]}
  32. previousPeriod={[
  33. {
  34. seriesName: 'Previous',
  35. data: getData(7),
  36. },
  37. ]}
  38. />
  39. </Container>
  40. );
  41. };
  42. _AreaChart.storyName = 'Area Chart';
  43. _AreaChart.parameters = {
  44. docs: {
  45. description: {
  46. story: 'Stacked AreaChart with previous period',
  47. },
  48. },
  49. };
  50. const Container = styled('div')`
  51. padding: 100px ${space(2)} 0;
  52. `;