From f011d3060a6b5ef0882a86937463b9bd704bfd04 Mon Sep 17 00:00:00 2001 From: deecay Date: Fri, 10 Mar 2017 19:10:31 +0900 Subject: [PATCH 1/3] Pivottable shows filtered and formatted data --- client/app/visualizations/pivot/index.js | 19 ++++++++++++++++--- client/app/visualizations/table/index.js | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/app/visualizations/pivot/index.js b/client/app/visualizations/pivot/index.js index ad6aae01..d909e2de 100644 --- a/client/app/visualizations/pivot/index.js +++ b/client/app/visualizations/pivot/index.js @@ -1,9 +1,10 @@ -import angular from 'angular'; import $ from 'jquery'; import 'pivottable'; import 'pivottable/dist/pivot.css'; +import { formatValue } from '../table'; +import { getColumnCleanName } from '../../services/query-result'; -function pivotTableRenderer() { +function pivotTableRenderer(clientConfig, $filter) { return { restrict: 'E', scope: { @@ -21,7 +22,19 @@ function pivotTableRenderer() { if ($scope.queryResult.getData() !== null) { // We need to give the pivot table its own copy of the data, because it changes // it which interferes with other visualizations. - data = angular.copy($scope.queryResult.getRawData()); + data = []; + const columns = $scope.queryResult.getColumns(); + const rows = $scope.queryResult.getData(); + rows.forEach((row) => { + const rowObj = {}; + columns.forEach((col) => { + const colName = getColumnCleanName(col.name); + const value = formatValue($filter, clientConfig, row[col.name], col.type); + rowObj[colName] = value; + }); + data.push(rowObj); + }); + const options = { renderers: $.pivotUtilities.renderers, onRefresh(config) { diff --git a/client/app/visualizations/table/index.js b/client/app/visualizations/table/index.js index eb625ff7..1617577a 100644 --- a/client/app/visualizations/table/index.js +++ b/client/app/visualizations/table/index.js @@ -3,7 +3,7 @@ import { _, partial, isString } from 'underscore'; import { getColumnCleanName } from '../../services/query-result'; import template from './table.html'; -function formatValue($filter, clientConfig, value, type) { +export function formatValue($filter, clientConfig, value, type) { let formattedValue = value; switch (type) { case 'integer': From 10fe3c5373d325449839527946ae5cef63ebff86 Mon Sep 17 00:00:00 2001 From: deecay Date: Thu, 23 Mar 2017 21:07:56 +0900 Subject: [PATCH 2/3] Revert "Pivottable shows filtered and formatted data" This reverts commit f011d3060a6b5ef0882a86937463b9bd704bfd04. --- client/app/visualizations/pivot/index.js | 19 +++---------------- client/app/visualizations/table/index.js | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/client/app/visualizations/pivot/index.js b/client/app/visualizations/pivot/index.js index d909e2de..ad6aae01 100644 --- a/client/app/visualizations/pivot/index.js +++ b/client/app/visualizations/pivot/index.js @@ -1,10 +1,9 @@ +import angular from 'angular'; import $ from 'jquery'; import 'pivottable'; import 'pivottable/dist/pivot.css'; -import { formatValue } from '../table'; -import { getColumnCleanName } from '../../services/query-result'; -function pivotTableRenderer(clientConfig, $filter) { +function pivotTableRenderer() { return { restrict: 'E', scope: { @@ -22,19 +21,7 @@ function pivotTableRenderer(clientConfig, $filter) { if ($scope.queryResult.getData() !== null) { // We need to give the pivot table its own copy of the data, because it changes // it which interferes with other visualizations. - data = []; - const columns = $scope.queryResult.getColumns(); - const rows = $scope.queryResult.getData(); - rows.forEach((row) => { - const rowObj = {}; - columns.forEach((col) => { - const colName = getColumnCleanName(col.name); - const value = formatValue($filter, clientConfig, row[col.name], col.type); - rowObj[colName] = value; - }); - data.push(rowObj); - }); - + data = angular.copy($scope.queryResult.getRawData()); const options = { renderers: $.pivotUtilities.renderers, onRefresh(config) { diff --git a/client/app/visualizations/table/index.js b/client/app/visualizations/table/index.js index 1617577a..eb625ff7 100644 --- a/client/app/visualizations/table/index.js +++ b/client/app/visualizations/table/index.js @@ -3,7 +3,7 @@ import { _, partial, isString } from 'underscore'; import { getColumnCleanName } from '../../services/query-result'; import template from './table.html'; -export function formatValue($filter, clientConfig, value, type) { +function formatValue($filter, clientConfig, value, type) { let formattedValue = value; switch (type) { case 'integer': From 3f047348e2cc3ea55856b9dbd9d62bb15d1c4f5f Mon Sep 17 00:00:00 2001 From: deecay Date: Thu, 23 Mar 2017 21:08:57 +0900 Subject: [PATCH 3/3] Pivottable shows filtered data --- client/app/visualizations/pivot/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/app/visualizations/pivot/index.js b/client/app/visualizations/pivot/index.js index ad6aae01..9c209f94 100644 --- a/client/app/visualizations/pivot/index.js +++ b/client/app/visualizations/pivot/index.js @@ -21,7 +21,7 @@ function pivotTableRenderer() { if ($scope.queryResult.getData() !== null) { // We need to give the pivot table its own copy of the data, because it changes // it which interferes with other visualizations. - data = angular.copy($scope.queryResult.getRawData()); + data = angular.copy($scope.queryResult.getData()); const options = { renderers: $.pivotUtilities.renderers, onRefresh(config) {