1
+ 'use strict' ;
2
+
3
+ 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 ; } ; } ( ) ;
4
+
5
+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
6
+
7
+ 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 ; }
8
+
9
+ 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 ; }
10
+
11
+ var ReactTable = window . ReactTable . default ;
12
+
13
+ var MovingAverageCrossoverTable = function ( _React$Component ) {
14
+ _inherits ( MovingAverageCrossoverTable , _React$Component ) ;
15
+
16
+ function MovingAverageCrossoverTable ( props ) {
17
+ _classCallCheck ( this , MovingAverageCrossoverTable ) ;
18
+
19
+ var _this = _possibleConstructorReturn ( this , ( MovingAverageCrossoverTable . __proto__ || Object . getPrototypeOf ( MovingAverageCrossoverTable ) ) . call ( this , props ) ) ;
20
+
21
+ _this . state = { data : [ ] } ;
22
+ return _this ;
23
+ }
24
+
25
+ _createClass ( MovingAverageCrossoverTable , [ {
26
+ key : 'componentDidMount' ,
27
+ value : function componentDidMount ( ) {
28
+ var _this2 = this ;
29
+
30
+ axios . get ( '/msa' ) . then ( function ( response ) {
31
+ _this2 . setState ( {
32
+ data : response . data
33
+ } ) ;
34
+ } ) . catch ( function ( error ) {
35
+ // handle error
36
+ console . log ( error ) ;
37
+ } ) . finally ( function ( ) {
38
+ // always executed
39
+ } ) ;
40
+ }
41
+ } , {
42
+ key : 'render' ,
43
+ value : function render ( ) {
44
+ var columns = [ {
45
+ Header : 'Date' ,
46
+ accessor : 'Date' , // String-based value accessors!
47
+ Cell : function Cell ( props ) {
48
+ return React . createElement (
49
+ 'div' ,
50
+ { style : { textAlign : 'center' } } ,
51
+ React . createElement (
52
+ 'span' ,
53
+ null ,
54
+ props . value
55
+ )
56
+ ) ;
57
+ }
58
+ } , {
59
+ Header : 'Close Price' ,
60
+ accessor : 'Close Price' , // String-based value accessors!
61
+ Cell : function Cell ( props ) {
62
+ return React . createElement (
63
+ 'div' ,
64
+ { style : { textAlign : 'center' } } ,
65
+ React . createElement (
66
+ 'span' ,
67
+ { className : 'number' } ,
68
+ props . value
69
+ )
70
+ ) ;
71
+ }
72
+ } , {
73
+ Header : 'Buy' ,
74
+ accessor : 'Buy' ,
75
+ width : 200 ,
76
+ Cell : function Cell ( props ) {
77
+ return React . createElement (
78
+ 'div' ,
79
+ { style : {
80
+ //width: `${props.value}%`,
81
+ height : '100%' ,
82
+ backgroundColor : props . value > 0 ? '#85cc00' : '#FFFFFF' ,
83
+ borderRadius : '2px' ,
84
+ textAlign : 'center'
85
+ }
86
+ } ,
87
+ React . createElement (
88
+ 'span' ,
89
+ { className : 'number' } ,
90
+ props . value
91
+ )
92
+ ) ;
93
+ } // Custom cell components!
94
+ } , {
95
+ Header : 'Sell' ,
96
+ accessor : 'Sell' ,
97
+ width : 200 ,
98
+ Cell : function Cell ( props ) {
99
+ return React . createElement (
100
+ 'div' ,
101
+ { style : {
102
+ // width: `${props.value}%`,
103
+ height : '100%' ,
104
+ backgroundColor : props . value < 0 ? '#ff2e00' : '#ffffff' ,
105
+ borderRadius : '2px' ,
106
+ textAlign : 'center'
107
+ }
108
+ } ,
109
+ React . createElement (
110
+ 'span' ,
111
+ { className : 'number' } ,
112
+ props . value
113
+ )
114
+ ) ;
115
+ } // Custom cell components!
116
+ } ] ;
117
+
118
+ return React . createElement ( ReactTable , { data : this . state . data , columns : columns ,
119
+ defaultPageSize : 10 } ) ;
120
+ }
121
+ } ] ) ;
122
+
123
+ return MovingAverageCrossoverTable ;
124
+ } ( React . Component ) ;
125
+
126
+ var domContainer = document . querySelector ( '#macs' ) ;
127
+
128
+ ReactDOM . render ( React . createElement ( MovingAverageCrossoverTable , null ) , domContainer ) ;
0 commit comments