Adding a REST Data Source
Currently, the Reveal SDK is in the process of decoupling the data sources from the Reveal SDK core package. In order to ensure the project's continued functionality, you might be required to install additional packages into your project. Please see the Supported Data Sources topic for more information.
Step 1 - Add an event handler for the RevealView.onDataSourcesRequested
event.
var revealView = new $.ig.RevealView("#revealView");
revealView.onDataSourcesRequested = (callback) => {
//add code here
callback(new $.ig.RevealDataSources([], [], false));
};
Step 2 - In the RevealView.onDataSourcesRequested
event handler, create a new instance of the RVRESTDataSource object. Set the URL
property to the url of the REST endpoint, and set the useAnonymousAuthentication
property to false if there is no authentication required to access the REST endpoint. After you have created the RVRESTDataSource
object, add it to the data sources collection.
revealView.onDataSourcesRequested = (callback) => {
const restDataSource = new $.ig.RVRESTDataSource();
restDataSource.title = "Sales by Category";
restDataSource.subtitle = "Excel2Json";
restDataSource.url = "https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9";
restDataSource.useAnonymousAuthentication = true;
callback(new $.ig.RevealDataSources([restDataSource], [], true));
};
When the application runs, create a new Visualization and you will see the newly created REST data source listed in the "Select a Data Source" dialog.
The source code to this sample can be found on GitHub