Copy and Clone

Create multiple views of the same data


Sometimes you want to see different visualizations of the same column. You might want to see the data with different chart types, create a segmentation variable or just save a particular crosstab of interest. This tutorial shows how to clone and modify elements to create multiple views.

Example 1

Let's say your survey has a data column state. By default Protobi shows each data column as an interactive bar chart, so state will initially appear like this:

You can modify this element however you want -- choose a new chart type, translate or recode values, etc. But maybe you want to keep the original view and also create a modified view too. This is where cloning is useful.

To create an independent copy of an element, select the element. Press the "Advanced" button in the toolbar and select "Clone (simple)":

It will prompt you to enter a key for the new element. In this example enter "state_cloud".

You now have two different elements pointing at the same data column:

You can change the new element without affecting the first. Press the blue edit icon, and from the context menu choose "Chart type..." and select "Word cloud"

Clone vs copy-by-reference

There are two ways to copy views in Protobi:

  • Copy by reference - The same element appears in multiple groups
  • Clone Create a differnet element that refers to the same data column

Each interactive chart in Protobi is called an "Element". Each element is defined by an attribute key. When Protobi creates an initial element for each data column, its key is the same as the data column name. In this example the initial element is state.

Copy by reference

Multiple groups can refer to the same key as a child element and that element will appear in each group. You can do this by dragging an element from one group to another and hold the Shift key when you drop. When copying by reference, changing the element in one place will change it everywhere.

Clone

In the example above we created an new element with a different key state_cloud. Because it has a different key we can change its properties without affecting the first element.

The new element has an attribute field with value "state" so it draws its data from column "state". You can verify this by selecting "More properties..." from the context menu.

How cloning works underneath

When you clone an element, you get a new element with a new key. Below is the JSON configuration for the new element:


Here we can see that it has a new key. And it also specifies a new attribute "field": "state" which tells the element to get its data from the same data column as the original element.

The attribute "format" is also copied over, as in this survey states are represented in the data as integer codes and value labels for display are specified in the format. In the view above that is minimized for brevity.

Cloning groups: simple or recursive clones

In the above example we cloned a simple element state that had no children. Sometimes you may wish to create multiple views of a group.

The question then is whether to copy just the parent group (aka a "simple" clone) or recursively copy its child elements (aka a "recursive" clone).

For instance, we might have a group q15 that shows ratings as a stacked bar chart:

We might wish to clone the element and see it as a tornado chart as well:

If we create a simple clone, both parent groups will refer to the same children by reference. So if we change the titles or formats for a child element in one group it will change it in both. Generally this will be what you want.

Recursively clone

But if you want to create truly independent graphs, you can select "Clone (recursive)" and it will clone not just the parent group but its children all way down.

In this case, rather than specify a new key for the clone element, you specify a prefix that will be prepended to each element's key to generate new keys.

Or set heritability on the simple cloned group

Generally simple cloning is appropriate for most cases where you need to create a new view.

But keep in mind that some changes to a group element propagate down to its children. This includes changing color, format, recodes, filters and crosstab columns. You may not want changes to the new copy to propagate down to the child elements.

When cloning a group element, consider setting the new copy so that its changes do not propagate down to its children.

To do this press the edit icon, select "More properties..." and set "Heritable" to "No".

Video tutorial