There might be times you want to see different visualizations of the same data 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 you how to clone and modify elements to create multiple views.
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 - Creates a different 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.
Copy by reference (drag, Shift + drop)
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.
In the "Cloning example" below 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.
Cloning is useful
It allows you to keep the original view of an element, and create a modified view too.
Let's say your survey has a data column state. By default, Protobi shows each data column as an interactive bar chart. The initial element "state" will initially appear like this:
You want to modify the element "state" (seen above.) Maybe you want to choose a new chart type, translate or recode values, etc. However, you still want to see the original.
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 we've entered "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."
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.
"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 they are minimized for brevity.
Cloning groups: simple or recursive clones
In the above cloning 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.
But if you want to create truly independent graphs, you can select "Clone (recursive)" from the "Advanced" button in the toolbar. 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".