charts.stories.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import React from 'react';
  2. import {storiesOf} from '@storybook/react';
  3. import {withInfo} from '@storybook/addon-info';
  4. import {number, boolean, text} from '@storybook/addon-knobs';
  5. import LineChart from 'app/components/charts/lineChart';
  6. import BarChart from 'app/components/charts/barChart';
  7. storiesOf('Charts|Playground')
  8. .add(
  9. 'Line Chart',
  10. withInfo('Description')(() => (
  11. <div style={{backgroundColor: 'white', padding: 12}}>
  12. <LineChart
  13. series={[
  14. {
  15. seriesName: text('Line 1', 'sentry:user'),
  16. data: [
  17. {value: 18, name: 'Aug 15th'},
  18. {value: 31, name: 'Aug 16th'},
  19. {value: 9, name: 'Aug 22nd'},
  20. {value: 100, name: 'Sep 5th'},
  21. {value: 12, name: 'Sep 6th'},
  22. ],
  23. },
  24. {
  25. seriesName: text('Line 2', 'environment'),
  26. data: [
  27. {value: 84, name: 'Aug 15th'},
  28. {value: 1, name: 'Aug 16th'},
  29. {value: 28, name: 'Aug 22nd'},
  30. {value: 1, name: 'Sep 5th'},
  31. {value: 1, name: 'Sep 6th'},
  32. ],
  33. },
  34. {
  35. seriesName: text('Line 3', 'browser'),
  36. data: [
  37. {value: 108, name: 'Aug 15th'},
  38. {value: 1, name: 'Aug 16th'},
  39. {value: 36, name: 'Aug 22nd'},
  40. {value: null, name: 'Sep 5th'},
  41. {value: 1, name: 'Sep 6th'},
  42. ],
  43. },
  44. ]}
  45. tooltip={{
  46. filter: value => value !== null,
  47. truncate: 80,
  48. }}
  49. legend={{
  50. data: [
  51. text('Line 1 Legend (match Line 1)', 'sentry:user'),
  52. text('Line 2 Legend (match Line 2)', 'environment'),
  53. text('Line 3 Legend (match Line 3)', 'browser'),
  54. ],
  55. type: text('Legend Type', 'scroll'),
  56. }}
  57. height={number('height', 300)}
  58. grid={{
  59. top: text('grid:top', 40),
  60. bottom: text('grid:bottom', 20),
  61. left: text('grid:left', '10%'),
  62. right: text('grid:right', '10%'),
  63. containLabel: boolean('grid:containLabel', true),
  64. }}
  65. />
  66. </div>
  67. ))
  68. )
  69. .add(
  70. 'Bar Chart',
  71. withInfo('Description: Note Scroll Legends does not work in storybook')(() => (
  72. <div style={{backgroundColor: 'white', padding: 12}}>
  73. <BarChart
  74. stacked={boolean('stacked', true)}
  75. renderer="canvas"
  76. series={[
  77. {
  78. seriesName: text('Line 1', 'sentry:user'),
  79. data: [
  80. {value: 18, name: 'Aug 15th'},
  81. {value: 31, name: 'Aug 16th'},
  82. {value: 9, name: 'Aug 22nd'},
  83. {value: 100, name: 'Sep 5th'},
  84. {value: 12, name: 'Sep 6th'},
  85. ],
  86. },
  87. {
  88. seriesName: text('Line 2', 'environment'),
  89. data: [
  90. {value: 84, name: 'Aug 15th'},
  91. {value: 1, name: 'Aug 16th'},
  92. {value: 28, name: 'Aug 22nd'},
  93. {value: 1, name: 'Sep 5th'},
  94. {value: 1, name: 'Sep 6th'},
  95. ],
  96. },
  97. {
  98. seriesName: text('Line 3', 'browser'),
  99. data: [
  100. {value: 108, name: 'Aug 15th'},
  101. {value: 1, name: 'Aug 16th'},
  102. {value: 36, name: 'Aug 22nd'},
  103. {value: null, name: 'Sep 5th'},
  104. {value: 1, name: 'Sep 6th'},
  105. ],
  106. },
  107. ]}
  108. tooltip={{
  109. filter: value => value !== null,
  110. truncate: 50,
  111. }}
  112. legend={{
  113. show: boolean('show legend', true),
  114. data: [
  115. text('Line 1 Legend (match Line 1)', 'sentry:user'),
  116. text('Line 2 Legend (match Line 2)', 'environment'),
  117. text('Line 3 Legend (match Line 3)', 'browser'),
  118. ],
  119. padding: number('legend: padding', 0),
  120. type: text('legend: type', 'scroll'),
  121. orient: text('legend: orient (vertical or horizontal)', 'horizontal'),
  122. align: text('legend: align (left, right)', 'auto'),
  123. left: text('legend: left (left, right, center)', 'center'),
  124. right: text('legend: right (20 or 20%)', 'auto'),
  125. top: text('legend: top (top, middle, bottom)', 'auto'),
  126. bottom: text('legend: bottom (20 or 20%)', 'auto'),
  127. width: text('legend: width (string or number)', 'auto'),
  128. height: text('legend: height', 'auto'),
  129. }}
  130. height={number('height', 300)}
  131. grid={{
  132. top: text('grid: top', 40),
  133. bottom: text('grid: bottom', 20),
  134. left: text('grid: left', '10%'),
  135. right: text('grid: right', '10%'),
  136. containLabel: boolean('grid: containLabel', true),
  137. }}
  138. />
  139. </div>
  140. ))
  141. );