@@ -4,7 +4,7 @@ import { arc as d3Arc } from 'd3-shape'
4
4
import { degreesToRadians , useValueFormatter } from '@nivo/core'
5
5
import { Arc } from '@nivo/arcs'
6
6
import { useOrdinalColorScale } from '@nivo/colors'
7
- import { commonDefaultProps } from './props'
7
+ import { commonDefaultProps , svgDefaultProps } from './props'
8
8
import {
9
9
ComputedBar ,
10
10
RadialBarCommonProps ,
@@ -22,6 +22,7 @@ interface RadialBarGroup<D extends RadialBarDatum> {
22
22
23
23
export const useRadialBar = < D extends RadialBarDatum = RadialBarDatum > ( {
24
24
data,
25
+ maxValue : maxValueDirective = svgDefaultProps . maxValue ,
25
26
valueFormat,
26
27
startAngle = commonDefaultProps . startAngle ,
27
28
endAngle = commonDefaultProps . endAngle ,
@@ -35,6 +36,7 @@ export const useRadialBar = <D extends RadialBarDatum = RadialBarDatum>({
35
36
tracksColor = commonDefaultProps . tracksColor ,
36
37
} : {
37
38
data : RadialBarDataProps < D > [ 'data' ]
39
+ maxValue : RadialBarCommonProps < D > [ 'maxValue' ]
38
40
valueFormat ?: RadialBarCommonProps < D > [ 'valueFormat' ]
39
41
startAngle : RadialBarCommonProps < D > [ 'startAngle' ]
40
42
innerRadiusRatio : RadialBarCommonProps < D > [ 'innerRadius' ]
@@ -91,10 +93,14 @@ export const useRadialBar = <D extends RadialBarDatum = RadialBarDatum>({
91
93
} )
92
94
} )
93
95
94
- result . maxValue = Math . max ( ...result . groups . map ( group => group . total ) )
96
+ if ( maxValueDirective === 'auto' ) {
97
+ result . maxValue = Math . max ( ...result . groups . map ( group => group . total ) )
98
+ } else {
99
+ result . maxValue = maxValueDirective
100
+ }
95
101
96
102
return result
97
- } , [ data ] )
103
+ } , [ data , maxValueDirective ] )
98
104
99
105
const valueScale = useMemo (
100
106
( ) => scaleLinear < number , number > ( ) . domain ( [ 0 , maxValue ] ) . range ( [ startAngle , endAngle ] ) ,
0 commit comments