HighChart Visualisation

  • Date September 16, 2019
  • Written by Katsiaryna Ramanovich
  • Category JavaScript

This guide shows how to create HightChart using SAS9API.

Introduction

A large amount of data is difficult to perceive and understand. Well visualised data is easier to understand and find patterns.
Using SAS9API, you can visualize your data for analysis with help from any visualisation toolkit, such as HighCharts (https://www.highcharts.com/). Here is an example of sashelp.stocks visualised using HighCharts.

For this example you need:

  • Access to SAS server and sashelp library.
  • Access to a SAS9API instance that is configured to access SAS server.
  • Somewhere to create a store a few text files.
  • Chrome Browser.

Step 1 – Create HTML file.

Cope past below HTML code to a file, let’s call it index.html:

Step 2 – Create JavaScript file.

Create another file, let’s say main.js and add this code there:

Please note that in main.js, you will need to replace {sas9apihostname:port} with your SAS9API address and port number.

Step 3 – Overcome CORS (if required).

The chances are, you are not able to call on your instance of SAS9API due to CORS (Cross-Origin Resource Sharing). This is a security mechanism implemented in most browsers and you can read more about it here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS.

To overcome the problem, simply create a Chrome shortcut and add the following settings. Please note that there must be a space before the first characters.

Now you should have the following three files:

Launch the shortcut. An unsafe access warning is displayed immediately and must be skipped and you should have a visualisation of sashelp.stocks in your browser that should look like this:

Conclusion

Now you can quickly and easily navigate across the full time series using the timeline below, you can zoom in and out using the zoom buttons on the top left and you can export the graph in a variety of formats in the menu on the top right.
For this and other examples, see www.sas9api.io/examples.
[ninja_form id=1]