charts.stories.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import {BarChart} from 'sentry/components/charts/barChart';
  2. import {LineChart} from 'sentry/components/charts/lineChart';
  3. export default {
  4. title: 'Components/Data Visualization/Charts/Playground',
  5. args: {
  6. height: 300,
  7. series: [
  8. {
  9. seriesName: 'sentry:user',
  10. data: [
  11. {value: 18, name: 'Aug 15th'},
  12. {value: 31, name: 'Aug 16th'},
  13. {value: 9, name: 'Aug 22nd'},
  14. {value: 100, name: 'Sep 5th'},
  15. {value: 12, name: 'Sep 6th'},
  16. ],
  17. },
  18. {
  19. seriesName: 'environment',
  20. data: [
  21. {value: 84, name: 'Aug 15th'},
  22. {value: 1, name: 'Aug 16th'},
  23. {value: 28, name: 'Aug 22nd'},
  24. {value: 1, name: 'Sep 5th'},
  25. {value: 1, name: 'Sep 6th'},
  26. ],
  27. },
  28. {
  29. seriesName: 'browser',
  30. data: [
  31. {value: 108, name: 'Aug 15th'},
  32. {value: 1, name: 'Aug 16th'},
  33. {value: 36, name: 'Aug 22nd'},
  34. {value: null, name: 'Sep 5th'},
  35. {value: 1, name: 'Sep 6th'},
  36. ],
  37. },
  38. ],
  39. grid: {
  40. top: 40,
  41. bottom: 20,
  42. left: '10%',
  43. right: '10%',
  44. containLabel: true,
  45. },
  46. },
  47. };
  48. export const _LineChart = ({height, series, legend, grid}) => (
  49. <div style={{backgroundColor: 'white', padding: 12}}>
  50. <LineChart
  51. series={series}
  52. tooltip={{
  53. filter: value => value !== null,
  54. truncate: 80,
  55. }}
  56. legend={legend}
  57. height={height}
  58. grid={grid}
  59. />
  60. </div>
  61. );
  62. _LineChart.args = {
  63. legend: {
  64. data: ['sentry:user', 'environment', 'browser'],
  65. type: 'scroll',
  66. },
  67. };
  68. export const _BarChart = ({height, series, legend, stacked, grid}) => (
  69. <div style={{backgroundColor: 'white', padding: 12}}>
  70. <BarChart
  71. stacked={stacked}
  72. renderer="canvas"
  73. series={series}
  74. tooltip={{
  75. filter: value => value !== null,
  76. truncate: 50,
  77. }}
  78. legend={legend}
  79. height={height}
  80. grid={grid}
  81. />
  82. </div>
  83. );
  84. _BarChart.args = {
  85. stacked: true,
  86. legend: {
  87. show: true,
  88. data: ['sentry:user', 'environment', 'browser'],
  89. padding: 0,
  90. type: 'scroll',
  91. orient: 'horizontal',
  92. align: 'auto',
  93. left: 'center',
  94. right: 'auto',
  95. top: 'auto',
  96. bottom: 'auto',
  97. width: 'auto',
  98. height: 'auto',
  99. },
  100. };
  101. _BarChart.parameters = {
  102. docs: {
  103. description: {
  104. story: 'Description: Note Scroll Legends does not work in storybook',
  105. },
  106. },
  107. };