From 84e9b3e750c21ebf7b4c2095af3bfcdabfebecad Mon Sep 17 00:00:00 2001 From: huy Date: Thu, 8 Jun 2017 18:32:12 +0900 Subject: [PATCH 1/2] Up to date react and babel modules. --- package.json | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index ecc929e..989ea1b 100644 --- a/package.json +++ b/package.json @@ -14,19 +14,19 @@ "author": "ElixirDoc team", "license": "Apache 2.0", "devDependencies": { - "babel-cli": "^6.6.4", - "babel-core": "^6.5.2", + "babel-cli": "^6.24.1", + "babel-core": "^6.24.1", "babel-eslint": "^3.1.9", - "babel-loader": "^6.2.3", + "babel-loader": "^6.4.1", "babel-plugin-add-module-exports": "^0.1.2", "babel-plugin-react-transform": "^2.0.0", "babel-plugin-transform-react-remove-prop-types": "^0.2.2", "babel-plugin-transform-runtime": "^6.5.2", - "babel-polyfill": "^6.5.0", - "babel-preset-es2015": "^6.5.0", - "babel-preset-react": "^6.5.0", - "babel-preset-react-hmre": "1.0.1", - "babel-preset-stage-0": "^6.5.0", + "babel-polyfill": "^6.23.0", + "babel-preset-es2015": "^6.24.1", + "babel-preset-react": "^6.24.1", + "babel-preset-react-hmre": "1.1.1", + "babel-preset-stage-0": "^6.24.1", "css-loader": "^0.18.0", "dsv-loader": "^1.0.0", "express": "^4.13.4", @@ -38,13 +38,14 @@ "react-router": "^2.0.0", "style-loader": "^0.12.4", "tapable": "^0.2.4", + "webpack": "^1.12.2", "webpack-dev-middleware": "^1.5.1", "webpack-dev-server": "^1.11.0", "webpack-hot-middleware": "^2.9.1" }, "peerDependencies": { - "react": "^0.14.7", - "react-dom": "^0.14.7" + "react": "^15.4.2", + "react-dom": "^15.4.2" }, "dependencies": { "d3-array": "^0.7.1", From e64c60661997dd705478b03fa99594930204ee5c Mon Sep 17 00:00:00 2001 From: huy Date: Thu, 8 Jun 2017 19:08:11 +0900 Subject: [PATCH 2/2] Add /lib forder and change react-d3-* repository. --- .gitignore | 1 - lib/area.js | 104 +++++++++++++++++++++++++++++++++++ lib/area_stack.js | 103 +++++++++++++++++++++++++++++++++++ lib/bar.js | 105 +++++++++++++++++++++++++++++++++++ lib/bar_group.js | 105 +++++++++++++++++++++++++++++++++++ lib/bar_group_horizontal.js | 104 +++++++++++++++++++++++++++++++++++ lib/bar_horizontal.js | 104 +++++++++++++++++++++++++++++++++++ lib/bar_stack.js | 106 ++++++++++++++++++++++++++++++++++++ lib/bar_stack_horizontal.js | 105 +++++++++++++++++++++++++++++++++++ lib/commonProps.js | 56 +++++++++++++++++++ lib/index.js | 65 ++++++++++++++++++++++ lib/line.js | 104 +++++++++++++++++++++++++++++++++++ lib/pie.js | 96 ++++++++++++++++++++++++++++++++ lib/scatter.js | 102 ++++++++++++++++++++++++++++++++++ package.json | 4 +- 15 files changed, 1261 insertions(+), 3 deletions(-) create mode 100644 lib/area.js create mode 100644 lib/area_stack.js create mode 100644 lib/bar.js create mode 100644 lib/bar_group.js create mode 100644 lib/bar_group_horizontal.js create mode 100644 lib/bar_horizontal.js create mode 100644 lib/bar_stack.js create mode 100644 lib/bar_stack_horizontal.js create mode 100644 lib/commonProps.js create mode 100644 lib/index.js create mode 100644 lib/line.js create mode 100644 lib/pie.js create mode 100644 lib/scatter.js diff --git a/.gitignore b/.gitignore index 0c01323..9de7874 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .DS_Store node_modules example/dist/ -lib diff --git a/lib/area.js b/lib/area.js new file mode 100644 index 0000000..8afc602 --- /dev/null +++ b/lib/area.js @@ -0,0 +1,104 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +var _commonProps2 = _interopRequireDefault(_commonProps); + +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; } + +var AreaChart = function (_Component) { + _inherits(AreaChart, _Component); + + function AreaChart(props) { + _classCallCheck(this, AreaChart); + + return _possibleConstructorReturn(this, (AreaChart.__proto__ || Object.getPrototypeOf(AreaChart)).call(this, props)); + } + + _createClass(AreaChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries + }), + _react2.default.createElement(_reactD3Shape.Area, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return AreaChart; +}(_react.Component); + +AreaChart.defaultProps = _extends({ + showScatter: false +}, _commonProps2.default); +AreaChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = AreaChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/area_stack.js b/lib/area_stack.js new file mode 100644 index 0000000..d1c274e --- /dev/null +++ b/lib/area_stack.js @@ -0,0 +1,103 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +var _commonProps2 = _interopRequireDefault(_commonProps); + +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; } + +var AreaStackChart = function (_Component) { + _inherits(AreaStackChart, _Component); + + function AreaStackChart(props) { + _classCallCheck(this, AreaStackChart); + + return _possibleConstructorReturn(this, (AreaStackChart.__proto__ || Object.getPrototypeOf(AreaStackChart)).call(this, props)); + } + + _createClass(AreaStackChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries, + stack: true + }), + _react2.default.createElement(_reactD3Shape.AreaStack, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return AreaStackChart; +}(_react.Component); + +AreaStackChart.defaultProps = _commonProps2.default; +AreaStackChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = AreaStackChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/bar.js b/lib/bar.js new file mode 100644 index 0000000..f0c103c --- /dev/null +++ b/lib/bar.js @@ -0,0 +1,105 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +var _commonProps2 = _interopRequireDefault(_commonProps); + +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; } + +var BarChart = function (_Component) { + _inherits(BarChart, _Component); + + function BarChart(props) { + _classCallCheck(this, BarChart); + + return _possibleConstructorReturn(this, (BarChart.__proto__ || Object.getPrototypeOf(BarChart)).call(this, props)); + } + + _createClass(BarChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries + }), + _react2.default.createElement(_reactD3Shape.Bar, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return BarChart; +}(_react.Component); + +BarChart.defaultProps = _extends({ + onMouseOver: function onMouseOver() {}, + onMouseOut: function onMouseOut() {} +}, _commonProps2.default); +BarChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = BarChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/bar_group.js b/lib/bar_group.js new file mode 100644 index 0000000..77beaa2 --- /dev/null +++ b/lib/bar_group.js @@ -0,0 +1,105 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +var _commonProps2 = _interopRequireDefault(_commonProps); + +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; } + +var BarGroupChart = function (_Component) { + _inherits(BarGroupChart, _Component); + + function BarGroupChart(props) { + _classCallCheck(this, BarGroupChart); + + return _possibleConstructorReturn(this, (BarGroupChart.__proto__ || Object.getPrototypeOf(BarGroupChart)).call(this, props)); + } + + _createClass(BarGroupChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries + }), + _react2.default.createElement(_reactD3Shape.BarGroup, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return BarGroupChart; +}(_react.Component); + +BarGroupChart.defaultProps = _extends({ + onMouseOver: function onMouseOver() {}, + onMouseOut: function onMouseOut() {} +}, _commonProps2.default); +BarGroupChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = BarGroupChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/bar_group_horizontal.js b/lib/bar_group_horizontal.js new file mode 100644 index 0000000..3a265da --- /dev/null +++ b/lib/bar_group_horizontal.js @@ -0,0 +1,104 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +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; } + +var BarGroupHorizontalChart = function (_Component) { + _inherits(BarGroupHorizontalChart, _Component); + + function BarGroupHorizontalChart(props) { + _classCallCheck(this, BarGroupHorizontalChart); + + return _possibleConstructorReturn(this, (BarGroupHorizontalChart.__proto__ || Object.getPrototypeOf(BarGroupHorizontalChart)).call(this, props)); + } + + _createClass(BarGroupHorizontalChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries, + horizontal: true + }), + _react2.default.createElement(_reactD3Shape.BarGroupHorizontal, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return BarGroupHorizontalChart; +}(_react.Component); + +BarGroupHorizontalChart.defaultProps = _extends({ + onMouseOver: function onMouseOver() {}, + onMouseOut: function onMouseOut() {} +}, _commonProps.horizontalProps); +BarGroupHorizontalChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = BarGroupHorizontalChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/bar_horizontal.js b/lib/bar_horizontal.js new file mode 100644 index 0000000..1e9fb4d --- /dev/null +++ b/lib/bar_horizontal.js @@ -0,0 +1,104 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +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; } + +var BarHorizontalChart = function (_Component) { + _inherits(BarHorizontalChart, _Component); + + function BarHorizontalChart(props) { + _classCallCheck(this, BarHorizontalChart); + + return _possibleConstructorReturn(this, (BarHorizontalChart.__proto__ || Object.getPrototypeOf(BarHorizontalChart)).call(this, props)); + } + + _createClass(BarHorizontalChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries, + horizontal: true + }), + _react2.default.createElement(_reactD3Shape.BarHorizontal, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return BarHorizontalChart; +}(_react.Component); + +BarHorizontalChart.defaultProps = _extends({ + onMouseOver: function onMouseOver() {}, + onMouseOut: function onMouseOut() {} +}, _commonProps.horizontalProps); +BarHorizontalChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = BarHorizontalChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/bar_stack.js b/lib/bar_stack.js new file mode 100644 index 0000000..b87a8a5 --- /dev/null +++ b/lib/bar_stack.js @@ -0,0 +1,106 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +var _commonProps2 = _interopRequireDefault(_commonProps); + +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; } + +var BarStackChart = function (_Component) { + _inherits(BarStackChart, _Component); + + function BarStackChart(props) { + _classCallCheck(this, BarStackChart); + + return _possibleConstructorReturn(this, (BarStackChart.__proto__ || Object.getPrototypeOf(BarStackChart)).call(this, props)); + } + + _createClass(BarStackChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries, + stack: true + }), + _react2.default.createElement(_reactD3Shape.BarStack, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return BarStackChart; +}(_react.Component); + +BarStackChart.defaultProps = _extends({ + onMouseOver: function onMouseOver() {}, + onMouseOut: function onMouseOut() {} +}, _commonProps2.default); +BarStackChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = BarStackChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/bar_stack_horizontal.js b/lib/bar_stack_horizontal.js new file mode 100644 index 0000000..9d0bd13 --- /dev/null +++ b/lib/bar_stack_horizontal.js @@ -0,0 +1,105 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +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; } + +var BarStackChart = function (_Component) { + _inherits(BarStackChart, _Component); + + function BarStackChart(props) { + _classCallCheck(this, BarStackChart); + + return _possibleConstructorReturn(this, (BarStackChart.__proto__ || Object.getPrototypeOf(BarStackChart)).call(this, props)); + } + + _createClass(BarStackChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries, + stack: true, + horizontal: true + }), + _react2.default.createElement(_reactD3Shape.BarStackHorizontal, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return BarStackChart; +}(_react.Component); + +BarStackChart.defaultProps = _extends({ + onMouseOver: function onMouseOver() {}, + onMouseOut: function onMouseOut() {} +}, _commonProps.horizontalProps); +BarStackChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = BarStackChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/commonProps.js b/lib/commonProps.js new file mode 100644 index 0000000..9f4378c --- /dev/null +++ b/lib/commonProps.js @@ -0,0 +1,56 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.pieProps = exports.horizontalProps = undefined; + +var _d3Scale = require('d3-scale'); + +var _d3Scale2 = _interopRequireDefault(_d3Scale); + +var _d3Array = require('d3-array'); + +var _d3Array2 = _interopRequireDefault(_d3Array); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var width = 960; +var height = 500; +var margins = { top: 40, right: 100, bottom: 40, left: 100 }; + +exports.default = { + width: width, + height: height, + margins: margins, + y: function y(d) { + return +d; + }, + xScale: 'linear', + yScale: 'linear', + showXGrid: true, + showYGrid: true, + showLegend: true +}; +var horizontalProps = exports.horizontalProps = { + width: width, + height: height, + margins: margins, + x: function x(d) { + return +d; + }, + xScale: 'linear', + yScale: 'linear', + showXGrid: true, + showYGrid: true, + showLegend: true +}; + +var pieProps = exports.pieProps = { + width: width, + height: height, + margins: margins, + innerRadius: 0, + categoricalColors: _d3Scale2.default.scaleCategory10(), + pieSort: _d3Array2.default.descending +}; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..6203344 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,65 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.PieChart = exports.BarStackHorizontalChart = exports.BarStackChart = exports.AreaStackChart = exports.BarGroupHorizontalChart = exports.BarGroupChart = exports.BarHorizontalChart = exports.BarChart = exports.ScatterPlot = exports.AreaChart = exports.LineChart = undefined; + +var _line = require('./line'); + +var _line2 = _interopRequireDefault(_line); + +var _area = require('./area'); + +var _area2 = _interopRequireDefault(_area); + +var _scatter = require('./scatter'); + +var _scatter2 = _interopRequireDefault(_scatter); + +var _bar = require('./bar'); + +var _bar2 = _interopRequireDefault(_bar); + +var _bar_horizontal = require('./bar_horizontal'); + +var _bar_horizontal2 = _interopRequireDefault(_bar_horizontal); + +var _bar_group = require('./bar_group'); + +var _bar_group2 = _interopRequireDefault(_bar_group); + +var _bar_group_horizontal = require('./bar_group_horizontal'); + +var _bar_group_horizontal2 = _interopRequireDefault(_bar_group_horizontal); + +var _area_stack = require('./area_stack'); + +var _area_stack2 = _interopRequireDefault(_area_stack); + +var _bar_stack = require('./bar_stack'); + +var _bar_stack2 = _interopRequireDefault(_bar_stack); + +var _bar_stack_horizontal = require('./bar_stack_horizontal'); + +var _bar_stack_horizontal2 = _interopRequireDefault(_bar_stack_horizontal); + +var _pie = require('./pie'); + +var _pie2 = _interopRequireDefault(_pie); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.LineChart = _line2.default; // Export high level charts + +exports.AreaChart = _area2.default; +exports.ScatterPlot = _scatter2.default; +exports.BarChart = _bar2.default; +exports.BarHorizontalChart = _bar_horizontal2.default; +exports.BarGroupChart = _bar_group2.default; +exports.BarGroupHorizontalChart = _bar_group_horizontal2.default; +exports.AreaStackChart = _area_stack2.default; +exports.BarStackChart = _bar_stack2.default; +exports.BarStackHorizontalChart = _bar_stack_horizontal2.default; +exports.PieChart = _pie2.default; \ No newline at end of file diff --git a/lib/line.js b/lib/line.js new file mode 100644 index 0000000..ca086dc --- /dev/null +++ b/lib/line.js @@ -0,0 +1,104 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +var _commonProps2 = _interopRequireDefault(_commonProps); + +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; } + +var LineChart = function (_Component) { + _inherits(LineChart, _Component); + + function LineChart(props) { + _classCallCheck(this, LineChart); + + return _possibleConstructorReturn(this, (LineChart.__proto__ || Object.getPrototypeOf(LineChart)).call(this, props)); + } + + _createClass(LineChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries + }), + _react2.default.createElement(_reactD3Shape.Line, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return LineChart; +}(_react.Component); + +LineChart.defaultProps = _extends({ + showScatter: false +}, _commonProps2.default); +LineChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = LineChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/pie.js b/lib/pie.js new file mode 100644 index 0000000..c9a5d42 --- /dev/null +++ b/lib/pie.js @@ -0,0 +1,96 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +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; } + +var PieChart = function (_Component) { + _inherits(PieChart, _Component); + + function PieChart(props) { + _classCallCheck(this, PieChart); + + return _possibleConstructorReturn(this, (PieChart.__proto__ || Object.getPrototypeOf(PieChart)).call(this, props)); + } + + _createClass(PieChart, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + value = _props.value, + name = _props.name, + categoricalColors = _props.categoricalColors, + showLegend = _props.showLegend; + + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.ChartPie, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries, + value: value, + name: name + }), + _react2.default.createElement(_reactD3Shape.Pie, _extends({}, this.props, { + chartSeries: chartSeries + })), + this.props.children + ) + ); + } + }]); + + return PieChart; +}(_react.Component); + +PieChart.defaultProps = { + onMouseOver: function onMouseOver() {}, + onMouseOut: function onMouseOut() {}, + showLegend: true +}; +PieChart.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired, + value: _react.PropTypes.func.isRequired, + name: _react.PropTypes.func.isRequired +}; +exports.default = PieChart; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/scatter.js b/lib/scatter.js new file mode 100644 index 0000000..c677252 --- /dev/null +++ b/lib/scatter.js @@ -0,0 +1,102 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +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; }; + +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 _reactD3Core = require('react-d3-core'); + +var _reactD3Shape = require('react-d3-shape'); + +var _commonProps = require('./commonProps'); + +var _commonProps2 = _interopRequireDefault(_commonProps); + +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; } + +var ScatterPlot = function (_Component) { + _inherits(ScatterPlot, _Component); + + function ScatterPlot(props) { + _classCallCheck(this, ScatterPlot); + + return _possibleConstructorReturn(this, (ScatterPlot.__proto__ || Object.getPrototypeOf(ScatterPlot)).call(this, props)); + } + + _createClass(ScatterPlot, [{ + key: 'render', + value: function render() { + var _props = this.props, + width = _props.width, + height = _props.height, + margins = _props.margins, + data = _props.data, + chartSeries = _props.chartSeries, + showXGrid = _props.showXGrid, + showYGrid = _props.showYGrid, + showLegend = _props.showLegend, + categoricalColors = _props.categoricalColors; + + + var xgrid, ygrid; + + if (showXGrid) xgrid = _react2.default.createElement(_reactD3Core.Xgrid, null); + if (showYGrid) ygrid = _react2.default.createElement(_reactD3Core.Ygrid, null); + + return _react2.default.createElement( + 'div', + null, + showLegend ? _react2.default.createElement(_reactD3Core.Legend, _extends({}, this.props, { + width: width, + margins: margins, + chartSeries: chartSeries, + categoricalColors: categoricalColors + })) : null, + _react2.default.createElement( + _reactD3Shape.Chart, + _extends({}, this.props, { + width: width, + height: height, + data: data, + chartSeries: chartSeries + }), + _react2.default.createElement(_reactD3Shape.Scatter, { + chartSeries: chartSeries + }), + xgrid, + ygrid, + _react2.default.createElement(_reactD3Core.Xaxis, null), + _react2.default.createElement(_reactD3Core.Yaxis, null), + this.props.children + ) + ); + } + }]); + + return ScatterPlot; +}(_react.Component); + +ScatterPlot.defaultProps = _commonProps2.default; +ScatterPlot.propTypes = { + width: _react.PropTypes.number.isRequired, + height: _react.PropTypes.number.isRequired, + margins: _react.PropTypes.object.isRequired, + data: _react.PropTypes.array.isRequired, + chartSeries: _react.PropTypes.array.isRequired +}; +exports.default = ScatterPlot; +module.exports = exports['default']; \ No newline at end of file diff --git a/package.json b/package.json index 989ea1b..0e5177f 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,8 @@ "dependencies": { "d3-array": "^0.7.1", "d3-scale": "^0.6.4", - "react-d3-core": "^1.2.8", - "react-d3-shape": "^0.2.13", + "react-d3-core": "git+https://github.com/kty1965/react-d3-core.git", + "react-d3-shape": "git+https://github.com/kty1965/react-d3-shape.git", "react-faux-dom": "^2.1.0" } }