Using Table Widgets and Charts

 

Table Widgets

These widgets present computed facts in a tabular layout. 

To insert a Table Widget, click through Insert > Container > Table in the Worksheet Menu. This brings up the dialog for configuring the table to be inserted.

 

In order to present computed facts in this table, the table must be linked with a computed relation that appears in your rules. To link a computed relation, specify the relation's name as the identifier (Id) of the inserted table.  

 

Note that the number of rows and columns that you specify have no bearing of the number of rows and columns that actually appear in the worksheet. This is because the underlying data may potentially be dynamic as it is computed as opposed to being static. 

 

Example: Suppose that you have entered the following in your Rule Editor:

parent(art, bob)
parent(jim, bob)
parent(jake, mary)
parent(mary, jane)
parent(bob, steve)
parent(jane, steve)

sibling(X, Y) :- parent(X, P) & parent(Y, P) & distinct(X, Y)

Now, suppose that you want to visualize the computed facts of the form sibling(X, Y) then insert a Table Widget. Then, specify sibling as its Id, and click the green checkmark on the top left part of the dialog to insert the widget. When you click preview, you'll notice that this table lists the pairs of siblings in a tabular format.
 

 

 

Adding Table Headers and Captions: In order to add headers to your Table Widget, check the option in the insert or editing dialog which is labeled as Display First Row as Header. Next, in the Rows field enter the value 1, and in the Columns field enter the arity of the computed relation e.g. 2 in case of sibling

 

In order to specify a caption for your table, add it in the Caption field in the insert or editing dialog for the Table Widget.

 

sibling

 

Charts

To insert a chart click through Insert > Chart in the Worksheet Menu. After you do so, you'll notice the chart dialog.

 

First, you must specify the underlying data on which the chart is based. To do so you must specify the relation name in the table labeled Underlying Table. Next, you must specify the type of the chart e.g. line, spline, step etc. 

 

You can specify the data ranges in the chart's axes by specifying values for the Y-Indexes and X-Indexes fields. These values should correspond to argument indexes in the underlying relation.

For e.g. if r(X,Y,Z) is a 3-ary relation, and you want to plot the Y values vs. the X values, specify the value of Y-Indexes as 2 and the value of X-Indexes as 1. You can have at most one value for the X-index; if no values are specified, then the numbers 1, 2, 3 and so on are assigned depending on the ordering of the Y values. For multiple indexes for the Y-axis, separate the Y-Indexes values using commas e.g. 2, 3. 

 

Note: 

- The data values corresponding to indexes specified in the Y-Indexes field must be numbers

- For Pie Charts, Donuts, and Gauges, there can be at most 1 value for the Y-Indexes field. For Gauges, the value of the X-Indexes field is irrelevant, as these only portray the sum of a singe range of values. 

- The values corresponding to the Y-Indexes must be functionally dependent on the value corresponding to the X-Index for chart types: line, spline, step, area, area-spline, area-step, bar, donut, and pie. 

 

Y-Axis Categories: Filling in (comma-separated) values for this field assigns names to the Y-Axis ranges. If no values are specified, generic names - Y1, Y2, and so on are assigned.

 

Data Colors: Filling in (comma-separated) values for this field assigns colors to the Y-Axis ranges. If no values are specified, default chart colors are used.

 

Chart Dimensions: These can be specified as the values of the Width and the Height fields respectively. If no values are specified, these fields default to 200px.

 

You can also configure a bar chart by stacking the bars on top of each other. To do so fill up the Groups field by specifying groups of comma-separated Y-Index values, with one group per line.  

 

Examples

The following content (to be entered via the Rule Editor) will be used in upcoming examples.

score(student1, exam1, 90)
score(student1, exam2, 67)
​score(student1, exam3, 78)
​score(student2, exam1, 94)
​score(student2, exam2, 76)
​score(student2, exam3, 99)
​score(student3, exam1, 69)
​score(student3, exam2, 90)
​score(student3, exam3, 100)
exam(E) :- score(P, E, S)
student(P) :- score(P, E, S)
avgScorePerExam(E, A) :- exam(E) & avgofall(S, score(P, E, S), A)
studentscores(P, S1, S2, S3) :- score(P, exam1, S1) & score(P, exam2, S2) & score(P, exam3, S3)
student1scores(E, S) :- score(student1, E, S)
examscore(E, S1, S2, S2, A) :- score(student1, E, S1) & score(student2, E, S2) & 
                               score(student3, E, S3) & avgScorePerExam(E, A) 

Scatter Plot

 

Bar Chart

 

Pie Chart