Sample 63233: Viewing the structure of a JSON file that is passed to a SAS® Visual Analytics data-driven content object
Overview
In SAS Visual Analytics, data-driven content objects often require input data to be in a certain format. The data passed from SAS Visual Analytics is a JSON object. It is often helpful to get a visual interpretation of the JSON object that is sent from SAS Visual Analytics. This sample demonstrates how to see a visual interpretation of jsonDataViewer.html, which is one of the samples that are provided on GitHub. You can find this file in the samples folder.
In the following display, a row in a list table is selected and the data-driven content object displays the contents of the JSON object that is passed. Notice that the JSON object sets a 1 in the SUV array element because the action between the list table and the data-driven content object is set to Linked selection.
There are two ways to implement Data Driven Content.
- Reference and store the html into a SAS Job Execution form. (No special access to web server needed)
- Reference the html from a web server. (Access to web server required)
Steps Using a SAS Job Execution form to Reference HTML
- Download the JsonDataViewer.zip file from the Downloads tab in this SAS Note.
- Launch SAS Job Execution. Example: http://<YourVAserver>/SASJobExecution
- Navigate the SAS Content folder to a location that is accessible to the users viewing the report.
- Right-click the folder. Select New ► File:
- Click OK. Right-click the job and select Edit ► New HTML form.
- Within the JsonDataViewer.html file, there is a reference to messagingUtil.js that is commented out. Access to this file is needed for all Data Driven Content objects. It is recommended that the web server administrator should copy this file to a location on your web server that can be easily accessed. Another alternative is to copy the entire code for messagingUtil.js and paste it at the top of the JsonDataViewer.html file. Then include the combined file into the form. If you decide to paste in the messagingUtil.js content, wrap it with a script tag. Note: The location of messagingUtil.js on GitHub is here:
<script type="text/javascript"> Insert contents of messagingUtil.js here </script>
- Click the Save Changes icon.
- Right-click the job and select Properties. Copy the job URL from the Details tab:
- You must insert "form" into the URL to call the form directly:
Example: http://<YourVAserver/SASJobExecution/form/?_program=/Public/Jobs/MyFirstDataDrivenContent
- Add a Data Driven Content object to your report. In the options, reference the URL in step 9.
Steps Referencing the HTML from Web Server
- Download the JsonDataViewer.zip file from the Downloads tab in this SAS Note.
- Extract the contents of the file to the web application server where SAS Visual Analytics is deployed. For example, the path might be: /opt/sas/viya/home/var/www/html/htmlcommons/JsonDataViewer.html.
- Create a URL to get to the file. By default, htmlcommons is a pre-configured drop zone that can be referenced directly using a URL similar to this one: http://yourWebServer/htmlcommons/JsonDataViewer.html
- Create a SAS Visual Analytics report using a list table and data-driven content object.
- Add a data-driven content object to the report canvas. If you are using the Cars table, open the Data Roles pane and add Invoice and Type. On the Options pane, replace the current URL with the URL from Step 3.
- Add a list table object to the report canvas. On the Data Roles pane, add Invoice and Type. On the Actions pane, make sure that Automatic actions on all objects is not selected. Expand Object Links, and select the data-driven content object. Click the Linked selection icon.
Additional Resources on Data-Driven Content
Data-Driven Content: leveraging third-party visualizations in SAS Visual Analytics (part 1 of 2)
Data-Driven Content: leveraging third-party visualizations in SAS Visual Analytics (part 2 of 2)
Custom Visualizations in SAS Visual Analytics - A Strategy for Using the Data-Driven Content Object
Leverage a Google 3D-PieChart within VA using the Data-Driven Content Object
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
It is often helpful to get a visual interpretation of the JSON object that is sent from SAS Visual Analytics. This sample demonstrates how to see a visual interpretation of jsonDataViewer.html, which is one of the data-driven content samples that are provided on GitHub.
Date Modified: | 2022-01-31 10:17:47 |
Date Created: | 2018-11-15 11:45:02 |
Operating System and Release Information
SAS System | SAS Visual Analytics (on SAS Viya) | Cloud Foundry | 8.3 | | Viya | |
Linux for x64 | 8.3 | | Viya | |
Microsoft® Windows® for x64 | 8.3 | | Viya | |