Comparing version 0.32.0 to 0.33.0-2
@@ -12,2 +12,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
import React from 'react'; | ||
import { pie as d3Pie, arc as d3Arc } from 'd3-shape'; | ||
import { Motion, TransitionMotion, spring } from 'react-motion'; | ||
@@ -20,3 +21,3 @@ import { getInheritedColorGenerator } from '@nivo/core'; | ||
import { BasicTooltip } from '@nivo/core'; | ||
import { pie as d3Pie, arc as d3Arc } from 'd3-shape'; | ||
import { BoxLegendSvg } from '@nivo/legends'; | ||
import PieRadialLabels from './PieRadialLabels'; | ||
@@ -62,3 +63,4 @@ import PieSlicesLabels from './PieSlicesLabels'; | ||
isInteractive = _ref.isInteractive, | ||
tooltipFormat = _ref.tooltipFormat; | ||
tooltipFormat = _ref.tooltipFormat, | ||
legends = _ref.legends; | ||
@@ -109,6 +111,14 @@ var centerX = width / 2; | ||
var enhancedData = data.map(function (d) { | ||
var color = getColor(d); | ||
return _extends({}, d, { color: color }); | ||
return _extends({}, d, { | ||
color: getColor(d) | ||
}); | ||
}); | ||
var legendData = enhancedData.map(function (d) { | ||
return { | ||
label: d.label, | ||
fill: d.color | ||
}; | ||
}); | ||
var boundDefs = bindDefs(defs, enhancedData, fill); | ||
@@ -196,3 +206,12 @@ | ||
} | ||
) | ||
), | ||
legends.map(function (legend, i) { | ||
return React.createElement(BoxLegendSvg, _extends({ | ||
key: i | ||
}, legend, { | ||
containerWidth: width, | ||
containerHeight: height, | ||
data: legendData | ||
})); | ||
}) | ||
); | ||
@@ -199,0 +218,0 @@ } |
@@ -10,2 +10,3 @@ /* | ||
import PropTypes from 'prop-types'; | ||
import { LegendPropShape } from '@nivo/legends'; | ||
@@ -56,3 +57,5 @@ export var PiePropTypes = { | ||
isInteractive: PropTypes.bool, | ||
tooltipFormat: PropTypes.oneOfType([PropTypes.func, PropTypes.string]) | ||
tooltipFormat: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), | ||
legends: PropTypes.arrayOf(PropTypes.shape(LegendPropShape)).isRequired | ||
}; | ||
@@ -86,3 +89,5 @@ | ||
// interactivity | ||
isInteractive: true | ||
isInteractive: true, | ||
legends: [] | ||
}; |
@@ -19,2 +19,4 @@ 'use strict'; | ||
var _d3Shape = require('d3-shape'); | ||
var _reactMotion = require('react-motion'); | ||
@@ -24,3 +26,3 @@ | ||
var _d3Shape = require('d3-shape'); | ||
var _legends = require('@nivo/legends'); | ||
@@ -78,3 +80,4 @@ var _PieRadialLabels = require('./PieRadialLabels'); | ||
isInteractive = _ref.isInteractive, | ||
tooltipFormat = _ref.tooltipFormat; | ||
tooltipFormat = _ref.tooltipFormat, | ||
legends = _ref.legends; | ||
@@ -125,6 +128,14 @@ var centerX = width / 2; | ||
var enhancedData = data.map(function (d) { | ||
var color = getColor(d); | ||
return _extends({}, d, { color: color }); | ||
return _extends({}, d, { | ||
color: getColor(d) | ||
}); | ||
}); | ||
var legendData = enhancedData.map(function (d) { | ||
return { | ||
label: d.label, | ||
fill: d.color | ||
}; | ||
}); | ||
var boundDefs = (0, _core.bindDefs)(defs, enhancedData, fill); | ||
@@ -212,3 +223,12 @@ | ||
} | ||
) | ||
), | ||
legends.map(function (legend, i) { | ||
return _react2.default.createElement(_legends.BoxLegendSvg, _extends({ | ||
key: i | ||
}, legend, { | ||
containerWidth: width, | ||
containerHeight: height, | ||
data: legendData | ||
})); | ||
}) | ||
); | ||
@@ -215,0 +235,0 @@ } |
@@ -10,4 +10,14 @@ 'use strict'; | ||
var _legends = require('@nivo/legends'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* | ||
* This file is part of the nivo project. | ||
* | ||
* Copyright 2016-present, Raphaël Benitte. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
var PiePropTypes = exports.PiePropTypes = { | ||
@@ -57,11 +67,7 @@ data: _propTypes2.default.arrayOf(_propTypes2.default.shape({ | ||
isInteractive: _propTypes2.default.bool, | ||
tooltipFormat: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]) | ||
}; /* | ||
* This file is part of the nivo project. | ||
* | ||
* Copyright 2016-present, Raphaël Benitte. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
tooltipFormat: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]), | ||
legends: _propTypes2.default.arrayOf(_propTypes2.default.shape(_legends.LegendPropShape)).isRequired | ||
}; | ||
var PieDefaultProps = exports.PieDefaultProps = { | ||
@@ -93,3 +99,5 @@ sortByValue: false, | ||
// interactivity | ||
isInteractive: true | ||
isInteractive: true, | ||
legends: [] | ||
}; |
{ | ||
"name": "@nivo/pie", | ||
"version": "0.32.0", | ||
"version": "0.33.0-2", | ||
"license": "MIT", | ||
@@ -10,2 +10,3 @@ "main": "./lib/index.js", | ||
"@nivo/core": "0.32.0", | ||
"@nivo/legends": "0.33.0-2", | ||
"d3-shape": "^1.2.0", | ||
@@ -12,0 +13,0 @@ "react-motion": "^0.5.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
173461
1099
7
+ Added@nivo/legends@0.33.0-2
+ Added@nivo/legends@0.33.0-2(transitive)