Extract a common interface for scatter and line chart #11
+271
−387
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi all.
I was trying to port to GT Plotter some charts from the Alexander Bergel book, Agile Artificial Intelligence in Pharo, originally made using Roassal. One of the first book examples use a composite chart that mixes a scatter plot with a line chart. I tried to reproduce that in GT, but I realized that
GtPlotterCompositeChart
class only works withGtPlotterLineChart
objects.Comparing
GtPlotterLineChart
class definition withGtPlotterScatterChart
I could notice many common instance variables and methods (many of them, just accessors on these variables). Thus, I decided to extract the common behavior to a new super class that I calledGtPlotterXYChart
.Beyond the extraction of the common behavior, I need to do a small fix on methods
axisXStencil
andaxisYStencil
in theGtPlotterScatterChart
class to guarantee the scatter chart object is correctly associated with the stencil. This was necessary since I got an error when the composite objectcreate
method executed. This is the small fix:This is a fragment class diagram with the resultant classes related to the existent examples classes that test them. All original examples pass.
Here are the snippets to recreate the chart from the book (page 28, figure 1-12). I did it in a Lepiter page with three snippets:
Generate the scatter plot:
Generate the Line chart:
Generate the composite chart:
This is the result chart: