A Conditional Image is an image that can be altered based on numeric, categorical, or text inputs, specifically a single value, R calculation, table, or variable. The fill and image can be automatically set to better depict the data it is representing and dynamically update based on specified thresholds. For these images, Displayr provides a variety of inbuilt pictures and icons, but you can also link to custom images stored online.
Please note this requires the Data Stories module or a Displayr license.
Examples
- In this example, we have a satisfaction table which we want to display as face icons that convey the Net Promoter Score when the page is filtered by the viewer in published mode. This image will be colored based on the categories of Detractors (0-6), Passives (7-8) and Promoters (9-10).
- For another example where you can change this image in real-time based on an R calculation connected to a combo box, see How to Switch Logos and Images Based on a Control Box Selection.
Method
- 1. Go to the Visualization icon > Pictographs > Conditional Image in the toolbar.
- 2. Under Data > DATA SOURCE > Data source, select the method to condition the image. In this case, we will select Table.
- 3. Select the table to use under Input data and enter either the indices or labels of the cell to use in the Select Row/Column fields. If the table is a single cell, simply enter 1 for Select Row.
- 3. Under Data > OUTPUT > Image type, select Displayr images from the dropdown to use one of our built-in images, otherwise select Custom images and enter the appropriate URL. Here, we will use Displayr images.
- 4. Set the Default image to Face - Sad and set the Fill color to Red from the color picker. This will always be the lowest value or category. In this case, it will represent the Detractors from values 0 to 6.
- 5. Set Threshold 1 to 7 to signify moving from a Detractor to a Passive. Note, if the source data displays categories instead of a numeric value, you would enter the next category label here.
- 6. Set Image 1 to Face - Neutral and set the Fill color to Yellow from the color picker. This will represent the Passives.
- 7. Set Threshold 2 to 9 to signify moving from a Passive to a Promoter.
- 8. Set the Image 1 to Face - Happy and set the Fill color to Green from the color picker. This will represent the Promoters.
Object Inspector Options
The following is an explanation of the options available in the Object Inspector for this specific visualization. Refer to Visualization Options for general chart formatting options.
Inputs
-
DATA SOURCE
- One of the following options:
- Type or paste value
- Use an existing R output
- Table
- Variable - Average
- Variable - Sum
- Variable - Percentage
- Variable - Most frequent
- One of the following options:
-
OUTPUT
- Image type Either Displayr images or Custom images. If Displayr images is chosen then the users can chose from the dropdown of available images, which can be re-colored. If Custom images, then users can enter a URL to their own image.
-
- Threshold A value the input data will be compared with to determine the image to show. If the input data is numeric or ordered, the thresholds should be numeric values supplied in increasing order. If the input data is categorical or text, then categories can be supplied in any order. Any number of thresholds can be supplied.
-
- Default Image The default image is Stick man.
See Visualization - Number Options for other options.
In the examples above, we used Type or paste value for simplicity, but users can also link to variables or other outputs which can automatically update.
Next
How to Switch Logos and Images Based on a Control Box Selection
How to Create a Pictograph Bar Chart
How to Create a Single Icon Pictograph