diff --git a/packages/nivo-radar/src/Radar.js b/packages/nivo-radar/src/Radar.js index 6e0cd35ef..2a186f100 100644 --- a/packages/nivo-radar/src/Radar.js +++ b/packages/nivo-radar/src/Radar.js @@ -176,6 +176,7 @@ Radar.propTypes = { data: PropTypes.arrayOf(PropTypes.object).isRequired, keys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])).isRequired, indexBy: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]).isRequired, + maxValue: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])]).isRequired, getIndex: PropTypes.func.isRequired, // computed indices: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])) .isRequired, // computed @@ -217,6 +218,8 @@ Radar.propTypes = { } export const RadarDefaultProps = { + maxValue: 'auto', + curve: 'linearClosed', // border @@ -262,9 +265,12 @@ const enhance = compose( }, {}), })), withPropsOnChange( - ['keys', 'indexBy', 'data', 'width', 'height'], - ({ data, keys, width, height }) => { - const maxValue = max(data.reduce((acc, d) => [...acc, ...keys.map(key => d[key])], [])) + ['keys', 'indexBy', 'data', 'maxValue', 'width', 'height'], + ({ data, keys, maxValue: _maxValue, width, height }) => { + const maxValue = + _maxValue !== 'auto' + ? _maxValue + : max(data.reduce((acc, d) => [...acc, ...keys.map(key => d[key])], [])) const radius = Math.min(width, height) / 2 const radiusScale = scaleLinear() diff --git a/website/src/components/charts/radar/Radar.js b/website/src/components/charts/radar/Radar.js index ce9494ca5..bfc97e5c7 100644 --- a/website/src/components/charts/radar/Radar.js +++ b/website/src/components/charts/radar/Radar.js @@ -30,6 +30,8 @@ export default class Radar extends Component { state = { settings: { + maxValue: 'auto', + margin: { top: 70, right: 80, diff --git a/website/src/components/charts/radar/props.js b/website/src/components/charts/radar/props.js index cc0b9745c..8ec78a72e 100644 --- a/website/src/components/charts/radar/props.js +++ b/website/src/components/charts/radar/props.js @@ -66,6 +66,22 @@ export default [ required: false, default: defaults.keys, }, + { + key: 'maxValue', + scopes: '*', + description: `Maximum value, if 'auto', will use max value from the provided data.`, + required: false, + default: defaults.maxValue, + type: '{number|string}', + controlType: 'switchableRange', + controlGroup: 'Base', + controlOptions: { + disabledValue: 'auto', + defaultValue: 200, + min: 0, + max: 1000, + }, + }, { key: 'width', scopes: ['api'],