@@ -291,6 +291,10 @@ def eventFilter(self, obj, event):
291291
292292 return super ().eventFilter (obj , event )
293293
294+ @property
295+ def show_stretched (self ):
296+ return self .stretched and self .group_var is not self .attribute
297+
294298 def reset_attrs (self ):
295299 domain = self .dataset .domain
296300 self .attrs [:] = [
@@ -448,6 +452,7 @@ def reset_all_data(self):
448452 self .update_display_box ()
449453
450454 def grouping_changed (self ):
455+ self .controls .stretched .setDisabled (self .group_var is self .attribute )
451456 self .apply_attr_sorting ()
452457 self .update_graph ()
453458
@@ -459,6 +464,7 @@ def select_box_items(self):
459464 [c .conditions for c in temp_cond ])
460465
461466 def attr_changed (self ):
467+ self .controls .stretched .setDisabled (self .group_var is self .attribute )
462468 self .apply_group_sorting ()
463469 self .update_graph ()
464470
@@ -623,7 +629,7 @@ def _display_changed_disc(self):
623629 self .attr_labels = [QGraphicsSimpleTextItem (lab )
624630 for lab in self .label_txts_all ]
625631
626- if not self .stretched :
632+ if not self .show_stretched :
627633 if self .group_var :
628634 self .labels = [
629635 QGraphicsTextItem ("{}" .format (int (sum (cont ))))
@@ -657,7 +663,7 @@ def _display_changed_disc(self):
657663 bars , labels = box [::2 ], box [1 ::2 ]
658664
659665 self .__draw_group_labels (y , box_index )
660- if not self .stretched :
666+ if not self .show_stretched :
661667 self .__draw_row_counts (y , box_index )
662668 if self .show_labels and self .attribute is not self .group_var :
663669 self .__draw_bar_labels (y , bars , labels )
@@ -909,7 +915,7 @@ def draw_axis_disc(self):
909915 Draw the horizontal axis and sets self.scale_x for discrete attributes
910916 """
911917 assert not self .is_continuous
912- if self .stretched :
918+ if self .show_stretched :
913919 if not self .attr_labels :
914920 return
915921 step = steps = 10
@@ -936,7 +942,7 @@ def draw_axis_disc(self):
936942 self .label_width = lab_width
937943
938944 right_offset = 0 # offset for the right label
939- if not self .stretched and self .labels :
945+ if not self .show_stretched and self .labels :
940946 if self .group_var :
941947 rows = list (zip (self .conts , self .labels ))
942948 else :
@@ -959,7 +965,7 @@ def draw_axis_disc(self):
959965 l .setZValue (100 )
960966 t = self .box_scene .addSimpleText (str (val ), self ._axis_font )
961967 t .setPos (val * scale_x - t .boundingRect ().width () / 2 , 8 )
962- if self .stretched :
968+ if self .show_stretched :
963969 self .scale_x *= 100
964970
965971 def label_group (self , stat , attr , mean_lab ):
@@ -1071,7 +1077,7 @@ def strudel(self, dist, group_val_index=None):
10711077 for i , v in enumerate (dist ):
10721078 if v < 1e-6 :
10731079 continue
1074- if self .stretched :
1080+ if self .show_stretched :
10751081 v /= ss
10761082 v *= self .scale_x
10771083 cond = [FilterDiscrete (attr , [i ])]
@@ -1080,7 +1086,7 @@ def strudel(self, dist, group_val_index=None):
10801086 rect = FilterGraphicsRectItem (cond , cum + 1 , - 6 , v - 2 , 12 )
10811087 rect .setBrush (QBrush (QColor (* colors [i ])))
10821088 rect .setPen (QPen (Qt .NoPen ))
1083- if self .stretched :
1089+ if self .show_stretched :
10841090 tooltip = "{}: {:.2f}%" .format (
10851091 values [i ],
10861092 100 * dist [i ] / sum (dist ))
0 commit comments