areaChart.stories.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React from 'react';
  2. import {withInfo} from '@storybook/addon-info';
  3. import AreaChart from 'app/components/charts/areaChart';
  4. export default {
  5. title: 'Charts/AreaChart',
  6. };
  7. export const _AreaChart = withInfo('Stacked AreaChart with previous period')(() => {
  8. const TOTAL = 6;
  9. const NOW = new Date().getTime();
  10. const getValue = () => Math.round(Math.random() * 1000);
  11. const getDate = num => NOW - (TOTAL - num) * 86400000;
  12. const getData = num =>
  13. [...Array(num)].map((_v, i) => ({value: getValue(), name: getDate(i)}));
  14. return (
  15. <div>
  16. <AreaChart
  17. style={{height: 250}}
  18. series={[
  19. {
  20. seriesName: 'Handled',
  21. data: getData(7),
  22. },
  23. {
  24. seriesName: 'Unhandled',
  25. data: getData(7),
  26. },
  27. ]}
  28. previousPeriod={[
  29. {
  30. seriesName: 'Previous',
  31. data: getData(7),
  32. },
  33. ]}
  34. />
  35. </div>
  36. );
  37. });
  38. _AreaChart.story = {
  39. name: 'AreaChart',
  40. };