@@ -502,6 +502,7 @@ def __eq__(self, other):
502502
503503 ohlc_colors = colorgen ()
504504 indicator_figs = []
505+ non_overlay_indicator_idxs = []
505506
506507 for i , value in enumerate (indicators ):
507508 value = np .atleast_2d (value )
@@ -518,6 +519,7 @@ def __eq__(self, other):
518519 else :
519520 fig = new_indicator_figure ()
520521 indicator_figs .append (fig )
522+ non_overlay_indicator_idxs .append (i )
521523 tooltips = []
522524 colors = value ._opts ['color' ]
523525 colors = colors and cycle (_as_list (colors )) or (
@@ -574,7 +576,7 @@ def __eq__(self, other):
574576 # have the legend only contain text without the glyph
575577 if len (value ) == 1 :
576578 fig .legend .glyph_width = 0
577- return indicator_figs
579+ return ( indicator_figs , non_overlay_indicator_idxs )
578580
579581 # Construct figure ...
580582
@@ -600,9 +602,10 @@ def __eq__(self, other):
600602
601603 ohlc_bars = _plot_ohlc ()
602604 _plot_ohlc_trades ()
603- indicator_figs = _plot_indicators ()
605+ indicator_figs , non_overlay_indicator_idxs = _plot_indicators ()
604606 if reverse_indicators :
605607 indicator_figs = indicator_figs [::- 1 ]
608+ non_overlay_indicator_idxs = non_overlay_indicator_idxs [::- 1 ]
606609 figs_below_ohlc .extend (indicator_figs )
607610
608611 set_tooltips (fig_ohlc , ohlc_tooltips , vline = True , renderers = [ohlc_bars ])
@@ -617,9 +620,9 @@ def __eq__(self, other):
617620 if plot_volume :
618621 custom_js_args .update (volume_range = fig_volume .y_range )
619622 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 })
623626 custom_js_args .update ({'indicator_ranges' : indicator_ranges })
624627 fig_ohlc .x_range .js_on_change ('end' , CustomJS (args = custom_js_args ,
625628 code = _AUTOSCALE_JS_CALLBACK ))
0 commit comments