@@ -12,6 +12,8 @@ var _react = require('react');
1212
1313var _react2 = _interopRequireDefault ( _react ) ;
1414
15+ require ( 'anychart' ) ;
16+
1517function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
1618
1719function _toConsumableArray ( arr ) { if ( Array . isArray ( arr ) ) { for ( var i = 0 , arr2 = Array ( arr . length ) ; i < arr . length ; i ++ ) { arr2 [ i ] = arr [ i ] ; } return arr2 ; } else { return Array . from ( arr ) ; } }
@@ -22,23 +24,49 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
2224
2325function _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 ; }
2426
25- require ( 'anychart' ) ( document . defaultView ) ;
26-
27+ /**
28+ * AnyChart React plugin.
29+ */
2730var AnyChart = function ( _React$Component ) {
2831 _inherits ( AnyChart , _React$Component ) ;
2932
3033 function AnyChart ( props ) {
3134 _classCallCheck ( this , AnyChart ) ;
3235
36+ /**
37+ * Instance (stage or chart).
38+ * @type {Object }
39+ */
3340 var _this = _possibleConstructorReturn ( this , ( AnyChart . __proto__ || Object . getPrototypeOf ( AnyChart ) ) . call ( this , props ) ) ;
3441
3542 _this . instance = null ;
43+
44+ /**
45+ * Whether instance is stage.
46+ * @type {boolean }
47+ */
3648 _this . isStage = false ;
49+
50+ /**
51+ * Should we dispose instance or not.
52+ * @type {boolean }
53+ */
3754 _this . disposeInstance = false ;
38- _this . multipleEntities = [ 'xAxis' , 'yAxis' , 'lineMarker' , 'rangeMarker' , 'textMarker' ] ;
55+
56+ /**
57+ * Properties of AnyChart which expected as array of [entity_index, json].
58+ * E.g. <AnyChart yAxis={[1, {orientation: 'right'}]} />
59+ * @type {Array.<string> }
60+ */
61+ _this . multipleEntities = [ 'xAxis' , 'yAxis' , 'lineMarker' , 'rangeMarker' , 'textMarker' , 'grid' , 'minorGrid' ] ;
3962 return _this ;
4063 }
4164
65+ /**
66+ * Remove instance (dispose it if necessary).
67+ */
68+
69+
4270 _createClass ( AnyChart , [ {
4371 key : 'removeInstance' ,
4472 value : function removeInstance ( ) {
@@ -48,11 +76,24 @@ var AnyChart = function (_React$Component) {
4876 }
4977 }
5078 }
79+
80+ /**
81+ * Checker for array.
82+ * @param {* } value Value to check.
83+ * @return {boolean }
84+ */
85+
5186 } , {
5287 key : 'isArray' ,
5388 value : function isArray ( value ) {
5489 return ( typeof value === 'undefined' ? 'undefined' : _typeof ( value ) ) == 'object' && value instanceof Array ;
5590 }
91+
92+ /**
93+ * Applies props.
94+ * @param {Object } props Properties.
95+ */
96+
5697 } , {
5798 key : 'applyProps' ,
5899 value : function applyProps ( props ) {
@@ -91,6 +132,12 @@ var AnyChart = function (_React$Component) {
91132 }
92133 }
93134 }
135+
136+ /**
137+ * Create instance to render chart or use instance property.
138+ * @param {Object } props Properties.
139+ */
140+
94141 } , {
95142 key : 'createInstance' ,
96143 value : function createInstance ( props ) {
@@ -111,6 +158,12 @@ var AnyChart = function (_React$Component) {
111158 if ( this . instance ) this . instance . container ( props . id || 'ac-chart-container' ) ;
112159 delete props . id ;
113160 }
161+
162+ /**
163+ * Draws chart.
164+ * @param {Object } props Properties.
165+ */
166+
114167 } , {
115168 key : 'drawInstance' ,
116169 value : function drawInstance ( props ) {
@@ -151,23 +204,46 @@ var AnyChart = function (_React$Component) {
151204 this . instance . draw ( ) ;
152205 }
153206 }
207+
208+ /**
209+ * Method that
210+ * @param {Object } prevProps
211+ */
212+
154213 } , {
155214 key : 'createAndDraw' ,
156215 value : function createAndDraw ( prevProps ) {
157216 var props = Object . assign ( prevProps , this . props ) ;
158217 this . createInstance ( props ) ;
159218 this . drawInstance ( props ) ;
160219 }
220+
221+ /**
222+ * Render container for future chart drawing.
223+ */
224+
161225 } , {
162226 key : 'render' ,
163227 value : function render ( ) {
164228 return _react2 . default . createElement ( 'div' , { id : this . props . id || 'ac-chart-container' } ) ;
165229 }
230+
231+ /**
232+ * Component has rendered.
233+ */
234+
166235 } , {
167236 key : 'componentDidMount' ,
168237 value : function componentDidMount ( ) {
169238 this . createAndDraw ( { } ) ;
170239 }
240+
241+ /**
242+ * Component has re-rendered.
243+ * @param {Object } prevProps Previous properties.
244+ * @param {Object } prevState Previous state.
245+ */
246+
171247 } , {
172248 key : 'componentDidUpdate' ,
173249 value : function componentDidUpdate ( prevProps , prevState ) {
@@ -176,6 +252,11 @@ var AnyChart = function (_React$Component) {
176252 delete props . instance ;
177253 this . createAndDraw ( props ) ;
178254 }
255+
256+ /**
257+ * Unmount react component.
258+ */
259+
179260 } , {
180261 key : 'componentWillUnmount' ,
181262 value : function componentWillUnmount ( ) {
@@ -186,4 +267,9 @@ var AnyChart = function (_React$Component) {
186267 return AnyChart ;
187268} ( _react2 . default . Component ) ;
188269
270+ /**
271+ * Default export.
272+ */
273+
274+
189275exports . default = AnyChart ;
0 commit comments