Have you ever wished to create graphs in your SAS Visual Analytics reports that are not part of the default SAS Visual Analytics objects but can still interact with the other report objects?
Have you ever been jealous of open source javascript graph frameworks?
In the SAS Visual Analytics 7.x versions, you probably used one of the following techniques or a mixture of creating:
What if SAS Visual Analytics offers you that functionality out of the box?
It does! Starting with the SAS Visual Analytics 8.2 release on SAS Viya you can use other open sourced graphics with the Data-Driven Content objects.
This blog entry explains how you can integrate SAS Visual Analytics 8.2+ report and a D3.js graph which makes use of the VA report data. D3.js has been chosen because it is a popular javascript library that specializes in data visualizations. Other javascript frameworks/libraries such as jQuery, Processing.js, etc. can also be integrated in your VA report. The integration is seamless and you will probably think that the graph is part of the default objects provided by SAS Visual Analytics.
With a basic understanding of javascript and html, adding a Data-Driven Content object is an easy task. The objective of this blog is not to explain how to code in javascript and html but to focus on how to use these pieces to integrate with a VA report. I have created all the files you need to be able to view this report in your own VA 8.2+ environment. I have attached a file that contains what is needed: the xml of the report, sample data, javascript files and an html page. The javascript files and the html page can be found with other samples on SAS repository on Github. You also need an environment with SAS Visual Analytics 8.2 or later licensed and installed.
The high level steps include: loading the sample data into CAS, then importing the xml of the report in SAS Visual Analytics and saving the html page and the javascript files on a web server. For the purpose of this example, the xml and javascript files are hosted on my personal server which should always be available to the VA environment. If you want to host the files on your own VA environment, you can store the files under the html directory under /var/www/ on the machine that hosts your HTTP Apache web service. You should copy the 2 directories and the html page contained in the zip file under the same directory.
If you uncheck or check some values in the List control, the graph adapts automatically.
The Roles should contain all the variables that are used in your graph. In this example, the data set is small so all the variables can be selected. If the dataset contains many variables, it might be a good idea to limit the variables to improve the performance.
if (window.addEventListener) { // For standards-compliant web browsers window.addEventListener("message", onMessage, false); } else { window.attachEvent("onmessage", onMessage); } // Retrieve data and begin processing function onMessage(event) { if (event && event.data) { //process event.data } }To ease your developments, SAS provides functions to use in your html page. The functions are explained here.
Works like a charm. Thank you sharing
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.