1
- import { Component , OnInit , ViewChild , ElementRef } from '@angular/core' ;
2
- import { createData } from './createData' ;
3
-
4
1
declare var Ext : any ;
2
+ import { Component } from '@angular/core' ;
3
+ import { createData } from './createData' ;
5
4
6
5
Ext . require ( [
7
6
'Ext.chart.axis.Numeric' ,
@@ -14,129 +13,120 @@ Ext.require([
14
13
templateUrl : './OHLC.html' ,
15
14
styles : [ `` ]
16
15
} )
17
- export class OHLCComponent implements OnInit {
16
+ export class OHLCComponent {
18
17
19
18
constructor ( ) {
20
-
21
19
this . refresh ( ) ;
22
20
}
23
21
24
- ngOnInit ( ) {
22
+ isPhone = Ext . os . is . Phone ;
23
+ store = Ext . create ( 'Ext.data.Store' , {
24
+ fields : [ 'time' , 'open' , 'high' , 'low' , 'close' ]
25
+ } ) ;
26
+
27
+ theme :string = 'default' ;
28
+ zoom :boolean = false ;
29
+
30
+ panzoom :any ;
31
+ crosshair :any ;
32
+
33
+ chart :any ;
34
+
35
+ chartNavReady = function ( event ) {
36
+ console . log ( "chartNavReady" ) ;
37
+ this . chart = event . ext ;
38
+ this . panzoom = this . chart . getInteraction ( 'panzoom' ) ;
39
+ this . crosshair = this . chart . getInteraction ( 'crosshair' ) ;
25
40
}
26
41
27
- isPhone = Ext . os . is . Phone ;
28
42
43
+ refresh = ( ) => {
44
+ this . store . loadData ( createData ( 1000 ) ) ;
45
+ }
29
46
30
- store = Ext . create ( 'Ext.data.Store' , {
31
- fields : [ 'time' , 'open' , 'high' , 'low' , 'close' ]
32
- } ) ;
33
-
34
- theme :string = 'default' ;
35
- zoom :boolean = false ;
36
-
37
- panzoom :any ;
38
- crosshair :any ;
39
-
40
- chart :any ;
41
-
42
- chartNavReady = function ( event ) {
43
- console . log ( "chartNavReady" ) ;
44
- this . chart = event . ext ;
45
- this . panzoom = this . chart . getInteraction ( 'panzoom' ) ;
46
- this . crosshair = this . chart . getInteraction ( 'crosshair' ) ;
47
- }
48
-
49
-
50
- refresh = ( ) => {
51
- this . store . loadData ( createData ( 1000 ) ) ;
52
- }
53
-
54
- changeTheme = theme => this . theme = theme ;
55
-
56
- toggleZoomOnPan = ( zoomOnPan ) => {
57
- this . toggleCrosshair ( false ) ;
58
- this . panzoom . setZoomOnPan ( zoomOnPan ) ;
59
- this . zoom = zoomOnPan ;
60
- }
61
-
62
- toggleCrosshair = ( crosshair ) => {
63
- this . panzoom . setEnabled ( ! crosshair ) ;
64
- this . crosshair . setEnabled ( crosshair ) ;
65
- if ( crosshair ) {
66
- this . crosshair = crosshair ;
67
- }
68
- }
69
-
70
-
71
- cartesianAxes = [ {
72
- type : 'numeric' ,
73
- fields : [ 'open' , 'high' , 'low' , 'close' ] ,
74
- position : 'left' ,
75
- maximum : 1000 ,
76
- minimum : 0
77
- } , {
78
- type : 'time' ,
79
- fields : [ 'time' ] ,
80
- position : 'bottom' ,
81
- visibleRange : [ 0 , 0.3 ] ,
82
- style : {
83
- axisLine : false
84
- }
85
- } ] ;
86
-
87
- cartesianSeries = {
88
- type : 'candlestick' ,
89
- xField : 'time' ,
90
- openField : 'open' ,
91
- highField : 'high' ,
92
- lowField : 'low' ,
93
- closeField : 'close' ,
94
- style : {
95
- ohlcType : 'ohlc' ,
96
- barWidth : 10 ,
97
- opacity : 0.9 ,
98
- dropStyle : {
99
- fill : 'rgb(237,123,43)' ,
100
- stroke : 'rgb(237,123,43)'
101
- } ,
102
- raiseStyle : {
103
- fill : 'rgb(55,153,19)' ,
104
- stroke : 'rgb(55,153,19)'
105
- }
106
- } ,
107
- aggregator : {
108
- strategy : 'time'
109
- }
110
- } ;
111
-
112
-
113
- cartesianInteractions = [ {
114
- type : 'panzoom' ,
115
- axes : {
116
- left : {
117
- allowPan : false ,
118
- allowZoom : false
119
- } ,
120
- bottom : {
121
- allowPan : true ,
122
- allowZoom : true
123
- }
124
- }
125
- } , {
126
- type : 'crosshair' ,
127
- axes : {
128
- label : {
129
- fillStyle : 'white'
130
- } ,
131
- rect : {
132
- fillStyle : '#344459' ,
133
- opacity : 0.7 ,
134
- radius : 5
135
- }
136
- }
137
- } ] ;
47
+ changeTheme = theme => this . theme = theme ;
48
+
49
+ toggleZoomOnPan = ( zoomOnPan ) => {
50
+ this . toggleCrosshair ( false ) ;
51
+ this . panzoom . setZoomOnPan ( zoomOnPan ) ;
52
+ this . zoom = zoomOnPan ;
53
+ }
138
54
55
+ toggleCrosshair = ( crosshair ) => {
56
+ this . panzoom . setEnabled ( ! crosshair ) ;
57
+ this . crosshair . setEnabled ( crosshair ) ;
58
+ if ( crosshair ) {
59
+ this . crosshair = crosshair ;
60
+ }
61
+ }
139
62
140
63
64
+ cartesianAxes = [ {
65
+ type : 'numeric' ,
66
+ fields : [ 'open' , 'high' , 'low' , 'close' ] ,
67
+ position : 'left' ,
68
+ maximum : 1000 ,
69
+ minimum : 0
70
+ } , {
71
+ type : 'time' ,
72
+ fields : [ 'time' ] ,
73
+ position : 'bottom' ,
74
+ visibleRange : [ 0 , 0.3 ] ,
75
+ style : {
76
+ axisLine : false
77
+ }
78
+ } ] ;
79
+
80
+ cartesianSeries = {
81
+ type : 'candlestick' ,
82
+ xField : 'time' ,
83
+ openField : 'open' ,
84
+ highField : 'high' ,
85
+ lowField : 'low' ,
86
+ closeField : 'close' ,
87
+ style : {
88
+ ohlcType : 'ohlc' ,
89
+ barWidth : 10 ,
90
+ opacity : 0.9 ,
91
+ dropStyle : {
92
+ fill : 'rgb(237,123,43)' ,
93
+ stroke : 'rgb(237,123,43)'
94
+ } ,
95
+ raiseStyle : {
96
+ fill : 'rgb(55,153,19)' ,
97
+ stroke : 'rgb(55,153,19)'
98
+ }
99
+ } ,
100
+ aggregator : {
101
+ strategy : 'time'
102
+ }
103
+ } ;
104
+
105
+
106
+ cartesianInteractions = [ {
107
+ type : 'panzoom' ,
108
+ axes : {
109
+ left : {
110
+ allowPan : false ,
111
+ allowZoom : false
112
+ } ,
113
+ bottom : {
114
+ allowPan : true ,
115
+ allowZoom : true
116
+ }
117
+ }
118
+ } , {
119
+ type : 'crosshair' ,
120
+ axes : {
121
+ label : {
122
+ fillStyle : 'white'
123
+ } ,
124
+ rect : {
125
+ fillStyle : '#344459' ,
126
+ opacity : 0.7 ,
127
+ radius : 5
128
+ }
129
+ }
130
+ } ] ;
141
131
142
132
}
0 commit comments