Thanks Alexandre,
great advice once again.
Here is the current result
[image: Inline image 1]
and the script:
========
"configuration" spaceBetweenLine := 150. lineHeight := 250. labelColor := (Color red alpha: 0.3). lineColor := (Color red alpha: 0.2).
"columns: Array of column label Arrays" columns := #( #('One' 'Two') #('Ten' 'Eleven' 'Twelve' 'Thirteen' 'Fourteen' 'Fifteen') #('Twenty' 'Twentyone' 'Twentytwo' 'Twentythree') ).
"values: Array of columns column: Array of columnelements columnelement: Array of indices the element is associated with in the next column" values := #( #( #(1 3 4 5 6) #(2 3 5) ) #( #(1 2) #(1 2 3) #(3 4) #(2 3 4) #(2 4) #(4) ) ).
numberOfColumns := columns size. maxColumnElements := (columns collect: [ :element | element size]) reduce: [ :size1 :size2 | size1 max: size2 ].
v := RTView new. label := RTLabel text: [ :t | t ]. label color: labelColor.
"draw labels" columnElements := OrderedCollection new. 1 to: numberOfColumns do: [ :i | | t labels | t := OrderedCollection new. labels := label elementsOn: (columns at: i). labels doWithIndex: [ :element :index | t add: element. element translateTo: (i * (spaceBetweenLine - 1)) @ (index * lineHeight / maxColumnElements). v add: element ]. columnElements add: t. ]. v.
"draw lines" 2 to: numberOfColumns do: [ :column | (values at: column - 1) doWithIndex: [ :setOfValues :index | setOfValues do: [ :setIndex | | fromElement toElement line | fromElement := ((columnElements at: (column - 1)) at: index). toElement := ((columnElements at: column) at: setIndex). lineShape := RTLine new color: lineColor. lineShape attachPoint: RTShorterDistanceAttachPoint new. line := lineShape edgeFrom: fromElement to: toElement. v add: line ]. ]. ]. v
========
The last thing I am going to experiment with will be to replace the straight lines with RTBezierLine.
Thanks, Manfred
On Fri, Jun 5, 2015 at 3:17 PM, Alexandre Bergel alexandre.bergel@me.com wrote:
Hi Manfred,
You just need to have a proper attach point. Consider this slightly modified version:
"configuration" spaceBetweenLine := 350. lineHeight := 250.
"data" columns := #( #('One' 'Two') #('Ten' 'Eleven' 'Twelve' 'Thirteen' 'Fourteen' 'Fifteen') ). values := #( #(1 3 4 5 6) #(2 3 5) ).
numberOfColumns := columns size. columnHeight := columns reduce: [ :c1 :c2 | (c1 size) max: (c2 size) ].
v := RTView new. label := RTLabel text: [ :t | t ]. label color: (Color red alpha: 0.3).
"draw labels" setOfElements := OrderedCollection new. 1 to: numberOfColumns do: [ :i | | t labels | t := OrderedCollection new. labels := label elementsOn: (columns at: i). labels doWithIndex: [ :element :index | t add: element. element translateTo: (i * (spaceBetweenLine - 1)) @ (index * lineHeight / columnHeight). v add: element ]. setOfElements add: t. ].
"draw lines" 2 to: numberOfColumns do: [ :column | values doWithIndex: [ :setOfValues :index | setOfValues do: [ :toIndex | lineShape := RTLine new color: (Color red alpha: 0.2). lineShape attachPoint: RTShorterDistanceAttachPoint new. line := lineShape edgeFrom: ((setOfElements at: (column - 1)) at: index) to: ((setOfElements at: column) at: toIndex). v add: line ]. ]. ]. v
Regarding the multiple columns, give a try first and we will iterate.
Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.