Class phpchartPlus is responsible for instanciating the appropriate Chart class and associating it with instances of ConfigParser,DataParser,Font and ColorAllocator classes.
Chart, is the base abstract class for all chart types. Therefore subclasses ( AreaChart, BarChart, LineChart, PieChart) must implement the abstract method Chart::draw() to gain the parent class functionality. The draw() method is where all the calculations and image generation is done, therefore implementing this method differently in subclasses gives us different chart types.
As it was said, the Chart instance is associated with a ConfigParser and a DataParser instance. The ConfigParser is responsible for reading the chart configuration parameters (ex bgColor,TextColor, ImageSize) whereas the DataParser is responsible for reading the chart data. All the data read, end up in the Chart instance for the image generation.
To support the reading of configuration and chart data parameters in a way independent of the data source implementation details each of the parsers can be configured with an appropriate strategy class. The inclusion of the strategy class seperates the proccess of reading the data from the data source (therefore closely connected with the data source implementation details) from the proccess of presenting the data to the Chart. This allows (the process of delegating work to another class) the development of an open-ended number of strategy classes and the runtime selection of the strategy classs based on some user-defined parameters. |