diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index ceaea36..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,132 +0,0 @@
-# ---> Node
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-lerna-debug.log*
-.pnpm-debug.log*
-
-# Diagnostic reports (https://nodejs.org/api/report.html)
-report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
-
-# Runtime data
-pids
-*.pid
-*.seed
-*.pid.lock
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-lib-cov
-
-# Coverage directory used by tools like istanbul
-coverage
-*.lcov
-
-# nyc test coverage
-.nyc_output
-
-# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-bower_components
-
-# node-waf configuration
-.lock-wscript
-
-# Compiled binary addons (https://nodejs.org/api/addons.html)
-build/Release
-
-# Dependency directories
-node_modules/
-jspm_packages/
-
-# Snowpack dependency directory (https://snowpack.dev/)
-web_modules/
-
-# TypeScript cache
-*.tsbuildinfo
-
-# Optional npm cache directory
-.npm
-
-# Optional eslint cache
-.eslintcache
-
-# Optional stylelint cache
-.stylelintcache
-
-# Microbundle cache
-.rpt2_cache/
-.rts2_cache_cjs/
-.rts2_cache_es/
-.rts2_cache_umd/
-
-# Optional REPL history
-.node_repl_history
-
-# Output of 'npm pack'
-*.tgz
-
-# Yarn Integrity file
-.yarn-integrity
-
-# dotenv environment variable files
-.env
-.env.development.local
-.env.test.local
-.env.production.local
-.env.local
-
-# parcel-bundler cache (https://parceljs.org/)
-.cache
-.parcel-cache
-
-# Next.js build output
-.next
-out
-
-# Nuxt.js build / generate output
-.nuxt
-dist
-
-# Gatsby files
-.cache/
-# Comment in the public line in if your project uses Gatsby and not Next.js
-# https://nextjs.org/blog/next-9-1#public-directory-support
-# public
-
-# vuepress build output
-.vuepress/dist
-
-# vuepress v2.x temp and cache directory
-.temp
-.cache
-
-# Docusaurus cache and generated files
-.docusaurus
-
-# Serverless directories
-.serverless/
-
-# FuseBox cache
-.fusebox/
-
-# DynamoDB Local files
-.dynamodb/
-
-# TernJS port file
-.tern-port
-
-# Stores VSCode versions used for testing VSCode extensions
-.vscode-test
-
-# yarn v2
-.yarn/cache
-.yarn/unplugged
-.yarn/build-state.yml
-.yarn/install-state.gz
-.pnp.*
-
diff --git a/LICENSE b/LICENSE
index 5752d0f..1516b64 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,9 +1,21 @@
-MIT License
+The MIT License (MIT)
-Copyright (c) 2024 dehernandezm
+Copyright (c) 2017 Plotly, Inc
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/PivotTable.js b/PivotTable.js
new file mode 100644
index 0000000..beebfaa
--- /dev/null
+++ b/PivotTable.js
@@ -0,0 +1,66 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _react = require('react');
+
+var _react2 = _interopRequireDefault(_react);
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = _interopRequireDefault(_propTypes);
+
+var _Utilities = require('./Utilities');
+
+var _TableRenderers = require('./TableRenderers');
+
+var _TableRenderers2 = _interopRequireDefault(_TableRenderers);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+/* eslint-disable react/prop-types */
+// eslint can't see inherited propTypes!
+
+var PivotTable = function (_React$PureComponent) {
+ _inherits(PivotTable, _React$PureComponent);
+
+ function PivotTable() {
+ _classCallCheck(this, PivotTable);
+
+ return _possibleConstructorReturn(this, (PivotTable.__proto__ || Object.getPrototypeOf(PivotTable)).apply(this, arguments));
+ }
+
+ _createClass(PivotTable, [{
+ key: 'render',
+ value: function render() {
+ var Renderer = this.props.renderers[this.props.rendererName in this.props.renderers ? this.props.rendererName : Object.keys(this.props.renderers)[0]];
+ return _react2.default.createElement(Renderer, this.props);
+ }
+ }]);
+
+ return PivotTable;
+}(_react2.default.PureComponent);
+
+PivotTable.propTypes = Object.assign({}, _Utilities.PivotData.propTypes, {
+ rendererName: _propTypes2.default.string,
+ renderers: _propTypes2.default.objectOf(_propTypes2.default.func)
+});
+
+PivotTable.defaultProps = Object.assign({}, _Utilities.PivotData.defaultProps, {
+ rendererName: 'Table',
+ renderers: _TableRenderers2.default
+});
+
+exports.default = PivotTable;
+module.exports = exports['default'];
+//# sourceMappingURL=PivotTable.js.map
\ No newline at end of file
diff --git a/PivotTable.js.map b/PivotTable.js.map
new file mode 100644
index 0000000..37fa97a
--- /dev/null
+++ b/PivotTable.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["src/PivotTable.jsx"],"names":["PivotTable","Renderer","props","renderers","rendererName","Object","keys","React","PureComponent","propTypes","assign","PivotData","PropTypes","string","objectOf","func","defaultProps","TableRenderers"],"mappings":";;;;;;;;AAAA;;;;AACA;;;;AACA;;AACA;;;;;;;;;;;;AAEA;AACA;;IAEMA,U;;;;;;;;;;;6BACK;AACP,UAAMC,WAAW,KAAKC,KAAL,CAAWC,SAAX,CACf,KAAKD,KAAL,CAAWE,YAAX,IAA2B,KAAKF,KAAL,CAAWC,SAAtC,GACI,KAAKD,KAAL,CAAWE,YADf,GAEIC,OAAOC,IAAP,CAAY,KAAKJ,KAAL,CAAWC,SAAvB,EAAkC,CAAlC,CAHW,CAAjB;AAKA,aAAO,8BAAC,QAAD,EAAc,KAAKD,KAAnB,CAAP;AACD;;;;EARsBK,gBAAMC,a;;AAW/BR,WAAWS,SAAX,GAAuBJ,OAAOK,MAAP,CAAc,EAAd,EAAkBC,qBAAUF,SAA5B,EAAuC;AAC5DL,gBAAcQ,oBAAUC,MADoC;AAE5DV,aAAWS,oBAAUE,QAAV,CAAmBF,oBAAUG,IAA7B;AAFiD,CAAvC,CAAvB;;AAKAf,WAAWgB,YAAX,GAA0BX,OAAOK,MAAP,CAAc,EAAd,EAAkBC,qBAAUK,YAA5B,EAA0C;AAClEZ,gBAAc,OADoD;AAElED,aAAWc;AAFuD,CAA1C,CAA1B;;kBAKejB,U","file":"PivotTable.js","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {PivotData} from './Utilities';\nimport TableRenderers from './TableRenderers';\n\n/* eslint-disable react/prop-types */\n// eslint can't see inherited propTypes!\n\nclass PivotTable extends React.PureComponent {\n render() {\n const Renderer = this.props.renderers[\n this.props.rendererName in this.props.renderers\n ? this.props.rendererName\n : Object.keys(this.props.renderers)[0]\n ];\n return ;\n }\n}\n\nPivotTable.propTypes = Object.assign({}, PivotData.propTypes, {\n rendererName: PropTypes.string,\n renderers: PropTypes.objectOf(PropTypes.func),\n});\n\nPivotTable.defaultProps = Object.assign({}, PivotData.defaultProps, {\n rendererName: 'Table',\n renderers: TableRenderers,\n});\n\nexport default PivotTable;\n"]}
\ No newline at end of file
diff --git a/PivotTableUI.js b/PivotTableUI.js
new file mode 100644
index 0000000..2c810b8
--- /dev/null
+++ b/PivotTableUI.js
@@ -0,0 +1,720 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.Dropdown = exports.DraggableAttribute = undefined;
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+var _react = require('react');
+
+var _react2 = _interopRequireDefault(_react);
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = _interopRequireDefault(_propTypes);
+
+var _immutabilityHelper = require('immutability-helper');
+
+var _immutabilityHelper2 = _interopRequireDefault(_immutabilityHelper);
+
+var _Utilities = require('./Utilities');
+
+var _PivotTable = require('./PivotTable');
+
+var _PivotTable2 = _interopRequireDefault(_PivotTable);
+
+var _reactSortablejs = require('react-sortablejs');
+
+var _reactSortablejs2 = _interopRequireDefault(_reactSortablejs);
+
+var _reactDraggable = require('react-draggable');
+
+var _reactDraggable2 = _interopRequireDefault(_reactDraggable);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+/* eslint-disable react/prop-types */
+// eslint can't see inherited propTypes!
+
+var DraggableAttribute = exports.DraggableAttribute = function (_React$Component) {
+ _inherits(DraggableAttribute, _React$Component);
+
+ function DraggableAttribute(props) {
+ _classCallCheck(this, DraggableAttribute);
+
+ var _this = _possibleConstructorReturn(this, (DraggableAttribute.__proto__ || Object.getPrototypeOf(DraggableAttribute)).call(this, props));
+
+ _this.state = { open: false, filterText: '' };
+ return _this;
+ }
+
+ _createClass(DraggableAttribute, [{
+ key: 'toggleValue',
+ value: function toggleValue(value) {
+ if (value in this.props.valueFilter) {
+ this.props.removeValuesFromFilter(this.props.name, [value]);
+ } else {
+ this.props.addValuesToFilter(this.props.name, [value]);
+ }
+ }
+ }, {
+ key: 'matchesFilter',
+ value: function matchesFilter(x) {
+ return x.toLowerCase().trim().includes(this.state.filterText.toLowerCase().trim());
+ }
+ }, {
+ key: 'selectOnly',
+ value: function selectOnly(e, value) {
+ e.stopPropagation();
+ this.props.setValuesInFilter(this.props.name, Object.keys(this.props.attrValues).filter(function (y) {
+ return y !== value;
+ }));
+ }
+ }, {
+ key: 'getFilterBox',
+ value: function getFilterBox() {
+ var _this2 = this;
+
+ var showMenu = Object.keys(this.props.attrValues).length < this.props.menuLimit;
+
+ var values = Object.keys(this.props.attrValues);
+ var shown = values.filter(this.matchesFilter.bind(this)).sort(this.props.sorter);
+
+ return _react2.default.createElement(
+ _reactDraggable2.default,
+ { handle: '.pvtDragHandle' },
+ _react2.default.createElement(
+ 'div',
+ {
+ className: 'pvtFilterBox',
+ style: {
+ display: 'block',
+ cursor: 'initial',
+ zIndex: this.props.zIndex
+ },
+ onClick: function onClick() {
+ return _this2.props.moveFilterBoxToTop(_this2.props.name);
+ }
+ },
+ _react2.default.createElement(
+ 'a',
+ { onClick: function onClick() {
+ return _this2.setState({ open: false });
+ }, className: 'pvtCloseX' },
+ '\xD7'
+ ),
+ _react2.default.createElement(
+ 'span',
+ { className: 'pvtDragHandle' },
+ '\u2630'
+ ),
+ _react2.default.createElement(
+ 'h4',
+ null,
+ this.props.name
+ ),
+ showMenu || _react2.default.createElement(
+ 'p',
+ null,
+ '(too many values to show)'
+ ),
+ showMenu && _react2.default.createElement(
+ 'p',
+ null,
+ _react2.default.createElement('input', {
+ type: 'text',
+ placeholder: 'Filter values',
+ className: 'pvtSearch',
+ value: this.state.filterText,
+ onChange: function onChange(e) {
+ return _this2.setState({
+ filterText: e.target.value
+ });
+ }
+ }),
+ _react2.default.createElement('br', null),
+ _react2.default.createElement(
+ 'a',
+ {
+ role: 'button',
+ className: 'pvtButton',
+ onClick: function onClick() {
+ return _this2.props.removeValuesFromFilter(_this2.props.name, Object.keys(_this2.props.attrValues).filter(_this2.matchesFilter.bind(_this2)));
+ }
+ },
+ 'Select ',
+ values.length === shown.length ? 'All' : shown.length
+ ),
+ ' ',
+ _react2.default.createElement(
+ 'a',
+ {
+ role: 'button',
+ className: 'pvtButton',
+ onClick: function onClick() {
+ return _this2.props.addValuesToFilter(_this2.props.name, Object.keys(_this2.props.attrValues).filter(_this2.matchesFilter.bind(_this2)));
+ }
+ },
+ 'Deselect ',
+ values.length === shown.length ? 'All' : shown.length
+ )
+ ),
+ showMenu && _react2.default.createElement(
+ 'div',
+ { className: 'pvtCheckContainer' },
+ shown.map(function (x) {
+ return _react2.default.createElement(
+ 'p',
+ {
+ key: x,
+ onClick: function onClick() {
+ return _this2.toggleValue(x);
+ },
+ className: x in _this2.props.valueFilter ? '' : 'selected'
+ },
+ _react2.default.createElement(
+ 'a',
+ { className: 'pvtOnly', onClick: function onClick(e) {
+ return _this2.selectOnly(e, x);
+ } },
+ 'only'
+ ),
+ _react2.default.createElement(
+ 'a',
+ { className: 'pvtOnlySpacer' },
+ '\xA0'
+ ),
+ x === '' ? _react2.default.createElement(
+ 'em',
+ null,
+ 'null'
+ ) : x
+ );
+ })
+ )
+ )
+ );
+ }
+ }, {
+ key: 'toggleFilterBox',
+ value: function toggleFilterBox() {
+ this.setState({ open: !this.state.open });
+ this.props.moveFilterBoxToTop(this.props.name);
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ var filtered = Object.keys(this.props.valueFilter).length !== 0 ? 'pvtFilteredAttribute' : '';
+ return _react2.default.createElement(
+ 'li',
+ { 'data-id': this.props.name },
+ _react2.default.createElement(
+ 'span',
+ { className: 'pvtAttr ' + filtered },
+ this.props.name,
+ _react2.default.createElement(
+ 'span',
+ {
+ className: 'pvtTriangle',
+ onClick: this.toggleFilterBox.bind(this)
+ },
+ ' ',
+ '\u25BE'
+ )
+ ),
+ this.state.open ? this.getFilterBox() : null
+ );
+ }
+ }]);
+
+ return DraggableAttribute;
+}(_react2.default.Component);
+
+DraggableAttribute.defaultProps = {
+ valueFilter: {}
+};
+
+DraggableAttribute.propTypes = {
+ name: _propTypes2.default.string.isRequired,
+ addValuesToFilter: _propTypes2.default.func.isRequired,
+ removeValuesFromFilter: _propTypes2.default.func.isRequired,
+ attrValues: _propTypes2.default.objectOf(_propTypes2.default.number).isRequired,
+ valueFilter: _propTypes2.default.objectOf(_propTypes2.default.bool),
+ moveFilterBoxToTop: _propTypes2.default.func.isRequired,
+ sorter: _propTypes2.default.func.isRequired,
+ menuLimit: _propTypes2.default.number,
+ zIndex: _propTypes2.default.number
+};
+
+var Dropdown = exports.Dropdown = function (_React$PureComponent) {
+ _inherits(Dropdown, _React$PureComponent);
+
+ function Dropdown() {
+ _classCallCheck(this, Dropdown);
+
+ return _possibleConstructorReturn(this, (Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).apply(this, arguments));
+ }
+
+ _createClass(Dropdown, [{
+ key: 'render',
+ value: function render() {
+ var _this4 = this;
+
+ return _react2.default.createElement(
+ 'div',
+ { className: 'pvtDropdown', style: { zIndex: this.props.zIndex } },
+ _react2.default.createElement(
+ 'div',
+ {
+ onClick: function onClick(e) {
+ e.stopPropagation();
+ _this4.props.toggle();
+ },
+ className: 'pvtDropdownValue pvtDropdownCurrent ' + (this.props.open ? 'pvtDropdownCurrentOpen' : ''),
+ role: 'button'
+ },
+ _react2.default.createElement(
+ 'div',
+ { className: 'pvtDropdownIcon' },
+ this.props.open ? '×' : '▾'
+ ),
+ this.props.current || _react2.default.createElement(
+ 'span',
+ null,
+ '\xA0'
+ )
+ ),
+ this.props.open && _react2.default.createElement(
+ 'div',
+ { className: 'pvtDropdownMenu' },
+ this.props.values.map(function (r) {
+ return _react2.default.createElement(
+ 'div',
+ {
+ key: r,
+ role: 'button',
+ onClick: function onClick(e) {
+ e.stopPropagation();
+ if (_this4.props.current === r) {
+ _this4.props.toggle();
+ } else {
+ _this4.props.setValue(r);
+ }
+ },
+ className: 'pvtDropdownValue ' + (r === _this4.props.current ? 'pvtDropdownActiveValue' : '')
+ },
+ r
+ );
+ })
+ )
+ );
+ }
+ }]);
+
+ return Dropdown;
+}(_react2.default.PureComponent);
+
+var PivotTableUI = function (_React$PureComponent2) {
+ _inherits(PivotTableUI, _React$PureComponent2);
+
+ function PivotTableUI(props) {
+ _classCallCheck(this, PivotTableUI);
+
+ var _this5 = _possibleConstructorReturn(this, (PivotTableUI.__proto__ || Object.getPrototypeOf(PivotTableUI)).call(this, props));
+
+ _this5.state = {
+ unusedOrder: [],
+ zIndices: {},
+ maxZIndex: 1000,
+ openDropdown: false,
+ attrValues: {},
+ materializedInput: []
+ };
+ return _this5;
+ }
+
+ _createClass(PivotTableUI, [{
+ key: 'componentDidMount',
+ value: function componentDidMount() {
+ this.materializeInput(this.props.data);
+ }
+ }, {
+ key: 'componentDidUpdate',
+ value: function componentDidUpdate() {
+ this.materializeInput(this.props.data);
+ }
+ }, {
+ key: 'materializeInput',
+ value: function materializeInput(nextData) {
+ if (this.state.data === nextData) {
+ return;
+ }
+ var newState = {
+ data: nextData,
+ attrValues: {},
+ materializedInput: []
+ };
+ var recordsProcessed = 0;
+ _Utilities.PivotData.forEachRecord(newState.data, this.props.derivedAttributes, function (record) {
+ newState.materializedInput.push(record);
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = Object.keys(record)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var attr = _step.value;
+
+ if (!(attr in newState.attrValues)) {
+ newState.attrValues[attr] = {};
+ if (recordsProcessed > 0) {
+ newState.attrValues[attr].null = recordsProcessed;
+ }
+ }
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+
+ for (var _attr in newState.attrValues) {
+ var value = _attr in record ? record[_attr] : 'null';
+ if (!(value in newState.attrValues[_attr])) {
+ newState.attrValues[_attr][value] = 0;
+ }
+ newState.attrValues[_attr][value]++;
+ }
+ recordsProcessed++;
+ });
+ this.setState(newState);
+ }
+ }, {
+ key: 'sendPropUpdate',
+ value: function sendPropUpdate(command) {
+ this.props.onChange((0, _immutabilityHelper2.default)(this.props, command));
+ }
+ }, {
+ key: 'propUpdater',
+ value: function propUpdater(key) {
+ var _this6 = this;
+
+ return function (value) {
+ return _this6.sendPropUpdate(_defineProperty({}, key, { $set: value }));
+ };
+ }
+ }, {
+ key: 'setValuesInFilter',
+ value: function setValuesInFilter(attribute, values) {
+ this.sendPropUpdate({
+ valueFilter: _defineProperty({}, attribute, {
+ $set: values.reduce(function (r, v) {
+ r[v] = true;
+ return r;
+ }, {})
+ })
+ });
+ }
+ }, {
+ key: 'addValuesToFilter',
+ value: function addValuesToFilter(attribute, values) {
+ if (attribute in this.props.valueFilter) {
+ this.sendPropUpdate({
+ valueFilter: _defineProperty({}, attribute, values.reduce(function (r, v) {
+ r[v] = { $set: true };
+ return r;
+ }, {}))
+ });
+ } else {
+ this.setValuesInFilter(attribute, values);
+ }
+ }
+ }, {
+ key: 'removeValuesFromFilter',
+ value: function removeValuesFromFilter(attribute, values) {
+ this.sendPropUpdate({
+ valueFilter: _defineProperty({}, attribute, { $unset: values })
+ });
+ }
+ }, {
+ key: 'moveFilterBoxToTop',
+ value: function moveFilterBoxToTop(attribute) {
+ this.setState((0, _immutabilityHelper2.default)(this.state, {
+ maxZIndex: { $set: this.state.maxZIndex + 1 },
+ zIndices: _defineProperty({}, attribute, { $set: this.state.maxZIndex + 1 })
+ }));
+ }
+ }, {
+ key: 'isOpen',
+ value: function isOpen(dropdown) {
+ return this.state.openDropdown === dropdown;
+ }
+ }, {
+ key: 'makeDnDCell',
+ value: function makeDnDCell(items, onChange, classes) {
+ var _this7 = this;
+
+ return _react2.default.createElement(
+ _reactSortablejs2.default,
+ {
+ options: {
+ group: 'shared',
+ ghostClass: 'pvtPlaceholder',
+ filter: '.pvtFilterBox',
+ preventOnFilter: false
+ },
+ tag: 'td',
+ className: classes,
+ onChange: onChange
+ },
+ items.map(function (x) {
+ return _react2.default.createElement(DraggableAttribute, {
+ name: x,
+ key: x,
+ attrValues: _this7.state.attrValues[x],
+ valueFilter: _this7.props.valueFilter[x] || {},
+ sorter: (0, _Utilities.getSort)(_this7.props.sorters, x),
+ menuLimit: _this7.props.menuLimit,
+ setValuesInFilter: _this7.setValuesInFilter.bind(_this7),
+ addValuesToFilter: _this7.addValuesToFilter.bind(_this7),
+ moveFilterBoxToTop: _this7.moveFilterBoxToTop.bind(_this7),
+ removeValuesFromFilter: _this7.removeValuesFromFilter.bind(_this7),
+ zIndex: _this7.state.zIndices[x] || _this7.state.maxZIndex
+ });
+ })
+ );
+ }
+ }, {
+ key: 'render',
+ value: function render() {
+ var _this8 = this;
+
+ var numValsAllowed = this.props.aggregators[this.props.aggregatorName]([])().numInputs || 0;
+
+ var aggregatorCellOutlet = this.props.aggregators[this.props.aggregatorName]([])().outlet;
+
+ var rendererName = this.props.rendererName in this.props.renderers ? this.props.rendererName : Object.keys(this.props.renderers)[0];
+
+ var rendererCell = _react2.default.createElement(
+ 'td',
+ { className: 'pvtRenderers' },
+ _react2.default.createElement(Dropdown, {
+ current: rendererName,
+ values: Object.keys(this.props.renderers),
+ open: this.isOpen('renderer'),
+ zIndex: this.isOpen('renderer') ? this.state.maxZIndex + 1 : 1,
+ toggle: function toggle() {
+ return _this8.setState({
+ openDropdown: _this8.isOpen('renderer') ? false : 'renderer'
+ });
+ },
+ setValue: this.propUpdater('rendererName')
+ })
+ );
+
+ var sortIcons = {
+ key_a_to_z: {
+ rowSymbol: '↕',
+ colSymbol: '↔',
+ next: 'value_a_to_z'
+ },
+ value_a_to_z: {
+ rowSymbol: '↓',
+ colSymbol: '→',
+ next: 'value_z_to_a'
+ },
+ value_z_to_a: { rowSymbol: '↑', colSymbol: '←', next: 'key_a_to_z' }
+ };
+
+ var aggregatorCell = _react2.default.createElement(
+ 'td',
+ { className: 'pvtVals' },
+ _react2.default.createElement(Dropdown, {
+ current: this.props.aggregatorName,
+ values: Object.keys(this.props.aggregators),
+ open: this.isOpen('aggregators'),
+ zIndex: this.isOpen('aggregators') ? this.state.maxZIndex + 1 : 1,
+ toggle: function toggle() {
+ return _this8.setState({
+ openDropdown: _this8.isOpen('aggregators') ? false : 'aggregators'
+ });
+ },
+ setValue: this.propUpdater('aggregatorName')
+ }),
+ _react2.default.createElement(
+ 'a',
+ {
+ role: 'button',
+ className: 'pvtRowOrder',
+ onClick: function onClick() {
+ return _this8.propUpdater('rowOrder')(sortIcons[_this8.props.rowOrder].next);
+ }
+ },
+ sortIcons[this.props.rowOrder].rowSymbol
+ ),
+ _react2.default.createElement(
+ 'a',
+ {
+ role: 'button',
+ className: 'pvtColOrder',
+ onClick: function onClick() {
+ return _this8.propUpdater('colOrder')(sortIcons[_this8.props.colOrder].next);
+ }
+ },
+ sortIcons[this.props.colOrder].colSymbol
+ ),
+ numValsAllowed > 0 && _react2.default.createElement('br', null),
+ new Array(numValsAllowed).fill().map(function (n, i) {
+ return [_react2.default.createElement(Dropdown, {
+ key: i,
+ current: _this8.props.vals[i],
+ values: Object.keys(_this8.state.attrValues).filter(function (e) {
+ return !_this8.props.hiddenAttributes.includes(e) && !_this8.props.hiddenFromAggregators.includes(e);
+ }),
+ open: _this8.isOpen('val' + i),
+ zIndex: _this8.isOpen('val' + i) ? _this8.state.maxZIndex + 1 : 1,
+ toggle: function toggle() {
+ return _this8.setState({
+ openDropdown: _this8.isOpen('val' + i) ? false : 'val' + i
+ });
+ },
+ setValue: function setValue(value) {
+ return _this8.sendPropUpdate({
+ vals: { $splice: [[i, 1, value]] }
+ });
+ }
+ }), i + 1 !== numValsAllowed ? _react2.default.createElement('br', { key: 'br' + i }) : null];
+ }),
+ aggregatorCellOutlet && aggregatorCellOutlet(this.props.data)
+ );
+
+ var unusedAttrs = Object.keys(this.state.attrValues).filter(function (e) {
+ return !_this8.props.rows.includes(e) && !_this8.props.cols.includes(e) && !_this8.props.hiddenAttributes.includes(e) && !_this8.props.hiddenFromDragDrop.includes(e);
+ }).sort((0, _Utilities.sortAs)(this.state.unusedOrder));
+
+ var unusedLength = unusedAttrs.reduce(function (r, e) {
+ return r + e.length;
+ }, 0);
+ var horizUnused = unusedLength < this.props.unusedOrientationCutoff;
+
+ var unusedAttrsCell = this.makeDnDCell(unusedAttrs, function (order) {
+ return _this8.setState({ unusedOrder: order });
+ }, 'pvtAxisContainer pvtUnused ' + (horizUnused ? 'pvtHorizList' : 'pvtVertList'));
+
+ var colAttrs = this.props.cols.filter(function (e) {
+ return !_this8.props.hiddenAttributes.includes(e) && !_this8.props.hiddenFromDragDrop.includes(e);
+ });
+
+ var colAttrsCell = this.makeDnDCell(colAttrs, this.propUpdater('cols'), 'pvtAxisContainer pvtHorizList pvtCols');
+
+ var rowAttrs = this.props.rows.filter(function (e) {
+ return !_this8.props.hiddenAttributes.includes(e) && !_this8.props.hiddenFromDragDrop.includes(e);
+ });
+ var rowAttrsCell = this.makeDnDCell(rowAttrs, this.propUpdater('rows'), 'pvtAxisContainer pvtVertList pvtRows');
+ var outputCell = _react2.default.createElement(
+ 'td',
+ { className: 'pvtOutput' },
+ _react2.default.createElement(_PivotTable2.default, (0, _immutabilityHelper2.default)(this.props, {
+ data: { $set: this.state.materializedInput }
+ }))
+ );
+
+ if (horizUnused) {
+ return _react2.default.createElement(
+ 'table',
+ { className: 'pvtUi' },
+ _react2.default.createElement(
+ 'tbody',
+ { onClick: function onClick() {
+ return _this8.setState({ openDropdown: false });
+ } },
+ _react2.default.createElement(
+ 'tr',
+ null,
+ rendererCell,
+ unusedAttrsCell
+ ),
+ _react2.default.createElement(
+ 'tr',
+ null,
+ aggregatorCell,
+ colAttrsCell
+ ),
+ _react2.default.createElement(
+ 'tr',
+ null,
+ rowAttrsCell,
+ outputCell
+ )
+ )
+ );
+ }
+
+ return _react2.default.createElement(
+ 'table',
+ { className: 'pvtUi' },
+ _react2.default.createElement(
+ 'tbody',
+ { onClick: function onClick() {
+ return _this8.setState({ openDropdown: false });
+ } },
+ _react2.default.createElement(
+ 'tr',
+ null,
+ rendererCell,
+ aggregatorCell,
+ colAttrsCell
+ ),
+ _react2.default.createElement(
+ 'tr',
+ null,
+ unusedAttrsCell,
+ rowAttrsCell,
+ outputCell
+ )
+ )
+ );
+ }
+ }]);
+
+ return PivotTableUI;
+}(_react2.default.PureComponent);
+
+PivotTableUI.propTypes = Object.assign({}, _PivotTable2.default.propTypes, {
+ onChange: _propTypes2.default.func.isRequired,
+ hiddenAttributes: _propTypes2.default.arrayOf(_propTypes2.default.string),
+ hiddenFromAggregators: _propTypes2.default.arrayOf(_propTypes2.default.string),
+ hiddenFromDragDrop: _propTypes2.default.arrayOf(_propTypes2.default.string),
+ unusedOrientationCutoff: _propTypes2.default.number,
+ menuLimit: _propTypes2.default.number
+});
+
+PivotTableUI.defaultProps = Object.assign({}, _PivotTable2.default.defaultProps, {
+ hiddenAttributes: [],
+ hiddenFromAggregators: [],
+ hiddenFromDragDrop: [],
+ unusedOrientationCutoff: 85,
+ menuLimit: 500
+});
+
+exports.default = PivotTableUI;
+//# sourceMappingURL=PivotTableUI.js.map
\ No newline at end of file
diff --git a/PivotTableUI.js.map b/PivotTableUI.js.map
new file mode 100644
index 0000000..ad1c4c8
--- /dev/null
+++ b/PivotTableUI.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["src/PivotTableUI.jsx"],"names":["DraggableAttribute","props","state","open","filterText","value","valueFilter","removeValuesFromFilter","name","addValuesToFilter","x","toLowerCase","trim","includes","e","stopPropagation","setValuesInFilter","Object","keys","attrValues","filter","y","showMenu","length","menuLimit","values","shown","matchesFilter","bind","sort","sorter","display","cursor","zIndex","moveFilterBoxToTop","setState","target","map","toggleValue","selectOnly","filtered","toggleFilterBox","getFilterBox","React","Component","defaultProps","propTypes","PropTypes","string","isRequired","func","objectOf","number","bool","Dropdown","toggle","current","r","setValue","PureComponent","PivotTableUI","unusedOrder","zIndices","maxZIndex","openDropdown","materializedInput","materializeInput","data","nextData","newState","recordsProcessed","PivotData","forEachRecord","derivedAttributes","record","push","attr","null","command","onChange","key","sendPropUpdate","$set","attribute","reduce","v","$unset","dropdown","items","classes","group","ghostClass","preventOnFilter","sorters","numValsAllowed","aggregators","aggregatorName","numInputs","aggregatorCellOutlet","outlet","rendererName","renderers","rendererCell","isOpen","propUpdater","sortIcons","key_a_to_z","rowSymbol","colSymbol","next","value_a_to_z","value_z_to_a","aggregatorCell","rowOrder","colOrder","Array","fill","n","i","vals","hiddenAttributes","hiddenFromAggregators","$splice","unusedAttrs","rows","cols","hiddenFromDragDrop","unusedLength","horizUnused","unusedOrientationCutoff","unusedAttrsCell","makeDnDCell","order","colAttrs","colAttrsCell","rowAttrs","rowAttrsCell","outputCell","assign","PivotTable","arrayOf"],"mappings":";;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;AACA;;;;AACA;;;;AACA;;;;;;;;;;;;;;AAEA;AACA;;IAEaA,kB,WAAAA,kB;;;AACX,8BAAYC,KAAZ,EAAmB;AAAA;;AAAA,wIACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa,EAACC,MAAM,KAAP,EAAcC,YAAY,EAA1B,EAAb;AAFiB;AAGlB;;;;gCAEWC,K,EAAO;AACjB,UAAIA,SAAS,KAAKJ,K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B,EAF8C;AAGrEK,sBAAoB,EAHiD;AAIrEG,2BAAyB,EAJ4C;AAKrEzG,aAAW;AAL0D,CAA3C,CAA5B;;kBAQeoC,Y","file":"PivotTableUI.js","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport update from 'immutability-helper';\nimport {PivotData, sortAs, getSort} from './Utilities';\nimport PivotTable from './PivotTable';\nimport Sortable from 'react-sortablejs';\nimport Draggable from 'react-draggable';\n\n/* eslint-disable react/prop-types */\n// eslint can't see inherited propTypes!\n\nexport class DraggableAttribute extends React.Component {\n constructor(props) {\n super(props);\n this.state = {open: false, filterText: ''};\n }\n\n toggleValue(value) {\n if (value in this.props.valueFilter) {\n this.props.removeValuesFromFilter(this.props.name, [value]);\n } else {\n this.props.addValuesToFilter(this.props.name, [value]);\n }\n }\n\n matchesFilter(x) {\n return x\n .toLowerCase()\n .trim()\n .includes(this.state.filterText.toLowerCase().trim());\n }\n\n selectOnly(e, value) {\n e.stopPropagation();\n this.props.setValuesInFilter(\n this.props.name,\n Object.keys(this.props.attrValues).filter(y => y !== value)\n );\n }\n\n getFilterBox() {\n const showMenu =\n Object.keys(this.props.attrValues).length < this.props.menuLimit;\n\n const values = Object.keys(this.props.attrValues);\n const shown = values\n .filter(this.matchesFilter.bind(this))\n .sort(this.props.sorter);\n\n return (\n \n \n \n );\n }\n\n toggleFilterBox() {\n this.setState({open: !this.state.open});\n this.props.moveFilterBoxToTop(this.props.name);\n }\n\n render() {\n const filtered =\n Object.keys(this.props.valueFilter).length !== 0\n ? 'pvtFilteredAttribute'\n : '';\n return (\n
\n \n {this.props.name}\n \n {' '}\n ▾\n \n \n\n {this.state.open ? this.getFilterBox() : null}\n \n );\n }\n}\n\nDraggableAttribute.defaultProps = {\n valueFilter: {},\n};\n\nDraggableAttribute.propTypes = {\n name: PropTypes.string.isRequired,\n addValuesToFilter: PropTypes.func.isRequired,\n removeValuesFromFilter: PropTypes.func.isRequired,\n attrValues: PropTypes.objectOf(PropTypes.number).isRequired,\n valueFilter: PropTypes.objectOf(PropTypes.bool),\n moveFilterBoxToTop: PropTypes.func.isRequired,\n sorter: PropTypes.func.isRequired,\n menuLimit: PropTypes.number,\n zIndex: PropTypes.number,\n};\n\nexport class Dropdown extends React.PureComponent {\n render() {\n return (\n \n
{\n e.stopPropagation();\n this.props.toggle();\n }}\n className={\n 'pvtDropdownValue pvtDropdownCurrent ' +\n (this.props.open ? 'pvtDropdownCurrentOpen' : '')\n }\n role=\"button\"\n >\n
{this.props.open ? '×' : '▾'}
\n {this.props.current ||
}\n
\n\n {this.props.open && (\n
\n {this.props.values.map(r => (\n
{\n e.stopPropagation();\n if (this.props.current === r) {\n this.props.toggle();\n } else {\n this.props.setValue(r);\n }\n }}\n className={\n 'pvtDropdownValue ' +\n (r === this.props.current ? 'pvtDropdownActiveValue' : '')\n }\n >\n {r}\n
\n ))}\n
\n )}\n
\n );\n }\n}\n\nclass PivotTableUI extends React.PureComponent {\n constructor(props) {\n super(props);\n this.state = {\n unusedOrder: [],\n zIndices: {},\n maxZIndex: 1000,\n openDropdown: false,\n attrValues: {},\n materializedInput: [],\n };\n }\n\n componentDidMount() {\n this.materializeInput(this.props.data);\n }\n\n componentDidUpdate() {\n this.materializeInput(this.props.data);\n }\n\n materializeInput(nextData) {\n if (this.state.data === nextData) {\n return;\n }\n const newState = {\n data: nextData,\n attrValues: {},\n materializedInput: [],\n };\n let recordsProcessed = 0;\n PivotData.forEachRecord(\n newState.data,\n this.props.derivedAttributes,\n function(record) {\n newState.materializedInput.push(record);\n for (const attr of Object.keys(record)) {\n if (!(attr in newState.attrValues)) {\n newState.attrValues[attr] = {};\n if (recordsProcessed > 0) {\n newState.attrValues[attr].null = recordsProcessed;\n }\n }\n }\n for (const attr in newState.attrValues) {\n const value = attr in record ? record[attr] : 'null';\n if (!(value in newState.attrValues[attr])) {\n newState.attrValues[attr][value] = 0;\n }\n newState.attrValues[attr][value]++;\n }\n recordsProcessed++;\n }\n );\n this.setState(newState);\n }\n\n sendPropUpdate(command) {\n this.props.onChange(update(this.props, command));\n }\n\n propUpdater(key) {\n return value => this.sendPropUpdate({[key]: {$set: value}});\n }\n\n setValuesInFilter(attribute, values) {\n this.sendPropUpdate({\n valueFilter: {\n [attribute]: {\n $set: values.reduce((r, v) => {\n r[v] = true;\n return r;\n }, {}),\n },\n },\n });\n }\n\n addValuesToFilter(attribute, values) {\n if (attribute in this.props.valueFilter) {\n this.sendPropUpdate({\n valueFilter: {\n [attribute]: values.reduce((r, v) => {\n r[v] = {$set: true};\n return r;\n }, {}),\n },\n });\n } else {\n this.setValuesInFilter(attribute, values);\n }\n }\n\n removeValuesFromFilter(attribute, values) {\n this.sendPropUpdate({\n valueFilter: {[attribute]: {$unset: values}},\n });\n }\n\n moveFilterBoxToTop(attribute) {\n this.setState(\n update(this.state, {\n maxZIndex: {$set: this.state.maxZIndex + 1},\n zIndices: {[attribute]: {$set: this.state.maxZIndex + 1}},\n })\n );\n }\n\n isOpen(dropdown) {\n return this.state.openDropdown === dropdown;\n }\n\n makeDnDCell(items, onChange, classes) {\n return (\n \n {items.map(x => (\n \n ))}\n \n );\n }\n\n render() {\n const numValsAllowed =\n this.props.aggregators[this.props.aggregatorName]([])().numInputs || 0;\n\n const aggregatorCellOutlet = this.props.aggregators[\n this.props.aggregatorName\n ]([])().outlet;\n\n const rendererName =\n this.props.rendererName in this.props.renderers\n ? this.props.rendererName\n : Object.keys(this.props.renderers)[0];\n\n const rendererCell = (\n \n \n this.setState({\n openDropdown: this.isOpen('renderer') ? false : 'renderer',\n })\n }\n setValue={this.propUpdater('rendererName')}\n />\n | \n );\n\n const sortIcons = {\n key_a_to_z: {\n rowSymbol: '↕',\n colSymbol: '↔',\n next: 'value_a_to_z',\n },\n value_a_to_z: {\n rowSymbol: '↓',\n colSymbol: '→',\n next: 'value_z_to_a',\n },\n value_z_to_a: {rowSymbol: '↑', colSymbol: '←', next: 'key_a_to_z'},\n };\n\n const aggregatorCell = (\n \n \n this.setState({\n openDropdown: this.isOpen('aggregators') ? false : 'aggregators',\n })\n }\n setValue={this.propUpdater('aggregatorName')}\n />\n \n this.propUpdater('rowOrder')(sortIcons[this.props.rowOrder].next)\n }\n >\n {sortIcons[this.props.rowOrder].rowSymbol}\n \n \n this.propUpdater('colOrder')(sortIcons[this.props.colOrder].next)\n }\n >\n {sortIcons[this.props.colOrder].colSymbol}\n \n {numValsAllowed > 0 && }\n {new Array(numValsAllowed).fill().map((n, i) => [\n \n !this.props.hiddenAttributes.includes(e) &&\n !this.props.hiddenFromAggregators.includes(e)\n )}\n open={this.isOpen(`val${i}`)}\n zIndex={this.isOpen(`val${i}`) ? this.state.maxZIndex + 1 : 1}\n toggle={() =>\n this.setState({\n openDropdown: this.isOpen(`val${i}`) ? false : `val${i}`,\n })\n }\n setValue={value =>\n this.sendPropUpdate({\n vals: {$splice: [[i, 1, value]]},\n })\n }\n />,\n i + 1 !== numValsAllowed ? : null,\n ])}\n {aggregatorCellOutlet && aggregatorCellOutlet(this.props.data)}\n | \n );\n\n const unusedAttrs = Object.keys(this.state.attrValues)\n .filter(\n e =>\n !this.props.rows.includes(e) &&\n !this.props.cols.includes(e) &&\n !this.props.hiddenAttributes.includes(e) &&\n !this.props.hiddenFromDragDrop.includes(e)\n )\n .sort(sortAs(this.state.unusedOrder));\n\n const unusedLength = unusedAttrs.reduce((r, e) => r + e.length, 0);\n const horizUnused = unusedLength < this.props.unusedOrientationCutoff;\n\n const unusedAttrsCell = this.makeDnDCell(\n unusedAttrs,\n order => this.setState({unusedOrder: order}),\n `pvtAxisContainer pvtUnused ${\n horizUnused ? 'pvtHorizList' : 'pvtVertList'\n }`\n );\n\n const colAttrs = this.props.cols.filter(\n e =>\n !this.props.hiddenAttributes.includes(e) &&\n !this.props.hiddenFromDragDrop.includes(e)\n );\n\n const colAttrsCell = this.makeDnDCell(\n colAttrs,\n this.propUpdater('cols'),\n 'pvtAxisContainer pvtHorizList pvtCols'\n );\n\n const rowAttrs = this.props.rows.filter(\n e =>\n !this.props.hiddenAttributes.includes(e) &&\n !this.props.hiddenFromDragDrop.includes(e)\n );\n const rowAttrsCell = this.makeDnDCell(\n rowAttrs,\n this.propUpdater('rows'),\n 'pvtAxisContainer pvtVertList pvtRows'\n );\n const outputCell = (\n \n \n | \n );\n\n if (horizUnused) {\n return (\n \n this.setState({openDropdown: false})}>\n \n {rendererCell}\n {unusedAttrsCell}\n
\n \n {aggregatorCell}\n {colAttrsCell}\n
\n \n {rowAttrsCell}\n {outputCell}\n
\n \n
\n );\n }\n\n return (\n \n this.setState({openDropdown: false})}>\n \n {rendererCell}\n {aggregatorCell}\n {colAttrsCell}\n
\n \n {unusedAttrsCell}\n {rowAttrsCell}\n {outputCell}\n
\n \n
\n );\n }\n}\n\nPivotTableUI.propTypes = Object.assign({}, PivotTable.propTypes, {\n onChange: PropTypes.func.isRequired,\n hiddenAttributes: PropTypes.arrayOf(PropTypes.string),\n hiddenFromAggregators: PropTypes.arrayOf(PropTypes.string),\n hiddenFromDragDrop: PropTypes.arrayOf(PropTypes.string),\n unusedOrientationCutoff: PropTypes.number,\n menuLimit: PropTypes.number,\n});\n\nPivotTableUI.defaultProps = Object.assign({}, PivotTable.defaultProps, {\n hiddenAttributes: [],\n hiddenFromAggregators: [],\n hiddenFromDragDrop: [],\n unusedOrientationCutoff: 85,\n menuLimit: 500,\n});\n\nexport default PivotTableUI;\n"]}
\ No newline at end of file
diff --git a/PlotlyRenderers.js b/PlotlyRenderers.js
new file mode 100644
index 0000000..575dac7
--- /dev/null
+++ b/PlotlyRenderers.js
@@ -0,0 +1,265 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+exports.default = createPlotlyRenderers;
+
+var _react = require('react');
+
+var _react2 = _interopRequireDefault(_react);
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = _interopRequireDefault(_propTypes);
+
+var _Utilities = require('./Utilities');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+/* eslint-disable react/prop-types */
+// eslint can't see inherited propTypes!
+
+function makeRenderer(PlotlyComponent) {
+ var traceOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ var layoutOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
+ var transpose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
+
+ var Renderer = function (_React$PureComponent) {
+ _inherits(Renderer, _React$PureComponent);
+
+ function Renderer() {
+ _classCallCheck(this, Renderer);
+
+ return _possibleConstructorReturn(this, (Renderer.__proto__ || Object.getPrototypeOf(Renderer)).apply(this, arguments));
+ }
+
+ _createClass(Renderer, [{
+ key: 'render',
+ value: function render() {
+ var pivotData = new _Utilities.PivotData(this.props);
+ var rowKeys = pivotData.getRowKeys();
+ var colKeys = pivotData.getColKeys();
+ var traceKeys = transpose ? colKeys : rowKeys;
+ if (traceKeys.length === 0) {
+ traceKeys.push([]);
+ }
+ var datumKeys = transpose ? rowKeys : colKeys;
+ if (datumKeys.length === 0) {
+ datumKeys.push([]);
+ }
+
+ var fullAggName = this.props.aggregatorName;
+ var numInputs = this.props.aggregators[fullAggName]([])().numInputs || 0;
+ if (numInputs !== 0) {
+ fullAggName += ' of ' + this.props.vals.slice(0, numInputs).join(', ');
+ }
+
+ var data = traceKeys.map(function (traceKey) {
+ var values = [];
+ var labels = [];
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = datumKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var datumKey = _step.value;
+
+ var val = parseFloat(pivotData.getAggregator(transpose ? datumKey : traceKey, transpose ? traceKey : datumKey).value());
+ values.push(isFinite(val) ? val : null);
+ labels.push(datumKey.join('-') || ' ');
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+
+ var trace = { name: traceKey.join('-') || fullAggName };
+ if (traceOptions.type === 'pie') {
+ trace.values = values;
+ trace.labels = labels.length > 1 ? labels : [fullAggName];
+ } else {
+ trace.x = transpose ? values : labels;
+ trace.y = transpose ? labels : values;
+ }
+ return Object.assign(trace, traceOptions);
+ });
+
+ var titleText = fullAggName;
+ var hAxisTitle = transpose ? this.props.rows.join('-') : this.props.cols.join('-');
+ var groupByTitle = transpose ? this.props.cols.join('-') : this.props.rows.join('-');
+ if (hAxisTitle !== '') {
+ titleText += ' vs ' + hAxisTitle;
+ }
+ if (groupByTitle !== '') {
+ titleText += ' by ' + groupByTitle;
+ }
+
+ var layout = {
+ title: titleText,
+ hovermode: 'closest',
+ /* eslint-disable no-magic-numbers */
+ width: window.innerWidth / 1.5,
+ height: window.innerHeight / 1.4 - 50
+ /* eslint-enable no-magic-numbers */
+ };
+
+ if (traceOptions.type === 'pie') {
+ var columns = Math.ceil(Math.sqrt(data.length));
+ var rows = Math.ceil(data.length / columns);
+ layout.grid = { columns: columns, rows: rows };
+ data.forEach(function (d, i) {
+ d.domain = {
+ row: Math.floor(i / columns),
+ column: i - columns * Math.floor(i / columns)
+ };
+ if (data.length > 1) {
+ d.title = d.name;
+ }
+ });
+ if (data[0].labels.length === 1) {
+ layout.showlegend = false;
+ }
+ } else {
+ layout.xaxis = {
+ title: transpose ? fullAggName : null,
+ automargin: true
+ };
+ layout.yaxis = {
+ title: transpose ? null : fullAggName,
+ automargin: true
+ };
+ }
+
+ return _react2.default.createElement(PlotlyComponent, {
+ data: data,
+ layout: Object.assign(layout, layoutOptions, this.props.plotlyOptions),
+ config: this.props.plotlyConfig,
+ onUpdate: this.props.onRendererUpdate
+ });
+ }
+ }]);
+
+ return Renderer;
+ }(_react2.default.PureComponent);
+
+ Renderer.defaultProps = Object.assign({}, _Utilities.PivotData.defaultProps, {
+ plotlyOptions: {},
+ plotlyConfig: {}
+ });
+ Renderer.propTypes = Object.assign({}, _Utilities.PivotData.propTypes, {
+ plotlyOptions: _propTypes2.default.object,
+ plotlyConfig: _propTypes2.default.object,
+ onRendererUpdate: _propTypes2.default.func
+ });
+
+ return Renderer;
+}
+
+function makeScatterRenderer(PlotlyComponent) {
+ var Renderer = function (_React$PureComponent2) {
+ _inherits(Renderer, _React$PureComponent2);
+
+ function Renderer() {
+ _classCallCheck(this, Renderer);
+
+ return _possibleConstructorReturn(this, (Renderer.__proto__ || Object.getPrototypeOf(Renderer)).apply(this, arguments));
+ }
+
+ _createClass(Renderer, [{
+ key: 'render',
+ value: function render() {
+ var pivotData = new _Utilities.PivotData(this.props);
+ var rowKeys = pivotData.getRowKeys();
+ var colKeys = pivotData.getColKeys();
+ if (rowKeys.length === 0) {
+ rowKeys.push([]);
+ }
+ if (colKeys.length === 0) {
+ colKeys.push([]);
+ }
+
+ var data = { x: [], y: [], text: [], type: 'scatter', mode: 'markers' };
+
+ rowKeys.map(function (rowKey) {
+ colKeys.map(function (colKey) {
+ var v = pivotData.getAggregator(rowKey, colKey).value();
+ if (v !== null) {
+ data.x.push(colKey.join('-'));
+ data.y.push(rowKey.join('-'));
+ data.text.push(v);
+ }
+ });
+ });
+
+ var layout = {
+ title: this.props.rows.join('-') + ' vs ' + this.props.cols.join('-'),
+ hovermode: 'closest',
+ /* eslint-disable no-magic-numbers */
+ xaxis: { title: this.props.cols.join('-'), automargin: true },
+ yaxis: { title: this.props.rows.join('-'), automargin: true },
+ width: window.innerWidth / 1.5,
+ height: window.innerHeight / 1.4 - 50
+ /* eslint-enable no-magic-numbers */
+ };
+
+ return _react2.default.createElement(PlotlyComponent, {
+ data: [data],
+ layout: Object.assign(layout, this.props.plotlyOptions),
+ config: this.props.plotlyConfig,
+ onUpdate: this.props.onRendererUpdate
+ });
+ }
+ }]);
+
+ return Renderer;
+ }(_react2.default.PureComponent);
+
+ Renderer.defaultProps = Object.assign({}, _Utilities.PivotData.defaultProps, {
+ plotlyOptions: {},
+ plotlyConfig: {}
+ });
+ Renderer.propTypes = Object.assign({}, _Utilities.PivotData.propTypes, {
+ plotlyOptions: _propTypes2.default.object,
+ plotlyConfig: _propTypes2.default.object,
+ onRendererUpdate: _propTypes2.default.func
+ });
+
+ return Renderer;
+}
+
+function createPlotlyRenderers(PlotlyComponent) {
+ return {
+ 'Grouped Column Chart': makeRenderer(PlotlyComponent, { type: 'bar' }, { barmode: 'group' }),
+ 'Stacked Column Chart': makeRenderer(PlotlyComponent, { type: 'bar' }, { barmode: 'relative' }),
+ 'Grouped Bar Chart': makeRenderer(PlotlyComponent, { type: 'bar', orientation: 'h' }, { barmode: 'group' }, true),
+ 'Stacked Bar Chart': makeRenderer(PlotlyComponent, { type: 'bar', orientation: 'h' }, { barmode: 'relative' }, true),
+ 'Line Chart': makeRenderer(PlotlyComponent),
+ 'Dot Chart': makeRenderer(PlotlyComponent, { mode: 'markers' }, {}, true),
+ 'Area Chart': makeRenderer(PlotlyComponent, { stackgroup: 1 }),
+ 'Scatter Chart': makeScatterRenderer(PlotlyComponent),
+ 'Multiple Pie Chart': makeRenderer(PlotlyComponent, { type: 'pie', scalegroup: 1, hoverinfo: 'label+value', textinfo: 'none' }, {}, true)
+ };
+}
+module.exports = exports['default'];
+//# sourceMappingURL=PlotlyRenderers.js.map
\ No newline at end of file
diff --git a/PlotlyRenderers.js.map b/PlotlyRenderers.js.map
new file mode 100644
index 0000000..ecbc545
--- /dev/null
+++ b/PlotlyRenderers.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["src/PlotlyRenderers.jsx"],"names":["createPlotlyRenderers","makeRenderer","PlotlyComponent","traceOptions","layoutOptions","transpose","Renderer","pivotData","PivotData","props","rowKeys","getRowKeys","colKeys","getColKeys","traceKeys","length","push","datumKeys","fullAggName","aggregatorName","numInputs","aggregators","vals","slice","join","data","map","values","labels","datumKey","val","parseFloat","getAggregator","traceKey","value","isFinite","trace","name","type","x","y","Object","assign","titleText","hAxisTitle","rows","cols","groupByTitle","layout","title","hovermode","width","window","innerWidth","height","innerHeight","columns","Math","ceil","sqrt","grid","forEach","d","i","domain","row","floor","column","showlegend","xaxis","automargin","yaxis","plotlyOptions","plotlyConfig","onRendererUpdate","React","PureComponent","defaultProps","propTypes","PropTypes","object","func","makeScatterRenderer","text","mode","v","rowKey","colKey","barmode","orientation","stackgroup","scalegroup","hoverinfo","textinfo"],"mappings":";;;;;;;;kBAuMwBA,qB;;AAvMxB;;;;AACA;;;;AACA;;;;;;;;;;AAEA;AACA;;AAEA,SAASC,YAAT,CACEC,eADF,EAKE;AAAA,MAHAC,YAGA,uEAHe,EAGf;AAAA,MAFAC,aAEA,uEAFgB,EAEhB;AAAA,MADAC,SACA,uEADY,KACZ;;AAAA,MACMC,QADN;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA,+BAEW;AACP,YAAMC,YAAY,IAAIC,oBAAJ,CAAc,KAAKC,KAAnB,CAAlB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3E,QAAP;AACD;;AAEc,SAASN,qBAAT,CAA+BE,eAA/B,EAAgD;AAC7D,SAAO;AACL,4BAAwBD,aACtBC,eADsB,EAEtB,EAACoC,MAAM,KAAP,EAFsB,EAGtB,EAACkD,SAAS,OAAV,EAHsB,CADnB;AAML,4BAAwBvF,aACtBC,eADsB,EAEtB,EAACoC,MAAM,KAAP,EAFsB,EAGtB,EAACkD,SAAS,UAAV,EAHsB,CANnB;AAWL,yBAAqBvF,aACnBC,eADmB,EAEnB,EAACoC,MAAM,KAAP,EAAcmD,aAAa,GAA3B,EAFmB,EAGnB,EAACD,SAAS,OAAV,EAHmB,EAInB,IAJmB,CAXhB;AAiBL,yBAAqBvF,aACnBC,eADmB,EAEnB,EAACoC,MAAM,KAAP,EAAcmD,aAAa,GAA3B,EAFmB,EAGnB,EAACD,SAAS,UAAV,EAHmB,EAInB,IAJmB,CAjBhB;AAuBL,kBAAcvF,aAAaC,eAAb,CAvBT;AAwBL,iBAAaD,aAAaC,eAAb,EAA8B,EAACkF,MAAM,SAAP,EAA9B,EAAiD,EAAjD,EAAqD,IAArD,CAxBR;AAyBL,kBAAcnF,aAAaC,eAAb,EAA8B,EAACwF,YAAY,CAAb,EAA9B,CAzBT;AA0BL,qBAAiBR,oBAAoBhF,eAApB,CA1BZ;AA2BL,0BAAsBD,aACpBC,eADoB,EAEpB,EAACoC,MAAM,KAAP,EAAcqD,YAAY,CAA1B,EAA6BC,WAAW,aAAxC,EAAuDC,UAAU,MAAjE,EAFoB,EAGpB,EAHoB,EAIpB,IAJoB;AA3BjB,GAAP;AAkCD","file":"PlotlyRenderers.js","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {PivotData} from './Utilities';\n\n/* eslint-disable react/prop-types */\n// eslint can't see inherited propTypes!\n\nfunction makeRenderer(\n PlotlyComponent,\n traceOptions = {},\n layoutOptions = {},\n transpose = false\n) {\n class Renderer extends React.PureComponent {\n render() {\n const pivotData = new PivotData(this.props);\n const rowKeys = pivotData.getRowKeys();\n const colKeys = pivotData.getColKeys();\n const traceKeys = transpose ? colKeys : rowKeys;\n if (traceKeys.length === 0) {\n traceKeys.push([]);\n }\n const datumKeys = transpose ? rowKeys : colKeys;\n if (datumKeys.length === 0) {\n datumKeys.push([]);\n }\n\n let fullAggName = this.props.aggregatorName;\n const numInputs =\n this.props.aggregators[fullAggName]([])().numInputs || 0;\n if (numInputs !== 0) {\n fullAggName += ` of ${this.props.vals.slice(0, numInputs).join(', ')}`;\n }\n\n const data = traceKeys.map(traceKey => {\n const values = [];\n const labels = [];\n for (const datumKey of datumKeys) {\n const val = parseFloat(\n pivotData\n .getAggregator(\n transpose ? datumKey : traceKey,\n transpose ? traceKey : datumKey\n )\n .value()\n );\n values.push(isFinite(val) ? val : null);\n labels.push(datumKey.join('-') || ' ');\n }\n const trace = {name: traceKey.join('-') || fullAggName};\n if (traceOptions.type === 'pie') {\n trace.values = values;\n trace.labels = labels.length > 1 ? labels : [fullAggName];\n } else {\n trace.x = transpose ? values : labels;\n trace.y = transpose ? labels : values;\n }\n return Object.assign(trace, traceOptions);\n });\n\n let titleText = fullAggName;\n const hAxisTitle = transpose\n ? this.props.rows.join('-')\n : this.props.cols.join('-');\n const groupByTitle = transpose\n ? this.props.cols.join('-')\n : this.props.rows.join('-');\n if (hAxisTitle !== '') {\n titleText += ` vs ${hAxisTitle}`;\n }\n if (groupByTitle !== '') {\n titleText += ` by ${groupByTitle}`;\n }\n\n const layout = {\n title: titleText,\n hovermode: 'closest',\n /* eslint-disable no-magic-numbers */\n width: window.innerWidth / 1.5,\n height: window.innerHeight / 1.4 - 50,\n /* eslint-enable no-magic-numbers */\n };\n\n if (traceOptions.type === 'pie') {\n const columns = Math.ceil(Math.sqrt(data.length));\n const rows = Math.ceil(data.length / columns);\n layout.grid = {columns, rows};\n data.forEach((d, i) => {\n d.domain = {\n row: Math.floor(i / columns),\n column: i - columns * Math.floor(i / columns),\n };\n if (data.length > 1) {\n d.title = d.name;\n }\n });\n if (data[0].labels.length === 1) {\n layout.showlegend = false;\n }\n } else {\n layout.xaxis = {\n title: transpose ? fullAggName : null,\n automargin: true,\n };\n layout.yaxis = {\n title: transpose ? null : fullAggName,\n automargin: true,\n };\n }\n\n return (\n \n );\n }\n }\n\n Renderer.defaultProps = Object.assign({}, PivotData.defaultProps, {\n plotlyOptions: {},\n plotlyConfig: {},\n });\n Renderer.propTypes = Object.assign({}, PivotData.propTypes, {\n plotlyOptions: PropTypes.object,\n plotlyConfig: PropTypes.object,\n onRendererUpdate: PropTypes.func,\n });\n\n return Renderer;\n}\n\nfunction makeScatterRenderer(PlotlyComponent) {\n class Renderer extends React.PureComponent {\n render() {\n const pivotData = new PivotData(this.props);\n const rowKeys = pivotData.getRowKeys();\n const colKeys = pivotData.getColKeys();\n if (rowKeys.length === 0) {\n rowKeys.push([]);\n }\n if (colKeys.length === 0) {\n colKeys.push([]);\n }\n\n const data = {x: [], y: [], text: [], type: 'scatter', mode: 'markers'};\n\n rowKeys.map(rowKey => {\n colKeys.map(colKey => {\n const v = pivotData.getAggregator(rowKey, colKey).value();\n if (v !== null) {\n data.x.push(colKey.join('-'));\n data.y.push(rowKey.join('-'));\n data.text.push(v);\n }\n });\n });\n\n const layout = {\n title: this.props.rows.join('-') + ' vs ' + this.props.cols.join('-'),\n hovermode: 'closest',\n /* eslint-disable no-magic-numbers */\n xaxis: {title: this.props.cols.join('-'), automargin: true},\n yaxis: {title: this.props.rows.join('-'), automargin: true},\n width: window.innerWidth / 1.5,\n height: window.innerHeight / 1.4 - 50,\n /* eslint-enable no-magic-numbers */\n };\n\n return (\n \n );\n }\n }\n\n Renderer.defaultProps = Object.assign({}, PivotData.defaultProps, {\n plotlyOptions: {},\n plotlyConfig: {},\n });\n Renderer.propTypes = Object.assign({}, PivotData.propTypes, {\n plotlyOptions: PropTypes.object,\n plotlyConfig: PropTypes.object,\n onRendererUpdate: PropTypes.func,\n });\n\n return Renderer;\n}\n\nexport default function createPlotlyRenderers(PlotlyComponent) {\n return {\n 'Grouped Column Chart': makeRenderer(\n PlotlyComponent,\n {type: 'bar'},\n {barmode: 'group'}\n ),\n 'Stacked Column Chart': makeRenderer(\n PlotlyComponent,\n {type: 'bar'},\n {barmode: 'relative'}\n ),\n 'Grouped Bar Chart': makeRenderer(\n PlotlyComponent,\n {type: 'bar', orientation: 'h'},\n {barmode: 'group'},\n true\n ),\n 'Stacked Bar Chart': makeRenderer(\n PlotlyComponent,\n {type: 'bar', orientation: 'h'},\n {barmode: 'relative'},\n true\n ),\n 'Line Chart': makeRenderer(PlotlyComponent),\n 'Dot Chart': makeRenderer(PlotlyComponent, {mode: 'markers'}, {}, true),\n 'Area Chart': makeRenderer(PlotlyComponent, {stackgroup: 1}),\n 'Scatter Chart': makeScatterRenderer(PlotlyComponent),\n 'Multiple Pie Chart': makeRenderer(\n PlotlyComponent,\n {type: 'pie', scalegroup: 1, hoverinfo: 'label+value', textinfo: 'none'},\n {},\n true\n ),\n };\n}\n"]}
\ No newline at end of file
diff --git a/README.md b/README.md
index 78d5580..4dbf3b5 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,263 @@
# v-react-pivottable
-Customización de libreria de react-pivottable
\ No newline at end of file
+`v-react-pivottable` is a custom version of `react-pivottable` is a React-based pivot table library with drag'n'drop
+functionality. It is a React port of the jQuery-based
+[PivotTable.js](https://pivottable.js.org/) by the same author.
+
+`react-pivottable` is part of Plotly's [React Component Suite](https://plot.ly/products/react/) for building data visualization Web apps and products.
+
+## What does it do & where is the demo?
+
+`react-pivottable`'s function is to enable data exploration and analysis by
+summarizing a data set into table or [Plotly.js](https://plot.ly/javascript/)
+chart with a true 2-d drag'n'drop UI, very similar to the one found in older
+versions of Microsoft Excel.
+
+A [live demo can be found here](https://react-pivottable.js.org/).
+
+
+
+## How can I use it in my project?
+
+### Drag'n'drop UI with Table output only
+
+Installation is via NPM and has a peer dependency on React:
+
+```
+npm install --save react-pivottable react react-dom
+```
+
+Basic usage is as follows. Note that `PivotTableUI` is a "dumb component" that
+maintains essentially no state of its own.
+
+```js
+import React from 'react';
+import ReactDOM from 'react-dom';
+import PivotTableUI from 'react-pivottable/PivotTableUI';
+import 'react-pivottable/pivottable.css';
+
+// see documentation for supported input formats
+const data = [['attribute', 'attribute2'], ['value1', 'value2']];
+
+class App extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = props;
+ }
+
+ render() {
+ return (
+ this.setState(s)}
+ {...this.state}
+ />
+ );
+ }
+}
+
+ReactDOM.render(, document.body);
+```
+
+### Drag'n'drop UI with Plotly charts as well as Table output
+
+The Plotly `react-plotly.js` component can be passed in via dependency
+injection. It has a peer dependency on `plotly.js`.
+
+**Important:** If you build your project using webpack, you'll have to follow
+[these instructions](https://github.com/plotly/plotly.js#building-plotlyjs-with-webpack)
+in order to successfully bundle `plotly.js`. See below for how to avoid having
+to bundle `plotly.js`.
+
+```
+npm install --save react-pivottable react-plotly.js plotly.js react react-dom
+```
+
+To add the Plotly renderers to your app, you can use the following pattern:
+
+```js
+import React from 'react';
+import PivotTableUI from 'react-pivottable/PivotTableUI';
+import 'react-pivottable/pivottable.css';
+import TableRenderers from 'react-pivottable/TableRenderers';
+import Plot from 'react-plotly.js';
+import createPlotlyRenderers from 'react-pivottable/PlotlyRenderers';
+
+// create Plotly renderers via dependency injection
+const PlotlyRenderers = createPlotlyRenderers(Plot);
+
+// see documentation for supported input formats
+const data = [['attribute', 'attribute2'], ['value1', 'value2']];
+
+class App extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = props;
+ }
+
+ render() {
+ return (
+ this.setState(s)}
+ renderers={Object.assign({}, TableRenderers, PlotlyRenderers)}
+ {...this.state}
+ />
+ );
+ }
+}
+
+ReactDOM.render(, document.body);
+```
+
+#### With external `plotly.js`
+
+If you would rather not install and bundle `plotly.js` but rather get it into
+your app via something like `
+
+
+
+