<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dynamic Images by Users Selections in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Dynamic-Images-by-Users-Selections/m-p/729498#M14767</link>
    <description>&lt;P&gt;In VA 8.x, you can accomplish this with Data Driven Content javascript code.&amp;nbsp; Here is an example of using the existing VA web server to store your images. I am&amp;nbsp; storing my code and images in the same location:&amp;nbsp; /opt/sas/viya/home/var/www/html/htmlcommons.&amp;nbsp; The URL for that would be &lt;A href="http://&amp;lt;your" target="_blank"&gt;http://&amp;lt;your&lt;/A&gt;&amp;nbsp;VA server&amp;gt;/htmlcommons.&amp;nbsp; I am using a table called Cars that is located within base SAS as sashelp.cars.&amp;nbsp; I imported that table into CAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="results.JPG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56565iBF8B5A6A01A2540F/image-size/large?v=v2&amp;amp;px=999" role="button" title="results.JPG" alt="results.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. include Honda.jpg in htmlcommons location&lt;/P&gt;
&lt;P&gt;2. . include Data Driven Content code to htmlcommons location.&amp;nbsp; (Add code at the bottom into a file called Dynamic.html)&lt;/P&gt;
&lt;P&gt;(note:&amp;nbsp; The code assumes that your image is located in the same location as Dynamic.html so it is referencing:&amp;nbsp; &amp;nbsp;./Honda.jpg etc&lt;/P&gt;
&lt;P&gt;4. In VA, on the Data Driven Content Object properties, add your url to your Data Driven Content object.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://&amp;lt;your" target="_blank"&gt;http://&amp;lt;your&lt;/A&gt;&amp;nbsp;VA server&amp;gt;/htmlcommons/Dynamic.html.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. Also click on the Source tab and add the data item Make.&lt;/P&gt;
&lt;P&gt;5. I set an Action from the List Table to the DDC object so when I click on Honda, "Honda" is passed in the form of a json file to the Data Driven Content object&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code Author: Renato Luppi&amp;nbsp;@ SAS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&amp;gt;&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;/P&gt;
&lt;P&gt;html {&lt;/P&gt;
&lt;P&gt;width: 100%;&lt;/P&gt;
&lt;P&gt;height: 100%;&lt;/P&gt;
&lt;P&gt;display: flex;&lt;/P&gt;
&lt;P&gt;flex-direction: column;&lt;/P&gt;
&lt;P&gt;justify-content: center;&lt;/P&gt;
&lt;P&gt;align-items: center;&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt;&lt;BR /&gt;body {&lt;BR /&gt;&lt;BR /&gt;max-width: 90%;&lt;/P&gt;
&lt;P&gt;max-height: 90%;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;img {&lt;BR /&gt;&lt;BR /&gt;max-width: 100%;&lt;/P&gt;
&lt;P&gt;max-height: 100%;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;lt;/style&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;div id="sample"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;&lt;BR /&gt;// ***************&lt;/P&gt;
&lt;P&gt;//INITIAL FUNCTION&lt;BR /&gt;&lt;BR /&gt;// IE9+ browser support&lt;/P&gt;
&lt;P&gt;if (window.addEventListener) {&lt;BR /&gt;&lt;BR /&gt;// Event for standard browsers&lt;/P&gt;
&lt;P&gt;window.addEventListener("message", onMessage, false);&lt;BR /&gt;&lt;BR /&gt;} // IE9+ browser support&lt;/P&gt;
&lt;P&gt;// Window support for IE8&lt;/P&gt;
&lt;P&gt;else {&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// Event for older browsers&lt;/P&gt;
&lt;P&gt;window.attachEvent("onmessage", onMessage);&lt;BR /&gt;&lt;BR /&gt;} // Window support for IE8&lt;/P&gt;
&lt;P&gt;// onMessage function for processing incoming information&lt;/P&gt;
&lt;P&gt;function onMessage (evt) {&lt;/P&gt;
&lt;P&gt;// check that the conditions are met&lt;/P&gt;
&lt;P&gt;if (evt &amp;amp;&amp;amp; evt.data) {&lt;/P&gt;
&lt;P&gt;// Variables&lt;/P&gt;
&lt;P&gt;var results = null;&lt;/P&gt;
&lt;P&gt;var columnInfo = null;&lt;BR /&gt;&lt;BR /&gt;// get the data name&lt;/P&gt;
&lt;P&gt;self.resultName = evt.data.resultName;&lt;/P&gt;
&lt;P&gt;// Check for records&lt;/P&gt;
&lt;P&gt;if (evt.data.availableRowCount &amp;gt;= 0) {&lt;/P&gt;
&lt;P&gt;// Variables are assigned&lt;/P&gt;
&lt;P&gt;results = evt.data;&lt;/P&gt;
&lt;P&gt;columnInfo = evt.data.columns;&lt;/P&gt;
&lt;P&gt;// build the table&lt;/P&gt;
&lt;P&gt;jsonToTable(columnInfo, results.data);&lt;/P&gt;
&lt;P&gt;} // Check for records&lt;BR /&gt;&lt;BR /&gt;} // verify that the conditions are met&lt;BR /&gt;&lt;BR /&gt;} // onMessage function for processing incoming information&lt;BR /&gt;&lt;BR /&gt;// jsonToTable function to create the table and process the information&lt;/P&gt;
&lt;P&gt;function jsonToTable (columnInfo, jsonData) {&lt;BR /&gt;&lt;BR /&gt;// Variable and DOOM cleaning&lt;/P&gt;
&lt;P&gt;var tableDiv = document.getElementById("sample");&lt;/P&gt;
&lt;P&gt;tableDiv.innerHTML = "";&lt;BR /&gt;&lt;BR /&gt;// Create table&lt;/P&gt;
&lt;P&gt;var table = tableDiv.appendChild(document.createElement('table'));&lt;/P&gt;
&lt;P&gt;var tableBody = table.appendChild(document.createElement('tbody'));&lt;BR /&gt;&lt;BR /&gt;// check for records&lt;/P&gt;
&lt;P&gt;if (jsonData) {&lt;/P&gt;
&lt;P&gt;// scroll through the data&lt;/P&gt;
&lt;P&gt;for (var i = 0; i &amp;lt; jsonData.length; i++) {&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// I add a new line&lt;/P&gt;
&lt;P&gt;addDataRow(jsonData[i]);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;} // scroll through the data&lt;BR /&gt;&lt;BR /&gt;} // check for records&lt;/P&gt;
&lt;P&gt;// addDataRow function to add records to the table&lt;/P&gt;
&lt;P&gt;function addDataRow (dataFields) {&lt;/P&gt;
&lt;P&gt;// create line&lt;/P&gt;
&lt;P&gt;var tr = document.createElement('tr');&lt;/P&gt;
&lt;P&gt;// Iteration of the fields to add them to the row&lt;/P&gt;
&lt;P&gt;dataFields.forEach(function (field, index) {&lt;/P&gt;
&lt;P&gt;// verify that field is other than absent&lt;/P&gt;
&lt;P&gt;if (field != '(ausente)') {&lt;/P&gt;
&lt;P&gt;// A picture element is created and assigned a value of&lt;/P&gt;
&lt;P&gt;var img = document.createElement('img');&lt;BR /&gt;field = './' + field + '.jpg';&lt;BR /&gt;img.src=field;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// The image is added to the line&lt;/P&gt;
&lt;P&gt;tr.appendChild(img)&lt;BR /&gt;&lt;BR /&gt;} // verify that field is other than absent&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;}); //Iteration of the fields to add them to the row&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// The line is added to the table&lt;/P&gt;
&lt;P&gt;tableBody.appendChild(tr);&lt;/P&gt;
&lt;P&gt;} // addDataRow function to add records to the table&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;} // jsonToTable function to create the table and process the information&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keith Myers&lt;/P&gt;
&lt;P&gt;SAS Tech Support&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Mar 2021 21:14:29 GMT</pubDate>
    <dc:creator>KeithM</dc:creator>
    <dc:date>2021-03-26T21:14:29Z</dc:date>
    <item>
      <title>Dynamic Images by Users Selections</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Dynamic-Images-by-Users-Selections/m-p/728336#M14755</link>
      <description>&lt;P&gt;If I would like to allow users to change the images in the dashboard dynamically based on their selections in the drop down boxes, is there any way we could do this with using SAS VA 8.3.1? Many Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 02:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Dynamic-Images-by-Users-Selections/m-p/728336#M14755</guid>
      <dc:creator>kcwtech</dc:creator>
      <dc:date>2021-03-23T02:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Images by Users Selections</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Dynamic-Images-by-Users-Selections/m-p/729498#M14767</link>
      <description>&lt;P&gt;In VA 8.x, you can accomplish this with Data Driven Content javascript code.&amp;nbsp; Here is an example of using the existing VA web server to store your images. I am&amp;nbsp; storing my code and images in the same location:&amp;nbsp; /opt/sas/viya/home/var/www/html/htmlcommons.&amp;nbsp; The URL for that would be &lt;A href="http://&amp;lt;your" target="_blank"&gt;http://&amp;lt;your&lt;/A&gt;&amp;nbsp;VA server&amp;gt;/htmlcommons.&amp;nbsp; I am using a table called Cars that is located within base SAS as sashelp.cars.&amp;nbsp; I imported that table into CAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="results.JPG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56565iBF8B5A6A01A2540F/image-size/large?v=v2&amp;amp;px=999" role="button" title="results.JPG" alt="results.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. include Honda.jpg in htmlcommons location&lt;/P&gt;
&lt;P&gt;2. . include Data Driven Content code to htmlcommons location.&amp;nbsp; (Add code at the bottom into a file called Dynamic.html)&lt;/P&gt;
&lt;P&gt;(note:&amp;nbsp; The code assumes that your image is located in the same location as Dynamic.html so it is referencing:&amp;nbsp; &amp;nbsp;./Honda.jpg etc&lt;/P&gt;
&lt;P&gt;4. In VA, on the Data Driven Content Object properties, add your url to your Data Driven Content object.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://&amp;lt;your" target="_blank"&gt;http://&amp;lt;your&lt;/A&gt;&amp;nbsp;VA server&amp;gt;/htmlcommons/Dynamic.html.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. Also click on the Source tab and add the data item Make.&lt;/P&gt;
&lt;P&gt;5. I set an Action from the List Table to the DDC object so when I click on Honda, "Honda" is passed in the form of a json file to the Data Driven Content object&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code Author: Renato Luppi&amp;nbsp;@ SAS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&amp;gt;&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;/P&gt;
&lt;P&gt;html {&lt;/P&gt;
&lt;P&gt;width: 100%;&lt;/P&gt;
&lt;P&gt;height: 100%;&lt;/P&gt;
&lt;P&gt;display: flex;&lt;/P&gt;
&lt;P&gt;flex-direction: column;&lt;/P&gt;
&lt;P&gt;justify-content: center;&lt;/P&gt;
&lt;P&gt;align-items: center;&lt;/P&gt;
&lt;P&gt;}&lt;BR /&gt;&lt;BR /&gt;body {&lt;BR /&gt;&lt;BR /&gt;max-width: 90%;&lt;/P&gt;
&lt;P&gt;max-height: 90%;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;img {&lt;BR /&gt;&lt;BR /&gt;max-width: 100%;&lt;/P&gt;
&lt;P&gt;max-height: 100%;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;lt;/style&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;div id="sample"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;&lt;BR /&gt;// ***************&lt;/P&gt;
&lt;P&gt;//INITIAL FUNCTION&lt;BR /&gt;&lt;BR /&gt;// IE9+ browser support&lt;/P&gt;
&lt;P&gt;if (window.addEventListener) {&lt;BR /&gt;&lt;BR /&gt;// Event for standard browsers&lt;/P&gt;
&lt;P&gt;window.addEventListener("message", onMessage, false);&lt;BR /&gt;&lt;BR /&gt;} // IE9+ browser support&lt;/P&gt;
&lt;P&gt;// Window support for IE8&lt;/P&gt;
&lt;P&gt;else {&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// Event for older browsers&lt;/P&gt;
&lt;P&gt;window.attachEvent("onmessage", onMessage);&lt;BR /&gt;&lt;BR /&gt;} // Window support for IE8&lt;/P&gt;
&lt;P&gt;// onMessage function for processing incoming information&lt;/P&gt;
&lt;P&gt;function onMessage (evt) {&lt;/P&gt;
&lt;P&gt;// check that the conditions are met&lt;/P&gt;
&lt;P&gt;if (evt &amp;amp;&amp;amp; evt.data) {&lt;/P&gt;
&lt;P&gt;// Variables&lt;/P&gt;
&lt;P&gt;var results = null;&lt;/P&gt;
&lt;P&gt;var columnInfo = null;&lt;BR /&gt;&lt;BR /&gt;// get the data name&lt;/P&gt;
&lt;P&gt;self.resultName = evt.data.resultName;&lt;/P&gt;
&lt;P&gt;// Check for records&lt;/P&gt;
&lt;P&gt;if (evt.data.availableRowCount &amp;gt;= 0) {&lt;/P&gt;
&lt;P&gt;// Variables are assigned&lt;/P&gt;
&lt;P&gt;results = evt.data;&lt;/P&gt;
&lt;P&gt;columnInfo = evt.data.columns;&lt;/P&gt;
&lt;P&gt;// build the table&lt;/P&gt;
&lt;P&gt;jsonToTable(columnInfo, results.data);&lt;/P&gt;
&lt;P&gt;} // Check for records&lt;BR /&gt;&lt;BR /&gt;} // verify that the conditions are met&lt;BR /&gt;&lt;BR /&gt;} // onMessage function for processing incoming information&lt;BR /&gt;&lt;BR /&gt;// jsonToTable function to create the table and process the information&lt;/P&gt;
&lt;P&gt;function jsonToTable (columnInfo, jsonData) {&lt;BR /&gt;&lt;BR /&gt;// Variable and DOOM cleaning&lt;/P&gt;
&lt;P&gt;var tableDiv = document.getElementById("sample");&lt;/P&gt;
&lt;P&gt;tableDiv.innerHTML = "";&lt;BR /&gt;&lt;BR /&gt;// Create table&lt;/P&gt;
&lt;P&gt;var table = tableDiv.appendChild(document.createElement('table'));&lt;/P&gt;
&lt;P&gt;var tableBody = table.appendChild(document.createElement('tbody'));&lt;BR /&gt;&lt;BR /&gt;// check for records&lt;/P&gt;
&lt;P&gt;if (jsonData) {&lt;/P&gt;
&lt;P&gt;// scroll through the data&lt;/P&gt;
&lt;P&gt;for (var i = 0; i &amp;lt; jsonData.length; i++) {&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// I add a new line&lt;/P&gt;
&lt;P&gt;addDataRow(jsonData[i]);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;} // scroll through the data&lt;BR /&gt;&lt;BR /&gt;} // check for records&lt;/P&gt;
&lt;P&gt;// addDataRow function to add records to the table&lt;/P&gt;
&lt;P&gt;function addDataRow (dataFields) {&lt;/P&gt;
&lt;P&gt;// create line&lt;/P&gt;
&lt;P&gt;var tr = document.createElement('tr');&lt;/P&gt;
&lt;P&gt;// Iteration of the fields to add them to the row&lt;/P&gt;
&lt;P&gt;dataFields.forEach(function (field, index) {&lt;/P&gt;
&lt;P&gt;// verify that field is other than absent&lt;/P&gt;
&lt;P&gt;if (field != '(ausente)') {&lt;/P&gt;
&lt;P&gt;// A picture element is created and assigned a value of&lt;/P&gt;
&lt;P&gt;var img = document.createElement('img');&lt;BR /&gt;field = './' + field + '.jpg';&lt;BR /&gt;img.src=field;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// The image is added to the line&lt;/P&gt;
&lt;P&gt;tr.appendChild(img)&lt;BR /&gt;&lt;BR /&gt;} // verify that field is other than absent&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;}); //Iteration of the fields to add them to the row&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// The line is added to the table&lt;/P&gt;
&lt;P&gt;tableBody.appendChild(tr);&lt;/P&gt;
&lt;P&gt;} // addDataRow function to add records to the table&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;} // jsonToTable function to create the table and process the information&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keith Myers&lt;/P&gt;
&lt;P&gt;SAS Tech Support&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 21:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Dynamic-Images-by-Users-Selections/m-p/729498#M14767</guid>
      <dc:creator>KeithM</dc:creator>
      <dc:date>2021-03-26T21:14:29Z</dc:date>
    </item>
  </channel>
</rss>

