@@ -537,10 +537,23 @@ def __eq__(self, other):
537537 colors = value ._opts ['color' ]
538538 colors = colors and cycle (_as_list (colors )) or (
539539 cycle ([next (ohlc_colors )]) if is_overlay else colorgen ())
540- legend_label = LegendStr (value .name )
541- for j , arr in enumerate (value , 1 ):
540+
541+ if isinstance (value .name , str ):
542+ tooltip_label = value .name
543+ if len (value ) == 1 :
544+ legend_labels = [LegendStr (value .name )]
545+ else :
546+ legend_labels = [
547+ LegendStr (f"{ value .name } [{ i } ]" )
548+ for i in range (len (value ))
549+ ]
550+ else :
551+ tooltip_label = ", " .join (value .name )
552+ legend_labels = [LegendStr (item ) for item in value .name ]
553+
554+ for j , arr in enumerate (value ):
542555 color = next (colors )
543- source_name = f'{ legend_label } _{ i } _{ j } '
556+ source_name = f'{ legend_labels [ j ] } _{ i } _{ j } '
544557 if arr .dtype == bool :
545558 arr = arr .astype (int )
546559 source .add (arr , source_name )
@@ -550,24 +563,24 @@ def __eq__(self, other):
550563 if is_scatter :
551564 fig .scatter (
552565 'index' , source_name , source = source ,
553- legend_label = legend_label , color = color ,
566+ legend_label = legend_labels [ j ] , color = color ,
554567 line_color = 'black' , fill_alpha = .8 ,
555568 marker = 'circle' , radius = BAR_WIDTH / 2 * 1.5 )
556569 else :
557570 fig .line (
558571 'index' , source_name , source = source ,
559- legend_label = legend_label , line_color = color ,
572+ legend_label = legend_labels [ j ] , line_color = color ,
560573 line_width = 1.3 )
561574 else :
562575 if is_scatter :
563576 r = fig .scatter (
564577 'index' , source_name , source = source ,
565- legend_label = LegendStr ( legend_label ) , color = color ,
578+ legend_label = legend_labels [ j ] , color = color ,
566579 marker = 'circle' , radius = BAR_WIDTH / 2 * .9 )
567580 else :
568581 r = fig .line (
569582 'index' , source_name , source = source ,
570- legend_label = LegendStr ( legend_label ) , line_color = color ,
583+ legend_label = legend_labels [ j ] , line_color = color ,
571584 line_width = 1.3 )
572585 # Add dashed centerline just because
573586 mean = float (pd .Series (arr ).mean ())
@@ -578,9 +591,9 @@ def __eq__(self, other):
578591 line_color = '#666666' , line_dash = 'dashed' ,
579592 line_width = .5 ))
580593 if is_overlay :
581- ohlc_tooltips .append ((legend_label , NBSP .join (tooltips )))
594+ ohlc_tooltips .append ((tooltip_label , NBSP .join (tooltips )))
582595 else :
583- set_tooltips (fig , [(legend_label , NBSP .join (tooltips ))], vline = True , renderers = [r ])
596+ set_tooltips (fig , [(tooltip_label , NBSP .join (tooltips ))], vline = True , renderers = [r ])
584597 # If the sole indicator line on this figure,
585598 # have the legend only contain text without the glyph
586599 if len (value ) == 1 :
0 commit comments