Need a special offer?Find out if your project fits.
+
All documentation
API reference
  • API Reference for older versions
  • connectTo

    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.

    Parameters

    The DataSourceObject which contains connection parameters.

    Examples

    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:

    flexmonster.connectTo({
      type: 'microsoft analysis services',
      proxyUrl: 'http://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:

    flexmonster.connectTo({
     type: 'elasticsearch',
    node: 'https://olap.flexmonster.com:9200',
    index: 'fm-product-sales'
    });

    4) Connect to CSV data source:

    flexmonster.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:

    flexmonster.connectTo({
      type: 'csv',
      filename: 'colon-data.csv',
      fieldSeparator: ':'
    });

    6) Open local CSV file:

    flexmonster.connectTo({
      type: 'csv', 
      browseForFile: true
    });

    See also

    updateData
    open
    load
    save
    getReport
    setReport