@@ -502,6 +502,7 @@ def __eq__(self, other):
502
502
503
503
ohlc_colors = colorgen ()
504
504
indicator_figs = []
505
+ non_overlay_indicator_idxs = []
505
506
506
507
for i , value in enumerate (indicators ):
507
508
value = np .atleast_2d (value )
@@ -518,6 +519,7 @@ def __eq__(self, other):
518
519
else :
519
520
fig = new_indicator_figure ()
520
521
indicator_figs .append (fig )
522
+ non_overlay_indicator_idxs .append (i )
521
523
tooltips = []
522
524
colors = value ._opts ['color' ]
523
525
colors = colors and cycle (_as_list (colors )) or (
@@ -574,7 +576,7 @@ def __eq__(self, other):
574
576
# have the legend only contain text without the glyph
575
577
if len (value ) == 1 :
576
578
fig .legend .glyph_width = 0
577
- return indicator_figs
579
+ return ( indicator_figs , non_overlay_indicator_idxs )
578
580
579
581
# Construct figure ...
580
582
@@ -600,9 +602,10 @@ def __eq__(self, other):
600
602
601
603
ohlc_bars = _plot_ohlc ()
602
604
_plot_ohlc_trades ()
603
- indicator_figs = _plot_indicators ()
605
+ indicator_figs , non_overlay_indicator_idxs = _plot_indicators ()
604
606
if reverse_indicators :
605
607
indicator_figs = indicator_figs [::- 1 ]
608
+ non_overlay_indicator_idxs = non_overlay_indicator_idxs [::- 1 ]
606
609
figs_below_ohlc .extend (indicator_figs )
607
610
608
611
set_tooltips (fig_ohlc , ohlc_tooltips , vline = True , renderers = [ohlc_bars ])
@@ -617,9 +620,9 @@ def __eq__(self, other):
617
620
if plot_volume :
618
621
custom_js_args .update (volume_range = fig_volume .y_range )
619
622
indicator_ranges = {}
620
- for idx , indicator in enumerate (indicator_figs ):
621
- indicator_range_key = f'indicator_{ idx } _range'
622
- indicator_ranges .update ({indicator_range_key : indicator .y_range })
623
+ for idx ,( indicator , indicator_idx ) in enumerate (zip ( indicator_figs , non_overlay_indicator_idxs ) ):
624
+ indicator_range_key = f'indicator_{ indicator_idx } _range'
625
+ indicator_ranges .update ({indicator_range_key :indicator .y_range })
623
626
custom_js_args .update ({'indicator_ranges' : indicator_ranges })
624
627
fig_ohlc .x_range .js_on_change ('end' , CustomJS (args = custom_js_args ,
625
628
code = _AUTOSCALE_JS_CALLBACK ))
0 commit comments