ViewBots

ViewBots are one-line analytic instruments used to dynamically compute a statistical or comparative measure over a subset of records and are extremely useful for analyzing tables. They are one of the most popular functions in Manifold for experienced users. When a ViewBot is configured for a drawing's table it continues to function when the drawing has the focus. For example, if we configure a ViewBot to show the average of a given field for selected items it will continue reporting the average of the selection whether or not we select items from a drawing's table or by using mouse selection commands to select objects in the drawing.

 

Turn on the ViewBots pane with a SHIFT-ALT-B ("B" for "ViewBot") or with a View - Panes - ViewBots command.

 

images\eg_vbots_11.gif

 

The ViewBots above, for example, report on those operations they have been told to conduct on the table in view. ViewBots are bound to the tables for which they were created. When a drawing window is active, the ViewBots pane will list all ViewBots created for the drawing's table. When a drawing layer in a map is active, the ViewBots pane will list all ViewBots for the active drawing's table.

 

To Create a ViewBot

 

1. Open the ViewBots pane and press the New ViewBot button. A new ViewBot line will be added to the ViewBots pane.

2. Double click onto the saved ViewBot fields to choose analytic functions and the scope of the ViewBot.

3. Press the Refresh button to update the results in that ViewBot if the ViewBot autorefresh option is not on in Tools - Options.

 

To Make a Selection using a ViewBot

 

1. Click on the target component to make it active. Open the ViewBots pane.

2. Click on the desired ViewBot to highlight it.

3. Click on one of the ViewBot pane's selection command buttons to combine the object set picked out by the ViewBot with any selection that is currently made. For example, clicking on the Subtract from Selection button will take the set of objects picked out by the ViewBot and will subtract the objects it contains from the current selection.

 

To Delete a ViewBot

 

1. Click on the desired saved ViewBot to highlight it.

2. Press the Delete ViewBot button.

 

To Edit a ViewBot

 

 1. Double-click on the ViewBot to be edited, or

 2. Click on the ViewBot to highlight it and press the F2 key.

 

ViewBots Pane Toolbar Commands

 

Use the New ViewBot and Delete ViewBot buttons to create and to remove ViewBots from the pane. Use Refresh and Refresh All to update the calculation in the highlighted ViewBot or in all ViewBots.

 

Five selection command buttons are arrayed at the top of the ViewBots pane. These commands apply to whatever set of objects is picked out by the highlighted ViewBot. If we click on a ViewBot to highlight it and then press one of these buttons, the object set picked out by that ViewBot will be combined with whatever is the current selection in the image. The selection commands allow us to use object picked out by a View ViewBot to replace the selection, to add to the selection, to subtract from the selection, to invert with the selection and to intersect the selection. For example, if we have a ViewBot that reports the number of objects for which the Elevation is greater than 100, the set of all objects picked out by this ViewBot will be combined with the existing selection with the selection command buttons.

 

images\btn_move_up.gif

Move Up - Move the active layer up one position in the layer stack.

images\btn_move_down.gif

Move Down - Move the active layer down one position in the layer stack.

images\btn_selcmd_rep.gif

Replace Selection - Replace the existing selection with the objects picked out by the highlighted ViewBot.

images\btn_selcmd_add.gif

Add to Selection - Add the objects picked out by the highlighted ViewBot to the existing selection.

images\btn_selcmd_sub.gif

Subtract from Selection - Subtract the objects picked out by the highlighted ViewBot from the existing selection.

images\btn_selcmd_inv.gif

Invert with Selection - Deselect what is in the objects set picked out by the highlighted ViewBot that was already in the existing selection and otherwise add the ViewBot's object set.

images\btn_selcmd_int.gif

Intersect Selection - Select only the region of overlap between the highlighted ViewBot's objects and what is in the existing selection. If there is no overlap, nothing will be selected.

images\btn_refresh.gif

Refresh - Update the highlighted ViewBot.

images\btn_refresh_all.gif

Refresh All - Update all ViewBots in the pane.

images\btn_add_thing.gif

New ViewBot - Create a new ViewBot line in the ViewBots list.

images\btn_delete_thing.gif

Delete ViewBot - Delete the highlighted ViewBot.

 

Add ViewBot Dialog Controls

 

Scope

The objects upon which the ViewBot operates: all objects (or records, pixels, etc), the selection, or the name of any saved selection.

Column

The name of the field to use. Optional for some operations. For example, Number of Areas or Center X don't require a field.

Operation

The ViewBot operator to be employed.

Argument

Arguments, if required for the operator.

Ignore Case

Treat upper and lower case letters the same in strings. Used with text operators.

Ignore leading and trailing whitespace

Ignore any space or tab characters in strings. Used with text operators. " This" would be treated the same as "This".

Ignore interior whitespace

Ignore any space or tab characters within strings. Used with text operators. "Th is" would be treated the same as "This".

Caption

String to display for ViewBot results. Can include escape sequences in square brackets:

[Argument] - Replace with argument in use.

[Column] - Data field in use.

[Operation] - Replace with the operation in use.

[Scope] - Replace with scope in use, such as the name of a saved selection.

[Scope Size] - Replace with the number of items in the scope.

[Time] - Estimated time to compute the ViewBot. Normally used when Autorefresh is turned off to warn users of computationally intensive ViewBots that should not be casually refreshed.

[Value] - Repeats the value computed and displayed in the Value column. Normally redundant.

The default Caption string of

[Column] [Operation] [Argument] in [Scope]

creates a reasonably comprehensible sentence for most ViewBots.

Autorefresh viewbot

Command ViewBot to self-refresh on any changes in the subject component. If this value is not checked, a Refresh or Refresh All command in the ViewBots pane will be required to update the value of the 'ViewBot on any changes.

 

Selection and ViewBots

 

Some ViewBots such as the maximum value of a column allow selection from the ViewBot and some (such as the average value of a column) do not.

 

Examples

 

We will open the Order Details table from the sample Nwind.mdb database.

 

images\eg_vbots_01.gif

 

For simplicity, we will hide all columns except Order ID and Unit Price. In the illustration above we've opened the ViewBots pane using View - Panes - ViewBots and have positioned it over the table so we can make screenshots of both at the same time.

 

images\btn_add_thing.gif To create a new ViewBot we press New ViewBot in the ViewBots pane.

 

images\eg_vbots_02.gif

 

The Add ViewBot dialog opens up. We will choose Unit Price for the Column and Average for the Operation, using defaults for all other choices.

 

images\eg_vbots_04.gif

 

In particular, we will leave the caption string to the default settings. We press OK and a new ViewBot is created.

 

images\eg_vbots_03.gif

 

images\btn_refresh_all.gif We can press Refresh All at any time to re-compute the ViewBot if Autorefresh viewbot is not checked. The Value column for the ViewBot reports that 24.71998… is the average of unit price values in the table.

 

images\eg_vbots_04.gif

 

To see how the Caption string is generated, recall that the Caption box in the Add Viewbots dialog contains the default string

 

 [Column] [Operation] [Argument] in [Scope]

 

images\eg_vbots_05.gif

 

The result in the ViewBot Caption column is the text seen above.

 

images\eg_vbots_06.gif

 

When the ViewBot is recomputed, the values of the various escape phrases in [ ] square brackets are replaced with the relevant text. There is no [Argument] used in this ViewBot so it is replaced by nothing.

 

images\btn_add_thing.gif Let's add another ViewBot. Once again we press the New ViewBot button.

 

images\eg_vbots_07.gif

 

We will use the same settings as before, but this time we will change the Scope to [Selection]. The Scope setting specifies upon which objects (records) the ViewBot will operate. By changing the Scope to [Selection] we are telling the ViewBot to look only at records that are selected.

 

images\eg_vbots_08.gif

 

images\btn_refresh_all.gif We can press Refresh All again (or, simply check the Autorefresh ViewBot box when creating the ViewBot) to see the new values. There is no value for the second ViewBot because we have not selected anything in this table.

 

images\eg_vbots_09.gif

 

If we make a selection as seen above and press Refresh All we see that the average of unit price for the selected records is 23.3. Note that we can simultaneously see the average for all records and for those only in the selection.

 

Suppose we had previously made a selection representing new orders we've received and that we've saved this selection in the Selections pane under the name New Orders. We could create a third ViewBot using New Orders in the Scope box (all saved selections will appear as choices in the Scope box).

 

images\eg_vbots_09a.gif

 

We would then be able to see how the unit price average for all records compares to the unit price average in the New Orders saved selection as well as in any current selection we care to make. We could also have query panes or use other methods to make selections and the ViewBots will faithfully report the latest figures based on the current selection if that is the Scope specified. The "live" ability of ViewBots to dynamically report values based on the current selection is an analytic and data discovery instrument of great power.

 

images\btn_delete_thing.gif We can get rid of the third ViewBot by clicking on it to highlight it and then choosing Delete ViewBot.

 

Using ViewBots to Make Selections

 

Operations like Average are aggregate operations that calculate a number without identifying any specific record. Many ViewBot operations can identify specific records. We can then use the ViewBot to select those records. We will add two more ViewBots that can be used for selection.

 

images\eg_vbots_10.gif

 

First we add a ViewBot that finds records where the Unit Price is greater than 50.

 

images\eg_vbots_11.gif

 

The resulting ViewBot informs us there are 191 records that are priced higher than 50.

 

images\eg_vbots_12.gif

 

We will add one more ViewBot that finds records where the Unit Price is less than 50.

 

images\eg_vbots_13.gif

 

This ViewBot tells us the table contains 2630 records that are priced lower than 50.

 

To make a selection using a ViewBot, we click on it to highlight it and then we press one of the Selection Commands at the top of the ViewBots pane.

 

images\eg_vbots_14.gif

 

images\btn_selcmd_rep.gif For example, we can click on the greater than 50 ViewBot and press Replace Selection.

 

images\eg_vbots_15.gif

 

Instantly, all those records with unit price greater than 50 are selected. In the table in view, we see only one such record (the others are scrolled out of sight). Note also that the ViewBot showing the average unit price in the selection has also been recomputed. We now know that the average unit price for products priced higher than 50 dollars is 100.86. What is the average unit price for products that are priced lower than 50 dollars?

 

images\eg_vbots_16.gif

 

images\btn_selcmd_rep.gif To find out, we click on the lower than 50 ViewBot and press Replace Selection once more.

 

images\eg_vbots_17.gif

 

Instantly, all records with unit price less than 50 are selected. We can now see from the second ViewBot that the average price for products that sell for less than 50 dollars is 19.13.

 

ViewBot Uses

 

ViewBots can be used for a very wide variety of purposes. In the example above we could have added ViewBots that reported the total number of items in the selection and then tried different ViewBots at different price levels to find average, maximum and minimum values.

 

We can use ViewBots for selection. Suppose we have a mailing list that needs to have duplicates cleaned. We could open a ViewBot that finds all duplicates except the first. If we select records with that ViewBot we can then delete the selected records.

 

Suppose we have a customer database for a store where we would like to find all customers who have purchased refrigerators who are not on credit hold. If our database has a "notes" field that contains the word "refrigerator" for anyone who has purchased a refrigerator, and if it also has a field for credit hold, we can create two ViewBots. One ViewBot finds all records where the notes field contains "refrigerator." The other ViewBot finds all records where credit hold is true. To create a list for mailing, we use Replace Selection with the refrigerator ViewBot to select all records with refrigerators. We then use Subtract from Selection with the credit hold ViewBot to remove the credit hold records from the selection. The resulting selection is only those people with refrigerators who are not on credit hold.

 

Example: Using ViewBots with Drawings

 

ViewBots are a great way to see a report of information from a drawing. In this example we import and use the mexico_eg.mif sample drawing that is on the Manifold CD. This drawing shows provinces in Mexico and provides demographic data for each province.

 

Begin by importing the drawing. Open the drawing and turn on the ViewBots pane with a SHIFT-ALT-B or with a View - Panes - ViewBots menu command.

 

images\btn_add_thing.gif Click the New ViewBot button to create a new ViewBot.

 

 

images\eg_vbots_18.gif

 

Configure the Add ViewBot pane as seen above. In the example drawing the POBL_1990 field gives the population in 1990 for each province. We will create a ViewBot that reports the sum of population in all selected provinces. Although Manifold will offer a suggested caption based on the scope and operation in use, we will provide our own caption, "Total Population in Selection." Note that the Autorefresh viewbot checkbox has been checked. This updates the ViewBot on any changes.

 

images\eg_vbots_19.gif

 

The initial result in the ViewBots pane is an empty ViewBot. The Value will not appear until we select something, either in the drawing or in the drawing's table.

 

images\eg_vbots_20.gif

 

If we select three provinces in the drawing the ViewBot will update.

 

images\eg_vbots_21.gif

 

Now it reports a total population of 5763591 for the three provinces.

 

images\eg_vbots_22.gif

 

If we pop open the drawing's table we can see the values of POBL_1990 that are in the selected provinces do indeed add up to 5763591.

 

images\eg_vbots_23.gif

 

If we make a different selection in the drawing the ViewBot will update the value.

 

images\eg_vbots_24.gif

 

We can see that this selection has a much higher total population (because, of course, it includes the provinces surrounding Mexico City).

 

See Also

 

See the Selection topic for examples of Replace, Add, Subtract, Invert and Intersect selection command usage.

 

ViewBot Operators for lists of operators that may be used within ViewBots.

 

See the Show Area of a Parcel in Acres topic for an example that uses ViewBots to show acreage of selected parcels.

 

ViewBot values are displayed using the format of the underlying column, if appropriate. See the Formatting Columns topic for information on setting formats.