Skip to content
soniyashowardhan edited this page Aug 31, 2016 · 22 revisions

Pivot-Chart-API

A plug and play cross tabulation library in JavaScript

Getting Started

  • Include the minified files in your app.
  • Copy "img" and "font" folders to your app directories and specify the path at "CrossTab.assetsPath".

APIs

  • CrossTab.assetsPath : Specifies the path to the "img" and "fonts" folders.
  • CrossTab.init(options)
  • CrossTab.loadSavedView(options)
  • CrossTab.saveActiveTab()

CrossTab.init(options).
Initialises the API.
options : {
  selector: The <div> to load pivot-chart,
  monitorEvents: true,
  monitorErrors: true,
  mode: "development" / "production",
  trackingIdentifier: //user identifier for heap tracking,
  if using from inside an App
    {
      fromApp: true,
      tableName: table_name,
      connectionParams: connection_params,
      meta_data: JSON.parse(data_set.formatted_columns)
    }
  if using directly as standlone lib
    {
      url: data
    }
  showSaveButton: true //to show save button,
  onSaveClick: //callback for save button,
  customTabName: "New Tab" // custom tab name,
  addTabCallback: //callback when new tab is added returns blank div so user can add custom content,
  customMainTabName: "My Data Cards" // custom main tab name,
  mainTabCallback: //callback when main tab is clicked, returns a blank div if it is not present and return the div so user can add custom content
  displayColumn: displayColumnOrNot,
  callbackForNewTab: // when a tab is added it return the reference of the new tab which gets added in tab bar,
  switchTabCallback: //callback for tab switch,
  onNoDataCallback: //callback when no data is present in dataset,
  onNoDataCallbackParams: //parameters for above callback
 }

CrossTab.loadSavedView(options).
Opens a saved chart.
options: {
  selector: //mandatory,
  view: //saved view object,
  showSaveButton: //same as init,
  onSaveClick: //same as init,
  customTabName: //same as init,
  addTabCallback: //same as init,
  customMainTabName: //same as init,
  mainTabCallback: //same as init,
  displayColumn: //same as init,
  callbackForNewTab: //same as init,
  switchTabCallback: //same as init
  }

CrossTab.saveActiveTab().
Saves the snapshot of a chart.

result object: {
  {
   view : {
     "title" : //tab title,
     "view_type": //tab viz type,
     "scratchpad": //scratchpad content,
     "pykquery_object": //crosstab data config object
     }
  }

Clone this wiki locally