react-apexcharts
Advanced tools
Comparing version 1.0.10 to 1.1.0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},_createClass=function(){function i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}}(),_apexcharts=require("apexcharts"),_apexcharts2=_interopRequireDefault(_apexcharts),_react=require("react"),_react2=_interopRequireDefault(_react),_propTypes=require("prop-types"),_propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _objectWithoutProperties(e,t){var r={};for(var i in e)0<=t.indexOf(i)||Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i]);return r}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var Charts=function(e){function r(e){_classCallCheck(this,r);var t=_possibleConstructorReturn(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return _react2.default.createRef?t.chartRef=_react2.default.createRef():t.setRef=function(e){return t.chartRef=e},t.chart=null,t}return _inherits(r,_react.Component),_createClass(r,[{key:"render",value:function(){var e=this.props,t=(e.type,e.width,e.height,e.series,e.options,_objectWithoutProperties(e,["type","width","height","series","options"]));return _react2.default.createElement("div",_extends({ref:_react2.default.createRef?this.chartRef:this.setRef},t))}},{key:"componentDidMount",value:function(){var e=_react2.default.createRef?this.chartRef.current:this.chartRef;this.chart=new _apexcharts2.default(e,this.getConfig()),this.chart.render()}},{key:"getConfig",value:function(){var e=this.props,t=e.type,r=e.height,i=e.width,n=e.series,o=e.options,a={chart:{type:t,height:r,width:i},series:n};return _apexcharts2.default.merge(o,a)}},{key:"componentDidUpdate",value:function(e){if(!this.chart)return null;var t=this.props,r=t.options,i=t.series,n=JSON.stringify(e.options),o=JSON.stringify(e.series),a=JSON.stringify(r),s=JSON.stringify(i);n===a&&o===s||(o===s?this.chart.updateOptions(this.getConfig()):n===a?this.chart.updateSeries(i):this.chart.updateOptions(this.getConfig()))}},{key:"componentWillUnmount",value:function(){this.chart&&"function"==typeof this.chart.destroy&&this.chart.destroy()}}]),r}();(exports.default=Charts).propTypes={type:_propTypes2.default.string.isRequired,width:_propTypes2.default.any,height:_propTypes2.default.any,series:_propTypes2.default.array.isRequired,options:_propTypes2.default.object.isRequired},Charts.defaultProps={type:"line",width:"100%",height:"auto"}; | ||
import ApexCharts from"apexcharts";import React,{Component}from"react";import PropTypes from"prop-types";var _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t};function _objectWithoutProperties(t,e){var r={};for(var s in t)e.indexOf(s)>=0||Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s]);return r}class Charts extends Component{constructor(t){super(t),React.createRef?this.chartRef=React.createRef():this.setRef=(t=>this.chartRef=t),this.chart=null}render(){const t=_objectWithoutProperties(this.props,["type","width","height","series","options"]);return React.createElement("div",_extends({ref:React.createRef?this.chartRef:this.setRef},t))}componentDidMount(){const t=React.createRef?this.chartRef.current:this.chartRef;this.chart=new ApexCharts(t,this.getConfig()),this.chart.render()}getConfig(){const{type:t,height:e,width:r,series:s,options:i}=this.props,o={chart:{type:t,height:e,width:r},series:s};return ApexCharts.merge(i,o)}componentDidUpdate(t){if(!this.chart)return null;const{options:e,series:r}=this.props,s=JSON.stringify(t.options),i=JSON.stringify(t.series),o=JSON.stringify(e),h=JSON.stringify(r);s===o&&i===h||(i===h?this.chart.updateOptions(this.getConfig()):s===o?this.chart.updateSeries(r):this.chart.updateOptions(this.getConfig()))}componentWillUnmount(){this.chart&&"function"==typeof this.chart.destroy&&this.chart.destroy()}}Charts.propTypes={type:PropTypes.string.isRequired,width:PropTypes.any,height:PropTypes.any,series:PropTypes.array.isRequired,options:PropTypes.object.isRequired},Charts.defaultProps={type:"line",width:"100%",height:"auto"};export default Charts; |
@@ -22,3 +22,3 @@ var gulp = require('gulp'); | ||
.pipe(babel({ | ||
presets: ['es2015'], | ||
presets: ['es2015', 'react'], | ||
plugins: ['transform-object-rest-spread'] | ||
@@ -32,2 +32,2 @@ })) | ||
gulp.task('build', ['dev', 'prod']); | ||
gulp.task('default', ['dev']); | ||
gulp.task('default', ['dev', 'prod']); |
{ | ||
"name": "react-apexcharts", | ||
"version": "1.0.10", | ||
"version": "1.1.0", | ||
"description": "React.js wrapper for ApexCharts", | ||
"main": "dist/react-apexcharts.min.js", | ||
"scripts": { | ||
"build": "gulp", | ||
"build": "rollup -c rollup.config.js", | ||
"test": "jest" | ||
@@ -30,21 +30,21 @@ }, | ||
"peerDependencies": { | ||
"apexcharts": "^2.1.8", | ||
"apexcharts": "^2.2.2", | ||
"react": ">=0.13" | ||
}, | ||
"devDependencies": { | ||
"babel-jest": "^23.4.2", | ||
"babel-core": "^6.26.3", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-preset-react": "^6.24.1", | ||
"gulp": "^3.9.1", | ||
"gulp-babel": "^6.1.2", | ||
"gulp-concat": "^2.6.1", | ||
"gulp-react": "^3.1.0", | ||
"gulp-uglify": "^3.0.0", | ||
"jest": "^23.5.0", | ||
"react": "^16.3.0", | ||
"react-dom": "^16.3.0", | ||
"react-test-renderer": "^16.4.2" | ||
"babel-preset-stage-3": "^6.24.1", | ||
"jest": "^23.6.0", | ||
"react": "^16.6.3", | ||
"react-dom": "^16.6.3", | ||
"react-test-renderer": "^16.6.3", | ||
"rollup": "^0.58.2", | ||
"rollup-plugin-babel": "^3.0.4", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"rollup-plugin-postcss": "^1.6.1", | ||
"rollup-plugin-uglify": "^3.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
12
1
15007
180