connectTo(dataSource: DataSourceObject)
[starting from version: 1.4]
Use this method to connect to a new data source at runtime. It clears the current report and connects to the specified data source. To update the data without clearing the report, use the updateData API call.
The DataSourceObject which contains connection parameters.
1) This example on JSFiddle demonstrates the connection to the following data sources: Microsoft Analysis Services, Elasticsearch, CSV, and JSON.
2) Connect to Microsoft Analysis Services:
pivot.connectTo({
type: 'microsoft analysis services',
proxyUrl: 'https://olap.flexmonster.com/olap/msmdpump.dll',
dataSourceInfo: 'Provider=MSOLAP; Data Source=extranet;',
catalog: 'Adventure Works DW Standard Edition',
cube: 'Adventure Works'
});
3) Connect to Elasticsearch:
pivot.connectTo({
type: 'elasticsearch',
node: 'https://olap.flexmonster.com:9200',
index: 'fm-product-sales'
});
4) Connect to CSV data source:
pivot.connectTo({
type: 'csv',
filename: 'data/csv/arabic.csv'
});
5) Connect to CSV file where colon char is used to separate fields in the row. You have to define fieldSeparator
explicitly:
pivot.connectTo({
type: 'csv',
filename: 'colon-data.csv',
fieldSeparator: ':'
});
6) Open local CSV file:
pivot.connectTo({
type: 'csv',
browseForFile: true
});