1
1
import { createElement , Fragment , ReactNode } from 'react'
2
- import {
3
- useDimensions ,
4
- Container ,
5
- SvgWrapper ,
6
- } from '@nivo/core'
2
+ import { useDimensions , Container , SvgWrapper } from '@nivo/core'
3
+ import { BoxLegendSvg } from '@nivo/legends'
4
+ import { ArcLabelsLayer } from '@nivo/arcs'
7
5
import { PolarGrid , RadialAxis , CircularAxis } from '@nivo/polar-axes'
8
- import { PolarBarSvgProps , PolarBarDatum , PolarBarLayerId } from './types'
9
- import { svgDefaultProps } from './props '
6
+ import { PolarBarSvgProps , PolarBarDatum , PolarBarLayerId , PolarBarComputedDatum } from './types'
7
+ import { svgDefaultProps } from './defaults '
10
8
import { usePolarBar } from './hooks'
11
9
import { PolarBarArcs } from './PolarBarArcs'
12
- import { BoxLegendSvg } from '@nivo/legends'
13
10
14
11
const InnerPolarBar = < RawDatum extends PolarBarDatum > ( {
15
12
data,
@@ -32,6 +29,14 @@ const InnerPolarBar = <RawDatum extends PolarBarDatum>({
32
29
borderWidth = svgDefaultProps . borderWidth ,
33
30
borderColor = svgDefaultProps . borderColor ,
34
31
32
+ enableArcLabels = svgDefaultProps . enableArcLabels ,
33
+ arcLabel = svgDefaultProps . arcLabel ,
34
+ arcLabelsSkipAngle = svgDefaultProps . arcLabelsSkipAngle ,
35
+ arcLabelsSkipRadius = svgDefaultProps . arcLabelsSkipRadius ,
36
+ arcLabelsTextColor = svgDefaultProps . arcLabelsTextColor ,
37
+ arcLabelsRadiusOffset = svgDefaultProps . arcLabelsRadiusOffset ,
38
+ arcLabelsComponent,
39
+
35
40
enableRadialGrid = svgDefaultProps . enableRadialGrid ,
36
41
enableCircularGrid = svgDefaultProps . enableCircularGrid ,
37
42
radialAxisStart = svgDefaultProps . radialAxisStart ,
@@ -177,6 +182,23 @@ const InnerPolarBar = <RawDatum extends PolarBarDatum>({
177
182
)
178
183
}
179
184
185
+ if ( enableArcLabels && layers . includes ( 'labels' ) ) {
186
+ layerById . labels = (
187
+ < ArcLabelsLayer < PolarBarComputedDatum >
188
+ key = "labels"
189
+ center = { center }
190
+ data = { arcs }
191
+ label = { arcLabel }
192
+ radiusOffset = { arcLabelsRadiusOffset }
193
+ skipAngle = { arcLabelsSkipAngle }
194
+ skipRadius = { arcLabelsSkipRadius }
195
+ textColor = { arcLabelsTextColor }
196
+ transitionMode = { transitionMode }
197
+ component = { arcLabelsComponent }
198
+ />
199
+ )
200
+ }
201
+
180
202
if ( layers . includes ( 'legends' ) && legends . length > 0 ) {
181
203
layerById . legends = (
182
204
< Fragment key = "legends" >
0 commit comments