Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. In my App.js' render, I have a line like this. Sample data is defined in apps default state:
  2.  
  3. <Grid item xs style={{height:200 + 'px'}}>
  4. <JobQueueChart data={this.state.jobCountTimeline}></JobQueueChart>
  5. </Grid>
  6.  
  7. The that component is:
  8.  
  9. import React from 'react';
  10. import { ResponsiveBar } from '@nivo/bar'
  11. const JobQueueChart = ({ data /* see data tab */ }) => (
  12.  
  13. <ResponsiveBar
  14. data={data}
  15. keys={[ 'hot dog', 'burger', 'sandwich', 'kebab', 'fries', 'donut' ]}
  16. indexBy="country"
  17. margin={{ top: 50, right: 130, bottom: 50, left: 60 }}
  18. padding={0.3}
  19. colors={{ scheme: 'nivo' }}
  20. defs={[
  21. {
  22. id: 'dots',
  23. type: 'patternDots',
  24. background: 'inherit',
  25. color: '#38bcb2',
  26. size: 4,
  27. padding: 1,
  28. stagger: true
  29. },
  30. {
  31. id: 'lines',
  32. type: 'patternLines',
  33. background: 'inherit',
  34. color: '#eed312',
  35. rotation: -45,
  36. lineWidth: 6,
  37. spacing: 10
  38. }
  39. ]}
  40. fill={[
  41. {
  42. match: {
  43. id: 'fries'
  44. },
  45. id: 'dots'
  46. },
  47. {
  48. match: {
  49. id: 'sandwich'
  50. },
  51. id: 'lines'
  52. }
  53. ]}
  54. borderColor={{ from: 'color', modifiers: [ [ 'darker', 1.6 ] ] }}
  55. axisTop={null}
  56. axisRight={null}
  57. axisBottom={{
  58. tickSize: 5,
  59. tickPadding: 5,
  60. tickRotation: 0,
  61. legend: 'country',
  62. legendPosition: 'middle',
  63. legendOffset: 32
  64. }}
  65. axisLeft={{
  66. tickSize: 5,
  67. tickPadding: 5,
  68. tickRotation: 0,
  69. legend: 'food',
  70. legendPosition: 'middle',
  71. legendOffset: -40
  72. }}
  73. labelSkipWidth={12}
  74. labelSkipHeight={12}
  75. labelTextColor={{ from: 'color', modifiers: [ [ 'darker', 1.6 ] ] }}
  76. legends={[
  77. {
  78. dataFrom: 'keys',
  79. anchor: 'bottom-right',
  80. direction: 'column',
  81. justify: false,
  82. translateX: 120,
  83. translateY: 0,
  84. itemsSpacing: 2,
  85. itemWidth: 100,
  86. itemHeight: 20,
  87. itemDirection: 'left-to-right',
  88. itemOpacity: 0.85,
  89. symbolSize: 20,
  90. effects: [
  91. {
  92. on: 'hover',
  93. style: {
  94. itemOpacity: 1
  95. }
  96. }
  97. ]
  98. }
  99. ]}
  100. animate={true}
  101. motionStiffness={90}
  102. motionDamping={15}
  103. />
  104.  
  105. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement