@@ -15,28 +15,31 @@ def __init__(self, dockArea, dockChart):
15
15
self .dockArea = dockArea
16
16
self .dockChart = dockChart
17
17
18
+ self .IndIchimokuActivated = False
19
+ self .IndRSIActivated = False
20
+ self .IndStochasticActivated = False
21
+ self .IndMAActivated = False
22
+
23
+ self .IndVolumesActivated = False
24
+
18
25
pass
19
26
20
27
#########
21
- # Draw chart
28
+ # Prepare the plot widgets
22
29
#########
23
- def drawFinPlots (self , data ):
30
+ def createPlotWidgets (self ):
24
31
25
- # Rest previous draws
26
- if hasattr (self , 'axo' ):
27
- self .ax0 .reset ()
28
- if hasattr (self , 'ax1' ):
29
- self .ax1 .reset ()
30
32
31
- self .data = data
32
33
33
34
# fin plot
34
35
self .ax0 , self .ax1 , self .ax2 , self .ax3 = fplt .create_plot_widget (master = self .dockArea , rows = 4 , init_zoom_periods = 100 )
35
36
self .dockArea .axs = [self .ax0 , self .ax1 , self .ax2 , self .ax3 ]
36
37
self .dockChart .addWidget (self .ax0 .ax_widget , 1 , 0 , 1 , 1 )
38
+ pass
37
39
38
- fplt .candlestick_ochl (data ['Open Close High Low' .split ()], ax = self .ax0 )
39
- #fplt.volume_ocv(data['Open Close Volume'.split()], ax=self.ax0.overlay())
40
+ def drawCandles (self ):
41
+
42
+ fplt .candlestick_ochl (self .data ['Open Close High Low' .split ()], ax = self .ax0 )
40
43
41
44
#self.hover_label = fplt.add_legend('', ax=self.ax0)
42
45
#fplt.set_time_inspector(self.update_legend_text, ax=self.ax0, when='hover', data=data)
@@ -251,38 +254,58 @@ def activateDarkMode(self, activated):
251
254
#############
252
255
# Indicators
253
256
#############
254
- def setIndicator (self , indicatorName , activated ):
255
257
256
- if (indicatorName == "Ichimoku" ):
258
+ def resetPlots (self ):
259
+ # Entirely reset graph
260
+ if (hasattr (self ,"ax0" )):
261
+ self .ax0 .reset ()
262
+ if (hasattr (self ,"ax1" )):
263
+ self .ax1 .reset ()
264
+ if (hasattr (self ,"ax2" )):
265
+ self .ax2 .reset ()
266
+ if (hasattr (self ,"ax3" )):
267
+ self .ax3 .reset ()
257
268
258
- if activated :
269
+ pass
270
+
271
+ def setChartData (self , data ):
272
+ self .data = data
273
+ pass
274
+
275
+ def updateChart (self ):
276
+
277
+ # Entirely reset graph
278
+ self .resetPlots ()
279
+
280
+ if (hasattr (self ,"data" )):
281
+
282
+ # Start plotting indicators
283
+ if self .IndIchimokuActivated :
259
284
self .ichimoku_indicator = ichimoku .Ichimoku (self .data )
260
285
self .ichimoku_indicator .draw (self .ax0 )
261
- else :
262
286
263
- for item in list (self .ax0 .items ):
264
- self .ax0 .removeItem (item )
287
+ if self .IndVolumesActivated :
288
+ fplt .volume_ocv (self .data ['Open Close Volume' .split ()], ax = self .ax0 .overlay ())
289
+
290
+ # Finally draw candles
291
+ self .drawCandles ()
265
292
266
- self .drawFinPlots (self .data )
293
+ # Refresh view : auto zoom
294
+ fplt .refresh ()
267
295
268
- # Refresh view
269
- self .ax0 .vb .refresh_all_y_zoom ()
270
296
pass
271
297
272
- def activate_volumes (self , activated ):
273
-
274
- if activated :
275
- fplt .volume_ocv (self .data ['Open Close Volume' .split ()], ax = self .ax0 .overlay ())
276
- else :
277
- #self.ax0.vb.reset()
278
- for item in list (self .ax0 .items ):
279
- self .ax0 .removeItem (item )
280
298
281
- self .drawFinPlots (self .data )
282
- #self.ax0.overlay().reset()
299
+ def setIndicator (self , indicatorName , activated ):
300
+
301
+ if (indicatorName == "Ichimoku" ):
302
+ self .IndIchimokuActivated = activated
303
+
304
+ if (indicatorName == "Volumes" ):
305
+ self .IndVolumesActivated = activated
306
+
307
+ self .updateChart ()
283
308
284
- # Refresh view
285
- self .ax0 .vb .refresh_all_y_zoom ()
286
309
pass
287
310
288
311
#############
0 commit comments