Skip to content
soniyashowardhan edited this page Sep 28, 2016 · 22 revisions

Pivot-Chart-API

A plug and play cross tabulation library in JavaScript

Getting Started

  • Include the minified files in your app.
<script type="text/javascript" src="compiled.0.2.0.min.js">
<script type="text/javascript" src="crosstab.0.2.0.min.js">
<link rel="stylesheet" href="compiled.0.2.0.min.css">
<link rel="stylesheet" href="crosstab.0.2.0.min.css">
  • Copy "img" and "font" folders to your app directories and specify the path at "CrossTab.assetsPath". Example
CrossTab.assetsPath = "./lib/"

APIs

CrossTab.init.

CrossTab.init({
	...
})

Initialises the API. The options attributes are:

  • selector: The container to load pivot-chart.
  • monitorEvents: Set 'true' to log the events via APIs.
  • monitorErrors: Set 'true' to log the errors via APIs.
  • mode: choose tracking mode in heap ("development" or "production").
  • trackingIdentifier: User identifier for heap tracking.
  • showSaveButton: Display button to save views/charts.
  • onSaveClick: Callback for the save button.
  • customTabName: Custom tab name for charts.
  • addTabCallback: Callback when new tab is added returns blank div so user can add custom content.
  • customMainTabName: 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: Callback for hiding a specific column. It takes the metadata object and the column name as input. Returns true for columns which are displayed and false for hidden columns.
  • callbackForNewTab: When a tab is added it returns 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.

Sample Object:

options : { 
	selector: "crosstab",
	monitorEvents: true,
	monitorErrors: true,
	mode: "production",
	trackingIdentifier: 
		{ 
		url: data 
		},
	showSaveButton: true,
    onSaveClick: onSaveClick,
    customTabName: "New Tab",
    addTabCallback: afterTabAdded,
    customMainTabName: "My Data Cards",
    mainTabCallback: showAllSavedViewsPage,
    displayColumn: displayColumnOrNot,
    callbackForNewTab: callbackForNewTab,
    switchTabCallback: switchTabCallback,
    onNoDataCallback: onNoDataCallback,
    onNoDataCallbackParams: data_set
}

CrossTab.loadSavedView.

CrossTab.loadSavedView({
   ...
})

Opens a saved chart.

The options attributes are:

  • selector: The container to load pivot-chart.
  • view: Set 'true' to log the events via APIs.
  • monitorErrors: Set 'true' to log the errors via APIs.
  • showSaveButton: Display button to save views/charts.
  • onSaveClick: Callback for save button.
  • customTabName: Custom tab name.
  • addTabCallback: Callback when new tab is added returns blank div so user can add custom content,
  • customMainTabName: 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: Custom tab name.
  • callbackForNewTab: When a tab is added it returns the reference of the new tab which gets added in tab bar.
  • switchTabCallback: Callback for tab switch.

Sample Object:

options: {
	selector: "crosstab", 
	view: saved_view_object, 
	showSaveButton: true,
    onSaveClick: onSaveClick,
    customTabName: "New Tab",
    addTabCallback: afterTabAdded,
	customMainTabName: "My Data Cards",
    mainTabCallback: showAllSavedViewsPage,
    displayColumn: displayColumnOrNot,
    callbackForNewTab: callbackForNewTab,
    switchTabCallback: switchTabCallback,
}

CrossTab.saveActiveTab().
Saves the snapshot of a chart. The view attributes are:

  • title: The title of the tab.
  • view_type: Tab visualization type.
  • scratchpad: Crosstab data config object.
  • pykquery_object: Set 'true' to log the errors via APIs.
result object: {
{ 
	view : {
			"title" : "mainview_1",
			"view_type": "cross_tabulation",
			"scratchpad": "Sample text",
			"pykquery_object": {
				...
				}
			} 
}
Clone this wiki locally