Skip to content

Frequently Asked Questions

Nicolas Kruchten edited this page Jun 23, 2016 · 85 revisions

Some issues/questions come up more than once and I'll try to pull together some boilerplate answers here.

Related Issues: #456, #451, #446

Question: Why can't I call pivot() with the same parameters as pivotUI() and vice versa?

Current answer: These two functions do different things and so take different parameters.

  • pivotUI() takes aggregators/renderers objects and aggregatorName/rendererName keys, because it must display a list of aggregators and renderers in its UI, while pre-loading with a specific aggregator and renderer.
  • pivot() on the other hand takes a pair of aggregator/renderer functions in order to generate its output. (pivot() also takes an aggregatorName parameter but this is used only as a label in certain renderers.)

Related Issues: #30, #73

Question: How can I use multiple aggregators? For example, showing a table which has sum(x) and avg(x) or sum(x) and sum(y)?

Current answer: PivotTable.js currently supports only one Aggregator in the drag'n'drop UI and in the built-in Renderer. I'm not sure how to gracefully support the creation of multiple Aggregators in the UI at the moment, nor am I clear on how Renderers like the Google Chart Renderers would support multiple Aggregators. If you need this feature you could implement your own custom Aggregator which displays multiple values, or your own custom Renderer using the built-in Table Renderer as a starting point (like the person who shared their work in issue #30) but if you need UI support you may need to modify the UI code.

Accessing/saving PivotTable State

Related Issues: saved search

Question: How can I access the user-selected options and/or state of the PivotTable?

Current answer: you can pass in a parameter to pivotUI() called onRefresh which is a function which will be called with the current configuration every time the user changes anything in the UI. If you call pivotUI() with this configuration and the same input, it will restore this state. This can be used to store the configuration in a cookie, or save/reload state etc. You can see an example of this in action here.

Server-side integration

Related Issues: #150

Question: Can I integrate PivotTable.js with an OLAP Server? Can some of the computation be done server-side?

Current answer: PivotTable.js is designed to be a browser-side component, and requires all the data that it is to operate on to be supplied up front in the browser: no AJAX-style interactions once loaded. In that sense, you can integrate this library with any server which is able to provide data in a compatible format, but there is no 'deep' integration beyond the original data load. That said, some people in #150 seem to have gotten somewhere with different server-side models.

Input Data Size

Related Issues: #36, #90, #203

Question: How big can the input data be?

Current answer: the best answer so far is "try it and see", as the performance of the system will depend on the machine/browser being used, the exact nature of the aggregators etc. It's proven difficult to give rules of thumb for estimating what will work well beyond 100,000 records, but certainly up to that point results seem satisfactory for most applications.

Related Issues: #500, #445, #382, #255

Question: Can I hide the totals in the built-in table renderer?

Current answer: Yes, with the following CSS.

.pvtTotal, .pvtTotalLabel, .pvtGrandTotal {display: none}

Related Issues: #476, #477, #286

Question: Can I paginate the results in the built-in table renderer?

Current answer: This is not a supported feature of any built-in renderer. If you need this you will need to write your own renderer or apply a jQuery transformation to the output of the built-in ones using another library.

Sorting in built-in Table Renderer

Related Issues: #48, #44

Question: How can I sort the table by cell value or using my own sorting function in the built-in Table Renderer?

Current answer: PivotTable.js today sorts column and row headers using an overrideable 'natural sort' so it will sort letters and numbers intuitively.

Sorting by cell-values is not currently possible with the built-in Table Renderer. It's very hard to implement due to colspans and rowspans when you have more than one attribute in the cols or rows position. If you need this feature you should implement your own custom Renderer using the built-in Table Renderer as a starting point. There's also a third-party wrapper available here: http://www.nrecosite.com/pivot_table_aspnet.aspx

Drilldown in built-in Table Renderer

Related Issues: #33, #45, #55

Question: How can I get 'drilldown' functionality in the built-in Table Renderer so that when I click or double-click on a cell, the relevant records are somehow made visible?

Current answer: Some pivot table implementations allow you to 'drill down' or 'drill through' a given table cell to get more information about the records that that cell is summarizing. This isn't currently possible with the built-in Table Renderer but I'm studying the problem to come up with an elegant solution. . iIf you need this feature you should implement your own custom Renderer using the built-in Table Renderer as a starting point. There's also a third-party wrapper available here: http://www.nrecosite.com/pivot_table_aspnet.aspx

(Optionally Collapsable) Subtotals in built-in Table Renderer

Related Issues: #25, #26

Question: How can I display subtotals in the built-in Table Renderer?

Current answer: The built-in Table Renderer doesn't support subtotals. If you need this feature you should implement your own custom Renderer using the built-in Table Renderer as a starting point.

Related Issues: #496, #449, #433, #338

Question: How can I get a different colour scale than the default white-to-red?

Current answer: You can use the rendererOptions.heatmap.colourScaleGenerator parameter to specify a custom colour scale. See the Montreal Weather example.

Exporting Renderer output to Excel or Images

Related Issues: #58, #187, #112, #204

Question: How can I export the output of the built-in Table Renderer to Excel? How can I export the output of the Google Charts Renderer to PNGs?

Current answer: I think that this feature is a bit out of scope for this library, given the variety of possible Renderers. There is, however, an optional export_renderers file, which will generate TSV output similar to the Table Renderer, which can be copy-pasted to Excel (see example). If the export_renderers add-on doesn't meet your needs, you could add extra code to your page to extract the information you want from the DOM and export to whatever target you are wanting, or you could implement your own renderer which includes an export function.

Supporting Charting library X (ChartJS, HighCharts etc)

Related Issues: #200, #193, #160

Question: PivotTable.js ships with supported Google Charts and D3/C3 renderers, but there are many other visualization systems out there. How can I use/are there plans to support my favourite visualization system?

Current answer: It is not a stated goal of this project to support every visualization library, but rather to structure the input for such libraries, so if you really want to use a specific visualization system, your best bet is to use the Google Chart or D3/C3 renderers as a starting point to creating your own.

I chose Google Charts initially because it was the only library available at that time that supported line/bar/stacked charts with basically identical input formats and provided decent tooltip and legend support. I added C3 support because that library met the above requirements, while being self-hostable (you don't need to request the javascript from Google).

Pie Charts in the chart renderers

Related Issues: #66, #188

Question: Why aren't Pie Charts included in the chart renderers?

Current answer: Pie Charts give wrong/misleading output in Google Charts if activated naively (see my reply to this PR) so they are not included.

In order for Pie Charts to be first class citizens in PivotTable.js, we would have to be able to display multiple pie charts at once (sharing legends!), based on what the user put in the 'columns' section of the UI, but neither Google Charts nor C3 easily make it possible to do this at the moment.