Skip to content

Instantly share code, notes, and snippets.

@mkroehnert
Last active November 6, 2015 19:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkroehnert/aa3d1d9913cb0f29a49f to your computer and use it in GitHub Desktop.
Save mkroehnert/aa3d1d9913cb0f29a49f to your computer and use it in GitHub Desktop.
Roassal Dependency Chart similar to Parallel Coordinates Charts
"configuration" spaceBetweenLine := 150. lineHeight := 50. labelColor := (Color red alpha: 0.8). lineColor := (Color red alpha: 0.5). "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 | | elements labels | elements := OrderedCollection new. labels := label elementsOn: (columns at: i). labels doWithIndex: [ :element :index | | height | height := lineHeight * maxColumnElements / (labels size + 1). elements add: element. element translateTo: (i * spaceBetweenLine) @ (index * height). v add: element ]. columnElements add: elements. ]. v. "draw lines" "add RTEllipse as connectors and scale the radius to match the number of connections?" 2 to: numberOfColumns do: [ :column | (values at: column - 1) doWithIndex: [ :setOfValues :index | | fromElement | fromElement := ((columnElements at: (column - 1)) at: index). "" setOfValues do: [ :setIndex | | toElement elements lineShape line | toElement := ((columnElements at: column) at: setIndex). "" lineShape := RTBezierLine horizontal edgeFrom: fromElement to: toElement; color: lineColor. "" lineShape attachPoint: RTShorterDistanceAttachPoint new. line := lineShape edgeFrom: fromElement to: toElement. v add: line ]. ]. ]. v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment