Move, mirror, clone

Create multiple views of the same data

Updated at February 12th, 2020

You can move elements in Protobi to organize your project's view. But, you might also want to see different visualizations of the same data column. Perhaps you 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 move elements, and create multiple views of an element using mirror or clone. 

To move, mirror or clone drag + drop the element to the desired location. The below dialog will pop up.

There are three options in the dialog:

  • Move - No duplication will occur; the element will be relocated. 
  • Mirror (copy by reference) - The same element will appear in multiple groups.
  • Clone (independent copy) - A different element that refers to the same data column is created.

Move elements

You can change the location and order of questions by using the tree to move elements. Press the element, then drag + drop to the desired position. The move or copy dialog will appear, choose "move."

You can move elements by dropping: 1) within the tree, or 2) from the tree into tabs. 

Drag + drop elements within the tree

Within the tree we moved Q1 from Section 1 into Section 2 (group will turn yellow). Moving an element into a group will place the element last in that group. 

Move an element to a specified position by dragging it to the white space between elements (indicated by yellow line). 

If you move an element between top level groups you're moving the element to $root, and it will become its own tab. 

Drag + drop elements from the tree into tabs

Here, we moved Q1 from Section 1 to Section 2 using a different method that produces the same result as moving within the tree. Drag the element from the tree and drop it into the white space of the tab. The element will be placed last in the group.

Note: This doesn't work conversely (from tab to tree.)

You can also move an element from the tree and onto the "+" sign and it will become a top level item with its own tab. This produces the same result as moving an element to $root within the tree. 


Mirror vs clone

There are two ways to duplicate views in Protobi:

  • Mirror (copy by reference) - The same element will appear in multiple groups.
  • Clone (independent copy) - A different element that refers to the same data column is created.

To mirror or clone drag + drop the element you want to duplicate to the desired location. From the dialog, choose the respective option.

Interactive charts in Protobi are called "elements." To better understand how duplicating views of the same data works, it's important to know that 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.

Mirror

Choosing to mirror an element essentially tells Protobi to recreate the same visualization, but in a different location. This works because multiple groups can refer to the same key as a child element, and that element will appear in each group. When copying by reference, changing the element in one place will change it everywhere.

Delete a mirror copy

Because they share a key, you cannot hide or delete a mirror copy without affecting the original element and vice versa. You can, however, remove the element from view by deleting it from the group's list of children in JSON. 

Below, Q1 is dragged from Section 1 to Section 2 and a mirror copy is made. 

To remove Q1 from Section 2, press "Edit JSON..." from the context menu and delete Q1 from the "children" attribute. This will not affect how Q1 appears in Section 1. 

 

Clone

Cloning allows you to create an independent copy of an element. You can keep the view of the original element, and have a modified view too.

There are two ways to clone an element:

  • Press on the element in the tree, drag + drop to the desired location, and select clone
  • Select the element (either in the tree or tab view), press the "Advanced" button in the toolbar and choose "Clone (simple)"
    • Keyboard shortcut is EL

When you choose to clone, you will be prompted to give the new element a different key. The key cannot be identical to any other key in the project. 

Because this new element has its own unique key, we can change its properties without affecting the original element. In addition to a different key, the new element will have an attribute field with a value that refers to the data column from the original element. You can verify this by selecting "More properties..." from the context menu.

Delete a clone

You can remove clones from view by hiding or deleting them as you would any other element. Since clones have unique keys, removing them won't have an affect on original elements. Select the clone, then press the del key on your keyboard. 

Cloning example

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


There are many ways you can modify this element. You might want to see the data in a different chart type, language, or as recoded values. By cloning, we can create these different visualizations without changing the original element. 

In this example we've cloned state and entered "state_cloud" for the new element's key.

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. You can also see field in "More properties..." from the context menu.

The attribute "format" is copied over from the original element. 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 vs recursive

In the above example, we cloned a simple element state that had no children. It's also possible to create multiple views of an entire 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).

Simple

If we create a simple clone, both parent groups will refer to the same children by reference. If we change the titles or formats for a child element in one group, it will change it in both. Typically, a simple clone is sufficient when creating a different visualization of a compacted group.  

We have a group q15 that shows ratings as a stacked bar chart:

We clone (simple) the element to see it as a tornado chart as well:


Recursive

To create truly independent graphs, you can select "Clone (recursive)" from the "Advanced" button in the toolbar. This will not only clone the parent group, but also create independent copies of its children all way down. If you want to specify a different format for child elements in the cloned group, these changes will not be applied to the original group. 

When you clone (recursive), 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.

Set heritability on cloned groups

Whether you're using a simple or recursive clone, some changes to a group element propagate down to its children. This includes changing color, format, recodes, filters and crosstab columns. You may want to modify the group without those changes propagating 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."

Note: Remember for simple clones, both parent groups will refer to the same children by reference. If you set "Heritable" to "No" on the simple clone, but you make changes to the original group element those changes will still propagate down to the children.

Video tutorial





Was this article helpful?