miniBarChart.stories.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import {Fragment} from 'react';
  2. import MiniBarChart from 'sentry/components/charts/miniBarChart';
  3. import theme from 'sentry/utils/theme';
  4. export default {
  5. title: 'Components/Data Visualization/Charts/MiniBarChart',
  6. };
  7. export const _MiniBarChart = () => {
  8. const startTime = 1601992800;
  9. const interval = 3600;
  10. const all = [
  11. 0, 1, 2, 4, 9, 6, 17, 6, 25, 8, 23, 28, 19, 17, 17, 29, 11, 20, 15, 12, 19, 13, 1, 4,
  12. 0,
  13. ];
  14. const current = [
  15. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 0, 2, 0,
  16. ];
  17. return (
  18. <Fragment>
  19. <div className="section">
  20. <h2>Stacked MiniBarChart</h2>
  21. <h3>With markers as per issue details</h3>
  22. <MiniBarChart
  23. width={294}
  24. height={70}
  25. isGroupedByDate
  26. showTimeInTooltip
  27. series={[
  28. {
  29. seriesName: 'All environments',
  30. data: all.map((value, i) => ({
  31. name: (startTime + interval * i) * 1000,
  32. value,
  33. })),
  34. },
  35. {
  36. seriesName: 'Release abc123',
  37. data: current.map((value, i) => ({
  38. name: (startTime + interval * i) * 1000,
  39. value,
  40. })),
  41. },
  42. ]}
  43. markers={[
  44. {
  45. barGap: '-100%',
  46. name: 'First Seen',
  47. value: (startTime + interval) * 1000,
  48. color: theme.pink300,
  49. },
  50. {
  51. name: 'Last Seen',
  52. value: (startTime + interval * 23) * 1000,
  53. color: theme.green300,
  54. },
  55. ]}
  56. />
  57. </div>
  58. <div className="section">
  59. <h3>No markers and emphasis colors</h3>
  60. <MiniBarChart
  61. width={160}
  62. height={24}
  63. isGroupedByDate
  64. showTimeInTooltip
  65. emphasisColors={[theme.purple300]}
  66. series={[
  67. {
  68. seriesName: 'Events',
  69. data: all.map((value, i) => ({
  70. name: (startTime + interval * i) * 1000,
  71. value,
  72. })),
  73. },
  74. ]}
  75. />
  76. </div>
  77. <div className="section">
  78. <h3>With yAxis labels and stacked results</h3>
  79. <MiniBarChart
  80. height={150}
  81. labelYAxisExtents
  82. isGroupedByDate
  83. showTimeInTooltip
  84. stacked
  85. series={[
  86. {
  87. seriesName: 'Accepted',
  88. data: all.map((value, i) => ({
  89. name: (startTime + interval * i) * 1000,
  90. value,
  91. })),
  92. },
  93. {
  94. seriesName: 'Rejected',
  95. data: current.map((value, i) => ({
  96. name: (startTime + interval * i) * 1000,
  97. value,
  98. })),
  99. },
  100. ]}
  101. />
  102. </div>
  103. </Fragment>
  104. );
  105. };
  106. _MiniBarChart.storyName = 'MiniBarChart';