Table Graph Framework
This framework extends the
VisualWorks Business Graphs
to dynamically display any two-dimensional collection of numbers in graph form. In addition, the labels for the X and Y axes must also be given (the Y axis labels are the legend).
In addition to this basic feature, there are several extensions.
- Create a dependency between the graph and the collection, so that when the collections values change, the graph automatically updates itself.
- Pass an entire table instead of a collection of values, in which case the dependency between the table and the graph is set up automatically.
- Display the results of a query in a graph. Again, the dependency between the query and the graph is set up automatically.
- Display the results of a query for each individual month. The dependency is set up automatically.
High level class descriptions:
- Graph display
TableGraph handles the graph display. It is able to handle
the first two features listed above. This class holds another class called
GraphHolder as a subcanvas, which in turn holds the VisualWorks graphics view.
makes a dynamic version of the VisualWorks graphics package. Because the
package requires the specifications of legend, type of graph, legend placement,
among other things, to be determined as part of the spec, the specifications cannot change. But TableGraph
allows all these features to be changed at run time.
is a subclass of TableGraph
. It displays the graphs that are calculated through GraphMaker, which makes a graph that is dependent on queries..
- Graph making through
handles the last two features above. The GraphMaker
holds a two-dimensional collection of block values to display. It is also possible to perform simple arithmetic operations on GraphMaker.
The values of the two GraphMakers must have the same dimensions.
- Its subclass, SingleGraphMaker,
gets the value from the result of a set of element specs.
The resulting values of each element spec is on the X-axis. Each element spec should return a group of values. The group should match the Y-axis.
is a subclass of SingleGraphMaker
that must use one element spec whose value returns the date of each row along with the value to graph. Based on the current selections of date in CatState, it calculates the values for each month. The X-axis is ordered by the months.
- CompositeGraphMaker is the result of applying arithmetic operations on GraphMaker.
- A TableGraph is opened after it is wrapped by CatModelWrapper, which gives a consistent look and feel for all Business Model windows. The row labels and the legend are passed after being grouped into an array. The size of the table is 5 by 2, meaning that the legend has two elements, and there are 5 row labels. It is possible to show a table right under the graph with the values. But it is turned off here.
graphWrapper := CatModelWrapper models: (Array with: (graph := TableGraph tableAdaptor: table labels: (Array with: rowLabels with: legend))) windowLabel: graphWindowName.
tableSize: 5 @ 2;
- A MonthlyGraphMaker is created here with an element spec. Its legend labels are given, but not the row labels, since the months represent that. The months to query the information is gathered from CatState, represented by the variable state. It is possible to put constraints so that only certain values will be selected. For example, it is very common to constrain the values returned by the family types. This maker is then passed to QueryGraph, which then graphs the values returned from the maker.
elementDefiner := (self elementSpecs elementDefinerAt: name) copy.
elementDefiner constraint: constraint.
maker := MonthlyGraphMaker new
legend: #('Budget' 'Actual');
graphWrapper := CatModelWrapper models: (Array with: (graph := QueryGraph queryCalculator: maker columnLabels: #('Budget' 'Actual'))) windowLabel: label.
Relevant classes and categories:
If you have any questions or changes, please contact:
Joseph W. Yoder at:(217) 344-4847 or by email:
Return to Financial Model Documentation Page