/
LegendDirection.tsx
49 lines (46 loc) · 1.69 KB
/
LegendDirection.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
import React from 'react'
import { BoxLegendSvg } from '@nivo/legends'
import { useTheme } from '../../../theming/context'
const legendProps = {
containerWidth: 800,
containerHeight: 90,
itemWidth: 70,
itemHeight: 24,
}
export const LegendDirection = () => {
const theme = useTheme()
return (
<div>
<h2>Legend direction</h2>
<p>
Legends support two directions, using the <code>direction</code> property,{' '}
<code>column</code> or <code>row</code>.
</p>
<svg width={legendProps.containerWidth} height={legendProps.containerHeight}>
<BoxLegendSvg
{...legendProps}
itemTextColor={theme.colors.text}
anchor="left"
direction="column"
data={[
{ id: 'a', label: `column`, color: theme.colors.accent },
{ id: 'b', label: `column`, color: theme.colors.accent },
{ id: 'c', label: `column`, color: theme.colors.accent },
]}
/>
<BoxLegendSvg
{...legendProps}
itemTextColor={theme.colors.text}
anchor="left"
translateX={260}
direction="row"
data={[
{ id: 'a', label: `row`, color: theme.colors.accent },
{ id: 'b', label: `row`, color: theme.colors.accent },
{ id: 'c', label: `row`, color: theme.colors.accent },
]}
/>
</svg>
</div>
)
}