@@ -290,6 +290,10 @@ def eventFilter(self, obj, event):
290290
291291 return super ().eventFilter (obj , event )
292292
293+ @property
294+ def show_stretched (self ):
295+ return self .stretched and self .group_var is not self .attribute
296+
293297 def reset_attrs (self ):
294298 domain = self .dataset .domain
295299 self .attrs [:] = [
@@ -434,6 +438,7 @@ def reset_all_data(self):
434438 self .update_display_box ()
435439
436440 def grouping_changed (self ):
441+ self .controls .stretched .setDisabled (self .group_var is self .attribute )
437442 self .apply_attr_sorting ()
438443 self .update_graph ()
439444
@@ -445,6 +450,7 @@ def select_box_items(self):
445450 [c .conditions for c in temp_cond ])
446451
447452 def attr_changed (self ):
453+ self .controls .stretched .setDisabled (self .group_var is self .attribute )
448454 self .apply_group_sorting ()
449455 self .update_graph ()
450456
@@ -607,7 +613,7 @@ def _display_changed_disc(self):
607613 self .attr_labels = [QGraphicsSimpleTextItem (lab )
608614 for lab in self .label_txts_all ]
609615
610- if not self .stretched :
616+ if not self .show_stretched :
611617 if self .group_var :
612618 self .labels = [
613619 QGraphicsTextItem ("{}" .format (int (sum (cont ))))
@@ -637,7 +643,7 @@ def _display_changed_disc(self):
637643 bars , labels = box [::2 ], box [1 ::2 ]
638644
639645 self .__draw_group_labels (y , box_index )
640- if not self .stretched :
646+ if not self .show_stretched :
641647 self .__draw_row_counts (y , box_index )
642648 if self .show_labels and self .attribute is not self .group_var :
643649 self .__draw_bar_labels (y , bars , labels )
@@ -889,7 +895,7 @@ def draw_axis_disc(self):
889895 Draw the horizontal axis and sets self.scale_x for discrete attributes
890896 """
891897 assert not self .is_continuous
892- if self .stretched :
898+ if self .show_stretched :
893899 if not self .attr_labels :
894900 return
895901 step = steps = 10
@@ -916,7 +922,7 @@ def draw_axis_disc(self):
916922 self .label_width = lab_width
917923
918924 right_offset = 0 # offset for the right label
919- if not self .stretched and self .labels :
925+ if not self .show_stretched and self .labels :
920926 if self .group_var :
921927 rows = list (zip (self .conts , self .labels ))
922928 else :
@@ -939,7 +945,7 @@ def draw_axis_disc(self):
939945 l .setZValue (100 )
940946 t = self .box_scene .addSimpleText (str (val ), self ._axis_font )
941947 t .setPos (val * scale_x - t .boundingRect ().width () / 2 , 8 )
942- if self .stretched :
948+ if self .show_stretched :
943949 self .scale_x *= 100
944950
945951 def label_group (self , stat , attr , mean_lab ):
@@ -1049,7 +1055,7 @@ def strudel(self, dist, group_val_index=None):
10491055 for i , v in enumerate (dist ):
10501056 if v < 1e-6 :
10511057 continue
1052- if self .stretched :
1058+ if self .show_stretched :
10531059 v /= ss
10541060 v *= self .scale_x
10551061 cond = [FilterDiscrete (attr , [i ])]
@@ -1058,7 +1064,7 @@ def strudel(self, dist, group_val_index=None):
10581064 rect = FilterGraphicsRectItem (cond , cum + 1 , - 6 , v - 2 , 12 )
10591065 rect .setBrush (QBrush (QColor (* attr .colors [i ])))
10601066 rect .setPen (QPen (Qt .NoPen ))
1061- if self .stretched :
1067+ if self .show_stretched :
10621068 tooltip = "{}: {:.2f}%" .format (attr .values [i ],
10631069 100 * dist [i ] / sum (dist ))
10641070 else :
0 commit comments