/
ThemedBar.tsx
75 lines (74 loc) · 2.31 KB
/
ThemedBar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import React from 'react'
import { CompleteTheme } from '@nivo/core'
import { ResponsiveBar } from '@nivo/bar'
import { colorSchemes } from '@nivo/colors'
export const ThemedBar = ({ theme }: { theme: CompleteTheme }) => {
return (
<ResponsiveBar
margin={{
top: 40,
right: 20,
bottom: 50,
left: 50,
}}
data={[
{ id: 'A', value: 12 },
{ id: 'B', value: 17 },
{ id: 'C', value: 9 },
{ id: 'D', value: 15 },
{ id: 'E', value: 23 },
]}
theme={theme}
colorBy="indexValue"
animate={false}
enableGridX={true}
axisBottom={{
legend: 'X axis legend',
legendPosition: 'middle',
legendOffset: 34,
}}
axisLeft={{
legend: 'Y axis legend',
legendPosition: 'middle',
legendOffset: -36,
}}
legends={[
{
anchor: 'top',
translateY: -28,
itemWidth: 40,
itemHeight: 12,
symbolSize: 12,
direction: 'row',
data: [
{
id: 'A',
label: 'A',
color: colorSchemes.nivo[0],
},
{
id: 'B',
label: 'B',
color: colorSchemes.nivo[1],
},
{
id: 'C',
label: 'C',
color: colorSchemes.nivo[2],
},
{
id: 'D',
label: 'D',
color: colorSchemes.nivo[3],
},
{
id: 'E',
label: 'E',
color: colorSchemes.nivo[4],
},
],
},
]}
/>
)
}