Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to lay out submorphs - example 5 - bar chart
Last updated at 12:39 pm UTC on 29 April 2018
This example shows how to do a simple bar chart by using the Morphic layout manager TableLayout.

MorphicLayoutExample5_Screenshot_from_2015-10-31.png

|cont m length |
 cont := Morph new.
  cont color: Color lightBlue.
 
  cont layoutPolicy: TableLayout new.
  cont listDirection: #topToBottom.
  cont cellPositioning:  #topLeft.
  cont hResizing: #shrinkWrap.
  cont vResizing: #shrinkWrap.
  
  #( 'Label A' 'Label B' 'Label C' 'Label D') 
  do:  [ :label |  
 	         m:= Morph new. 
 		 m layoutPolicy: TableLayout new.
 		 m listDirection: #leftToRight.
                m height: 25. 
 	         m cellInset: 4.
                m color: Color random twiceLighter.      
 
 		 length := m width + 200 atRandom.
                m width: length. 
 		 m addMorphBack: (StringMorph contents: label) .
                 m addMorphBack: (StringMorph contents: length asString). 
                cont addMorph: m.
             ].

  cont cellInset: 4.
  cont openInWorld.

See also

HistogramMorph