react-apexcharts 1.3.7 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,12 +41,12 @@ class App extends Component {
41
41
  id: 'apexchart-example'
42
42
  },
43
43
  xaxis: {
44
- categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998]
44
+ categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999]
45
45
  }
46
46
  },
47
47
  series: [{
48
48
  name: 'series-1',
49
- data: [30, 40, 45, 50, 49, 60, 70, 91]
49
+ data: [30, 40, 35, 50, 49, 60, 70, 91, 125]
50
50
  }]
51
51
  }
52
52
  }
@@ -63,7 +63,7 @@ This will render the following chart
63
63
 
64
64
  ### How do I update the chart?
65
65
  Simple! Just change the `series` or any `option` and it will automatically re-render the chart.
66
- <p align="center"><a href="#"><img src="https://apexcharts.com/media/react-chart-updation.gif"></a></p>
66
+ <p align="center"><a href="https://codesandbox.io/s/mzzq3yqjqj"><img src="https://apexcharts.com/media/react-chart-updation.gif"></a></p>
67
67
 
68
68
  View this example on <a href="https://codesandbox.io/s/mzzq3yqjqj">codesandbox</a>
69
69
 
@@ -102,7 +102,7 @@ this.setState({
102
102
  | **height** | Number/String | Possible values for width can be `100%` or `300px` or 300 |
103
103
  | **options** | Object | The configuration object, see options on [API (Reference)](https://apexcharts.com/docs/options/chart/type/) |
104
104
 
105
- ## How to call methods of ApexCharts programatically?
105
+ ## How to call methods of ApexCharts programmatically?
106
106
  Sometimes, you may want to call other methods of the core ApexCharts library, and you can do so on `ApexCharts` global variable directly
107
107
 
108
108
  Example
@@ -1,17 +1,32 @@
1
1
  /// <reference types="react"/>
2
-
2
+ import { ApexOptions } from 'apexcharts';
3
+ import React from 'react';
3
4
  /**
4
5
  * Basic type definitions from https://apexcharts.com/docs/react-charts/#props
5
6
  */
6
7
  declare module "react-apexcharts" {
7
- interface Props {
8
- type?: "line" | "area" | "bar" | "histogram" | "pie" | "donut" | "rangeBar" |
9
- "radialBar" | "scatter" | "bubble" | "heatmap" | "candlestick" | "radar" | "polarArea",
10
- series?: Array<any>,
11
- width?: string | number,
12
- height?: string | number,
13
- options?: object
14
- }
15
-
16
- export default class ReactApexChart extends React.Component<Props> {}
8
+ export interface Props {
9
+ type?: "line"
10
+ | "area"
11
+ | "bar"
12
+ | "histogram"
13
+ | "pie"
14
+ | "donut"
15
+ | "radialBar"
16
+ | "scatter"
17
+ | "bubble"
18
+ | "heatmap"
19
+ | "treemap"
20
+ | "boxPlot"
21
+ | "candlestick"
22
+ | "radar"
23
+ | "polarArea"
24
+ | "rangeBar",
25
+ series?: ApexOptions['series'],
26
+ width?: string | number,
27
+ height?: string | number,
28
+ options?: ApexOptions,
29
+ [key: string]: any,
30
+ }
31
+ export default class ReactApexChart extends React.Component<Props> {}
17
32
  }
@@ -1 +1 @@
1
- var ReactApexChart=function(t,e,r){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var i="default"in e?e.default:e;r=r&&r.hasOwnProperty("default")?r.default:r;var s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};window.ApexCharts=t;class n extends e.Component{constructor(t){super(t),i.createRef?this.chartRef=i.createRef():this.setRef=(t=>this.chartRef=t),this.chart=null}render(){const t=function(t,e){var r={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i]);return r}(this.props,[]);return i.createElement("div",s({ref:i.createRef?this.chartRef:this.setRef},t))}componentDidMount(){const e=i.createRef?this.chartRef.current:this.chartRef;this.chart=new t(e,this.getConfig()),this.chart.render()}getConfig(){const{type:t,height:e,width:r,series:i,options:s}=this.props,n={chart:{type:t,height:e,width:r},series:i};return this.extend(s,n)}isObject(t){return t&&"object"==typeof t&&!Array.isArray(t)&&null!=t}extend(t,e){"function"!=typeof Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");let e=Object(t);for(let t=1;t<arguments.length;t++){let r=arguments[t];if(void 0!==r&&null!==r)for(let t in r)r.hasOwnProperty(t)&&(e[t]=r[t])}return e});let r=Object.assign({},t);return this.isObject(t)&&this.isObject(e)&&Object.keys(e).forEach(i=>{this.isObject(e[i])&&i in t?r[i]=this.extend(t[i],e[i]):Object.assign(r,{[i]:e[i]})}),r}componentDidUpdate(t){if(!this.chart)return null;const{options:e,series:r,height:i,width:s}=this.props,n=JSON.stringify(t.options),h=JSON.stringify(t.series),o=JSON.stringify(e),a=JSON.stringify(r);n===o&&h===a&&i===t.height&&s===t.width||(h===a?this.chart.updateOptions(this.getConfig()):n===o&&i===t.height&&s===t.width?this.chart.updateSeries(r):this.chart.updateOptions(this.getConfig()))}componentWillUnmount(){this.chart&&"function"==typeof this.chart.destroy&&this.chart.destroy()}}return n.propTypes={type:r.string.isRequired,width:r.any,height:r.any,series:r.array.isRequired,options:r.object.isRequired},n.defaultProps={type:"line",width:"100%",height:"auto"},n}(ApexCharts,React,PropTypes);
1
+ var ReactApexChart=function(t,e,r){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var i="default"in e?e.default:e;r=r&&r.hasOwnProperty("default")?r.default:r;var s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};window.ApexCharts=t;class n extends e.Component{constructor(t){super(t),i.createRef?this.chartRef=i.createRef():this.setRef=(t=>this.chartRef=t),this.chart=null}render(){const t=function(t,e){var r={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i]);return r}(this.props,["type","height","width","series","options"]);return i.createElement("div",s({ref:i.createRef?this.chartRef:this.setRef},t))}componentDidMount(){const e=i.createRef?this.chartRef.current:this.chartRef;this.chart=new t(e,this.getConfig()),this.chart.render()}getConfig(){const{type:t,height:e,width:r,series:i,options:s}=this.props,n={chart:{type:t,height:e,width:r},series:i};return this.extend(s,n)}isObject(t){return t&&"object"==typeof t&&!Array.isArray(t)&&null!=t}extend(t,e){"function"!=typeof Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");let e=Object(t);for(let t=1;t<arguments.length;t++){let r=arguments[t];if(void 0!==r&&null!==r)for(let t in r)r.hasOwnProperty(t)&&(e[t]=r[t])}return e});let r=Object.assign({},t);return this.isObject(t)&&this.isObject(e)&&Object.keys(e).forEach(i=>{this.isObject(e[i])&&i in t?r[i]=this.extend(t[i],e[i]):Object.assign(r,{[i]:e[i]})}),r}componentDidUpdate(t){if(!this.chart)return null;const{options:e,series:r,height:i,width:s}=this.props,n=JSON.stringify(t.options),h=JSON.stringify(t.series),o=JSON.stringify(e),a=JSON.stringify(r);n===o&&h===a&&i===t.height&&s===t.width||(h===a?this.chart.updateOptions(this.getConfig()):n===o&&i===t.height&&s===t.width?this.chart.updateSeries(r):this.chart.updateOptions(this.getConfig()))}componentWillUnmount(){this.chart&&"function"==typeof this.chart.destroy&&this.chart.destroy()}}return n.propTypes={type:r.string.isRequired,width:r.any,height:r.any,series:r.array.isRequired,options:r.object.isRequired},n.defaultProps={type:"line",width:"100%",height:"auto"},n}(ApexCharts,React,PropTypes);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_createClass=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),_apexcharts=require("apexcharts/dist/apexcharts.common"),_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 _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectWithoutProperties(e,t){var r={};for(var n in e)0<=t.indexOf(n)||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);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)}window.ApexCharts=_apexcharts2.default;var Charts=function(){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=_objectWithoutProperties(this.props,[]);return _react2.default.createElement("div",_extends({ref:_react2.default.createRef?this.chartRef:this.setRef},e))}},{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,n=e.width,o=e.series,i=e.options,a={chart:{type:t,height:r,width:n},series:o};return this.extend(i,a)}},{key:"isObject",value:function(e){return e&&"object"===(void 0===e?"undefined":_typeof(e))&&!Array.isArray(e)&&null!=e}},{key:"extend",value:function(t,r){var n=this;"function"!=typeof Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;r<arguments.length;r++){var n=arguments[r];if(null!=n)for(var o in n)n.hasOwnProperty(o)&&(t[o]=n[o])}return t});var o=Object.assign({},t);return this.isObject(t)&&this.isObject(r)&&Object.keys(r).forEach(function(e){n.isObject(r[e])&&e in t?o[e]=n.extend(t[e],r[e]):Object.assign(o,_defineProperty({},e,r[e]))}),o}},{key:"componentDidUpdate",value:function(e){if(!this.chart)return null;var t=this.props,r=t.options,n=t.series,o=t.height,i=t.width,a=JSON.stringify(e.options),s=JSON.stringify(e.series),c=JSON.stringify(r),u=JSON.stringify(n);a===c&&s===u&&o===e.height&&i===e.width||(s!==u&&a===c&&o===e.height&&i===e.width?this.chart.updateSeries(n):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"};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_createClass=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),_apexcharts=require("apexcharts/dist/apexcharts.common"),_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 _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectWithoutProperties(e,t){var r={};for(var n in e)0<=t.indexOf(n)||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);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)}window.ApexCharts=_apexcharts2.default;var Charts=function(){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.height,e.width,e.series,e.options,_objectWithoutProperties(e,["type","height","width","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,n=e.width,o=e.series,i=e.options,a={chart:{type:t,height:r,width:n},series:o};return this.extend(i,a)}},{key:"isObject",value:function(e){return e&&"object"===(void 0===e?"undefined":_typeof(e))&&!Array.isArray(e)&&null!=e}},{key:"extend",value:function(t,r){var n=this;"function"!=typeof Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;r<arguments.length;r++){var n=arguments[r];if(null!=n)for(var o in n)n.hasOwnProperty(o)&&(t[o]=n[o])}return t});var o=Object.assign({},t);return this.isObject(t)&&this.isObject(r)&&Object.keys(r).forEach(function(e){n.isObject(r[e])&&e in t?o[e]=n.extend(t[e],r[e]):Object.assign(o,_defineProperty({},e,r[e]))}),o}},{key:"componentDidUpdate",value:function(e){if(!this.chart)return null;var t=this.props,r=t.options,n=t.series,o=t.height,i=t.width,a=JSON.stringify(e.options),s=JSON.stringify(e.series),c=JSON.stringify(r),u=JSON.stringify(n);a===c&&s===u&&o===e.height&&i===e.width||(s===u?this.chart.updateOptions(this.getConfig()):a===c&&o===e.height&&i===e.width?this.chart.updateSeries(n):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"};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-apexcharts",
3
- "version": "1.3.7",
3
+ "version": "1.4.0",
4
4
  "description": "React.js wrapper for ApexCharts",
5
5
  "main": "dist/react-apexcharts.min.js",
6
6
  "types": "types/react-apexcharts.d.ts",
@@ -16,7 +16,7 @@ export default class Charts extends Component {
16
16
  }
17
17
 
18
18
  render () {
19
- const { ...props } = this.props
19
+ const { type, height, width, series, options, ...props } = this.props
20
20
  return React.createElement('div', {
21
21
  ref: React.createRef
22
22
  ? this.chartRef
@@ -1,17 +1,32 @@
1
1
  /// <reference types="react"/>
2
-
2
+ import { ApexOptions } from 'apexcharts';
3
+ import React from 'react';
3
4
  /**
4
5
  * Basic type definitions from https://apexcharts.com/docs/react-charts/#props
5
6
  */
6
7
  declare module "react-apexcharts" {
7
- interface Props {
8
- type?: "line" | "area" | "bar" | "histogram" | "pie" | "donut" | "rangeBar" |
9
- "radialBar" | "scatter" | "bubble" | "heatmap" | "candlestick" | "radar" | "polarArea",
10
- series?: Array<any>,
11
- width?: string | number,
12
- height?: string | number,
13
- options?: object
14
- }
15
-
16
- export default class ReactApexChart extends React.Component<Props> {}
8
+ export interface Props {
9
+ type?: "line"
10
+ | "area"
11
+ | "bar"
12
+ | "histogram"
13
+ | "pie"
14
+ | "donut"
15
+ | "radialBar"
16
+ | "scatter"
17
+ | "bubble"
18
+ | "heatmap"
19
+ | "treemap"
20
+ | "boxPlot"
21
+ | "candlestick"
22
+ | "radar"
23
+ | "polarArea"
24
+ | "rangeBar",
25
+ series?: ApexOptions['series'],
26
+ width?: string | number,
27
+ height?: string | number,
28
+ options?: ApexOptions,
29
+ [key: string]: any,
30
+ }
31
+ export default class ReactApexChart extends React.Component<Props> {}
17
32
  }