Script of the day: Connecting charts

Home   »   Script of the day: Connecting charts

"Script of the day: Connecting charts

https://github.com/ObjectProfile/Roassal3

"
g1 := RSChart new.
p1 := RSLinePlot new.
p1 y: #(5 10 3 -4 -5 15).
g1 addPlot: p1.
g1 addDecoration: (RSXLabelDecoration new title: 'Time'; offset: 0 @ 10).
g1 addDecoration: (RSYLabelDecoration new title: 'Value'; offset: -20 @ 0).
g1 addDecoration: (RSHorizontalTick new).
g1 addDecoration: (RSVerticalTick new).
g1 build.

g2 := RSChart new.
p2 := RSLinePlot new.
p2 y: #(2 10 50 -20 40 30 25 12 4).
g2 addPlot: p2.
g2 addDecoration: (RSXLabelDecoration new title: 'Time'; offset: 0 @ 10).
g2 addDecoration: (RSYLabelDecoration new title: 'Value'; offset: -20 @ 0).
g2 addDecoration: (RSHorizontalTick new).
g2 addDecoration: (RSVerticalTick new).
g2 build.

c := RSCanvas new.
c add: (g1 canvas asShapeModel: 1).
c add: (g2 canvas asShapeModel: 2).
RSHorizontalLineLayout on: c shapes.

"We make the graphs draggable"
c shapes @ RSDraggable.

lb := RSLineBuilder arrowedLine.
lb shape color: Color red; width: 3.
lb withBorderAttachPoint.
lb canvas: c.
lb useAssociation: 1 -> 2.

c @ RSCanvasController.
c open

Leave a Reply

Your email address will not be published. Required fields are marked *