areaChart.stories.js 1.1 KB

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