Pivot Table: Translation and Empty Data as Columns

Hello,

I have a dynamic extraction system implemented that uses (today) the datatable component as output. That is working well, but we want to improve user experience using pivot table as the output so he can organize, filter and do calculations with the output data.

Important information to begin: since the data retrieved is dynamic (user will choose which information should be available), we don’t know how is the data. Could be {name: '1001', amount: 34.5} as could be {year: 2017, identifier: '22', production: 23.2}.

Questions:

  1. The very first question is if it’s possible to translate the data keys with pivot. For example, if the data is { 'site.name': 'SomeName'} instead of showing ‘site.name’ in the fields list and column header, show ‘Site - Name’.

  2. Sometimes, we retrieve empty data for some records. For example, If I have two entries in my data: {name: 'SomeName', year: 2015, production: 12} and {name: 'DidNotProduced', year: '', production: ''}, and want to see the production per year of all sites, I end up with a undefined column with no data. It is possible to not have that?

Obs: I wanted to do a snippet to show the problem, but I don’t have access to pivot table in the webix snippet.

The very first question is if it’s possible to translate the data keys with pivot

Yes, you can use .fieldMap property
http://docs.webix.com/api__ui.pivot_fieldmap_config.html

Sometimes, we retrieve empty data for some records
There will be an empty label in the above case. There must not be “undefined” values

http://webix.com/snippet/996fb078

I think it can be counted as an array anyway, though
We may update logic of pivot to ignore rows with empty values.

I wanted to do a snippet to show the problem, but I don’t have access to pivot table in the webix snippet.

It is not straight simple, but possible. Please check the above snippet.

Hello @maksim,

Yes, you can use .fieldMap property http://docs.webix.com/api__ui.pivot_fieldmap_config.html

Thanks for the answer. I must have missed this fieldMap option. Good to know it exists.

http://webix.com/snippet/996fb078

Thanks for this snippet. It allowed me write one of my own with the behavior I described in the post: http://webix.com/snippet/32ed2a80

As you can see, If I have a record with missing data (something that is possible in my case, since the data is dynamically constructed) I end up with a undefined column.

It would be possible to get rid of it ?

We will update the logic of the pivot, so it will exclude records with undefined key for columns and rows from calculations. As results there will be no “undefined” keys in rows and columns scales.

Not quite sure about cases when key contains null or empty string value, it can be usefull in some cases and useless in other ones.

If you have a license, the updated Pivot control will be available in next few days through npm/client-area. If you are using a trial - drop us an email and we will send you the updated version when it will be available ( or just send me your email through PM )

Thanks for your replay @maksim.

Glad to hear that, I’ll be looking to the next version of Pivot Table in our client space soon.

Pivot 4.2.6 is available in npm|client-area, it contains a fix for the above issue.