ObjectProfile / Roassal3

The Roassal Visualization Engine
MIT License
95 stars 52 forks source link

Chart composite #568

Closed DurieuxPol closed 12 months ago

DurieuxPol commented 12 months ago

This PR aims at refactoring the hierarchy of charts and plots in Roassal by implementing a composite pattern, to make plots behave like charts and charts composed of plots. That is to say single plots don't require to be added into a RSChart to be displayed anymore. However if you want to display multiple plots together, you'll still need to add them into a chart, a RSCompositeChart, which works in a similar way as RSChart previously did. Now RSAbstractPlot, all its subclasses and RSCompositeChart inherit from an abstract superclass RSAbstractChart. image

A couple examples:

x := 1 to: 9 by: 0.1.
y := x sin.
p := RSLinePlot new x: x y: y.
p open

image

x1 := 1 to: 9 by: 0.1.
y1 := x1 sin.
x2 := -3 to: 4 by: 0.1.
y2 := x2 squared.
c := RSCompositeChart new.
p1 := RSLinePlot new x: x1 y: y1.
p2 := RSLinePlot new x: x2 y: y2.
c add: p1.
c add: p2.
c open

image