anychart-react
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -62,2 +62,8 @@ 'use strict'; | ||
_this.multipleEntities = ['xAxis', 'yAxis', 'lineMarker', 'rangeMarker', 'textMarker', 'grid', 'minorGrid']; | ||
/** | ||
* Container for chart/stage. | ||
* @type {string} | ||
*/ | ||
_this.containerId = props.id || 'ac-chart-container'; | ||
return _this; | ||
@@ -159,3 +165,3 @@ } | ||
} | ||
if (this.instance) this.instance.container(props.id || 'ac-chart-container'); | ||
if (this.instance) this.instance.container(this.containerId); | ||
delete props.id; | ||
@@ -230,3 +236,3 @@ } | ||
value: function render() { | ||
return _react2.default.createElement('div', { id: this.props.id || 'ac-chart-container' }); | ||
return _react2.default.createElement('div', { id: this.containerId }); | ||
} | ||
@@ -243,2 +249,7 @@ | ||
} | ||
}, { | ||
key: 'componentWillUpdate', | ||
value: function componentWillUpdate(nextProps, nextState) { | ||
this.containerId = nextProps.id || this.containerId; | ||
} | ||
@@ -245,0 +256,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}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)}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},_createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),_react=require("react"),_react2=_interopRequireDefault(_react);require("anychart");var AnyChart=function(e){function t(e){_classCallCheck(this,t);var n=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.instance=null,n.isStage=!1,n.disposeInstance=!1,n.multipleEntities=["xAxis","yAxis","lineMarker","rangeMarker","textMarker","grid","minorGrid"],n}return _inherits(t,e),_createClass(t,[{key:"removeInstance",value:function(){this.instance&&(this.disposeInstance?this.instance.dispose():this.isStage?this.instance.remove():this.instance.container().getStage().remove())}},{key:"isArray",value:function(e){return"object"==(void 0===e?"undefined":_typeof(e))&&e instanceof Array}},{key:"applyProps",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=Object.keys(e)[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var s=i.value,o=e[s];if("width"!=s&&"height"!=s||this.isStage||this.instance.container().getStage()[s](o),this.instance[s])if(~this.multipleEntities.indexOf(s)){var c;this.isArray(o)||(o=[o]),(c=this.instance)[s].apply(c,_toConsumableArray(o))}else this.instance[s](o)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}},{key:"createInstance",value:function(e){e.instance?(this.removeInstance(),this.instance=e.instance,this.isStage="function"!=typeof this.instance.draw,delete e.instance,this.disposeInstance=!1):e.type&&(this.removeInstance(),this.disposeInstance=!0,this.instance=anychart[e.type](e.data),this.isStage=!1,delete e.type,delete e.data),this.instance&&this.instance.container(e.id||"ac-chart-container"),delete e.id}},{key:"drawInstance",value:function(e){if(this.instance)if(this.isStage){this.instance.suspend();var t=e.charts;delete e.charts,this.applyProps(e);var n=!0,r=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var o=a.value;o.container(this.instance).draw()}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}this.instance.resume()}else this.applyProps(e),this.instance.draw()}},{key:"createAndDraw",value:function(e){var t=Object.assign(e,this.props);this.createInstance(t),this.drawInstance(t)}},{key:"render",value:function(){return _react2.default.createElement("div",{id:this.props.id||"ac-chart-container"})}},{key:"componentDidMount",value:function(){this.createAndDraw({})}},{key:"componentDidUpdate",value:function(e,t){var n=Object.assign({},e);delete n.type,delete n.instance,this.createAndDraw(n)}},{key:"componentWillUnmount",value:function(){this.removeInstance()}}]),t}(_react2.default.Component);exports.default=AnyChart; | ||
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}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)}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},_createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),_react=require("react"),_react2=_interopRequireDefault(_react);require("anychart");var AnyChart=function(e){function t(e){_classCallCheck(this,t);var n=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.instance=null,n.isStage=!1,n.disposeInstance=!1,n.multipleEntities=["xAxis","yAxis","lineMarker","rangeMarker","textMarker","grid","minorGrid"],n.containerId=e.id||"ac-chart-container",n}return _inherits(t,e),_createClass(t,[{key:"removeInstance",value:function(){this.instance&&(this.disposeInstance?this.instance.dispose():this.isStage?this.instance.remove():this.instance.container().getStage().remove())}},{key:"isArray",value:function(e){return"object"==(void 0===e?"undefined":_typeof(e))&&e instanceof Array}},{key:"applyProps",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,a=Object.keys(e)[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var s=i.value,o=e[s];if("width"!=s&&"height"!=s||this.isStage||this.instance.container().getStage()[s](o),this.instance[s])if(~this.multipleEntities.indexOf(s)){var c;this.isArray(o)||(o=[o]),(c=this.instance)[s].apply(c,_toConsumableArray(o))}else this.instance[s](o)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}},{key:"createInstance",value:function(e){e.instance?(this.removeInstance(),this.instance=e.instance,this.isStage="function"!=typeof this.instance.draw,delete e.instance,this.disposeInstance=!1):e.type&&(this.removeInstance(),this.disposeInstance=!0,this.instance=anychart[e.type](e.data),this.isStage=!1,delete e.type,delete e.data),this.instance&&this.instance.container(this.containerId),delete e.id}},{key:"drawInstance",value:function(e){if(this.instance)if(this.isStage){this.instance.suspend();var t=e.charts;delete e.charts,this.applyProps(e);var n=!0,r=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var o=a.value;o.container(this.instance).draw()}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}this.instance.resume()}else this.applyProps(e),this.instance.draw()}},{key:"createAndDraw",value:function(e){var t=Object.assign(e,this.props);this.createInstance(t),this.drawInstance(t)}},{key:"render",value:function(){return _react2.default.createElement("div",{id:this.containerId})}},{key:"componentDidMount",value:function(){this.createAndDraw({})}},{key:"componentWillUpdate",value:function(e,t){this.containerId=e.id||this.containerId}},{key:"componentDidUpdate",value:function(e,t){var n=Object.assign({},e);delete n.type,delete n.instance,this.createAndDraw(n)}},{key:"componentWillUnmount",value:function(){this.removeInstance()}}]),t}(_react2.default.Component);exports.default=AnyChart; |
{ | ||
"name": "anychart-react", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "React component for AnyChart JavaScript charting library", | ||
@@ -5,0 +5,0 @@ "main": "./dist/anychart-react.min.js", |
@@ -34,2 +34,8 @@ import React from 'react'; | ||
this.multipleEntities = ['xAxis', 'yAxis', 'lineMarker', 'rangeMarker', 'textMarker', 'grid', 'minorGrid']; | ||
/** | ||
* Container for chart/stage. | ||
* @type {string} | ||
*/ | ||
this.containerId = props.id || 'ac-chart-container'; | ||
} | ||
@@ -103,3 +109,3 @@ | ||
if (this.instance) | ||
this.instance.container(props.id || 'ac-chart-container'); | ||
this.instance.container(this.containerId); | ||
delete props.id; | ||
@@ -144,3 +150,3 @@ } | ||
return ( | ||
<div id={this.props.id || 'ac-chart-container'}></div> | ||
<div id={this.containerId}></div> | ||
) | ||
@@ -156,2 +162,6 @@ } | ||
componentWillUpdate(nextProps, nextState) { | ||
this.containerId = nextProps.id || this.containerId; | ||
} | ||
/** | ||
@@ -158,0 +168,0 @@ * Component has re-rendered. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
18045032
38
74059