@nivo/sankey
Advanced tools
Comparing version 0.32.0 to 0.33.0-3
@@ -12,2 +12,3 @@ /* | ||
import { noop } from '@nivo/core'; | ||
import { LegendPropShape } from '@nivo/legends'; | ||
@@ -76,3 +77,5 @@ export var sankeyAlignmentPropMapping = { | ||
onClick: PropTypes.func.isRequired, | ||
tooltipFormat: PropTypes.oneOfType([PropTypes.func, PropTypes.string]) | ||
tooltipFormat: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), | ||
legends: PropTypes.arrayOf(PropTypes.shape(LegendPropShape)).isRequired | ||
}; | ||
@@ -109,3 +112,5 @@ | ||
isInteractive: true, | ||
onClick: noop | ||
onClick: noop, | ||
legends: [] | ||
}; |
@@ -15,2 +15,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 { Container, SvgWrapper } from '@nivo/core'; | ||
import { BoxLegendSvg } from '@nivo/legends'; | ||
import SankeyNodes from './SankeyNodes'; | ||
@@ -66,3 +67,4 @@ import SankeyLinks from './SankeyLinks'; | ||
onClick = _ref.onClick, | ||
tooltipFormat = _ref.tooltipFormat; | ||
tooltipFormat = _ref.tooltipFormat, | ||
legends = _ref.legends; | ||
@@ -88,2 +90,9 @@ var sankey = d3Sankey().nodeAlign(sankeyAlignmentFromProp(align)).nodeWidth(nodeWidth).nodePadding(nodePaddingY).size([width, height]).nodeId(getId); | ||
var legendData = data.nodes.map(function (node) { | ||
return { | ||
label: node.label, | ||
fill: node.color | ||
}; | ||
}); | ||
var motionProps = { | ||
@@ -193,3 +202,12 @@ animate: animate, | ||
theme: theme | ||
}, motionProps)) | ||
}, motionProps)), | ||
legends.map(function (legend, i) { | ||
return React.createElement(BoxLegendSvg, _extends({ | ||
key: i | ||
}, legend, { | ||
containerWidth: width, | ||
containerHeight: height, | ||
data: legendData | ||
})); | ||
}) | ||
); | ||
@@ -196,0 +214,0 @@ } |
@@ -14,4 +14,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 sankeyAlignmentPropMapping = exports.sankeyAlignmentPropMapping = { | ||
@@ -22,10 +32,4 @@ center: _d3Sankey.sankeyCenter, | ||
right: _d3Sankey.sankeyRight | ||
}; /* | ||
* 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 sankeyAlignmentPropKeys = exports.sankeyAlignmentPropKeys = Object.keys(sankeyAlignmentPropMapping); | ||
@@ -86,3 +90,5 @@ | ||
onClick: _propTypes2.default.func.isRequired, | ||
tooltipFormat: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]) | ||
tooltipFormat: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]), | ||
legends: _propTypes2.default.arrayOf(_propTypes2.default.shape(_legends.LegendPropShape)).isRequired | ||
}; | ||
@@ -119,3 +125,5 @@ | ||
isInteractive: true, | ||
onClick: _core.noop | ||
onClick: _core.noop, | ||
legends: [] | ||
}; |
@@ -25,2 +25,4 @@ 'use strict'; | ||
var _legends = require('@nivo/legends'); | ||
var _SankeyNodes = require('./SankeyNodes'); | ||
@@ -90,3 +92,4 @@ | ||
onClick = _ref.onClick, | ||
tooltipFormat = _ref.tooltipFormat; | ||
tooltipFormat = _ref.tooltipFormat, | ||
legends = _ref.legends; | ||
@@ -112,2 +115,9 @@ var sankey = (0, _d3Sankey.sankey)().nodeAlign((0, _props.sankeyAlignmentFromProp)(align)).nodeWidth(nodeWidth).nodePadding(nodePaddingY).size([width, height]).nodeId(getId); | ||
var legendData = data.nodes.map(function (node) { | ||
return { | ||
label: node.label, | ||
fill: node.color | ||
}; | ||
}); | ||
var motionProps = { | ||
@@ -217,3 +227,12 @@ animate: animate, | ||
theme: theme | ||
}, motionProps)) | ||
}, motionProps)), | ||
legends.map(function (legend, i) { | ||
return _react2.default.createElement(_legends.BoxLegendSvg, _extends({ | ||
key: i | ||
}, legend, { | ||
containerWidth: width, | ||
containerHeight: height, | ||
data: legendData | ||
})); | ||
}) | ||
); | ||
@@ -220,0 +239,0 @@ } |
{ | ||
"name": "@nivo/sankey", | ||
"version": "0.32.0", | ||
"version": "0.33.0-3", | ||
"license": "MIT", | ||
@@ -10,2 +10,3 @@ "main": "./lib/index.js", | ||
"@nivo/core": "0.32.0", | ||
"@nivo/legends": "0.33.0-3", | ||
"d3-sankey": "^0.7.1", | ||
@@ -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
210686
2170
7
+ Added@nivo/legends@0.33.0-3