From 4d9faf12ce95bf51a606c123c6333fbacb42b4a5 Mon Sep 17 00:00:00 2001 From: Jesse Yang Date: Sat, 9 Jan 2021 01:04:53 -0800 Subject: [PATCH] Update table chart stories --- .../src/query/types/PostProcessing.ts | 3 ++- .../plugin-chart-table/TableStories.tsx | 26 +++++++++++++++---- .../plugin-chart-table/birthNames.json | 5 ++-- .../plugins/plugin-chart-table/testData.ts | 3 ++- .../plugin-chart-table/src/transformProps.ts | 3 --- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/packages/superset-ui-core/src/query/types/PostProcessing.ts b/packages/superset-ui-core/src/query/types/PostProcessing.ts index 4d614a38e1..c79437d00b 100644 --- a/packages/superset-ui-core/src/query/types/PostProcessing.ts +++ b/packages/superset-ui-core/src/query/types/PostProcessing.ts @@ -114,4 +114,5 @@ export type PostProcessingRule = | PostProcessingAggregation | PostProcessingBoxplot | PostProcessingContribution - | PostProcessingPivot; + | PostProcessingPivot + | PostProcessingProphet; diff --git a/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/TableStories.tsx b/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/TableStories.tsx index e63777f3d0..cfca83577b 100644 --- a/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/TableStories.tsx +++ b/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/TableStories.tsx @@ -38,7 +38,14 @@ const expandColumns = memoizeOne(expandArray); */ function loadData( props: TableChartProps, - { pageLength = 50, rows = 1042, cols = 8, alignPn = false, showCellBars = true }, + { + pageLength = 50, + rows = 1042, + cols = 8, + alignPn = false, + showCellBars = true, + includeSearch = true, + }, ): TableChartProps { if (!props.queriesData || !props.queriesData[0]) return props; const records = props.queriesData?.[0].data || []; @@ -54,9 +61,10 @@ function loadData( ], formData: { ...props.formData, - alignPn, - pageLength, - showCellBars, + align_pn: alignPn, + page_length: pageLength, + show_cell_bars: showCellBars, + include_search: includeSearch, }, height: window.innerHeight - 130, }; @@ -87,9 +95,17 @@ export const BigTable = ({ width, height }) => { const rows = number('Records', 2046, { range: true, min: 0, max: 50000 }); const cols = number('Columns', 8, { range: true, min: 1, max: 20 }); const pageLength = number('Page size', 50, { range: true, min: 0, max: 100 }); + const includeSearch = boolean('Include search', true); const alignPn = boolean('Algin PosNeg', false); const showCellBars = boolean('Show Cell Bars', true); - const chartProps = loadData(birthNames, { pageLength, rows, cols, alignPn, showCellBars }); + const chartProps = loadData(birthNames, { + pageLength, + rows, + cols, + alignPn, + showCellBars, + includeSearch, + }); return ; }; BigTable.story = { diff --git a/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/birthNames.json b/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/birthNames.json index 271bd2dae5..456d8cf1d8 100644 --- a/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/birthNames.json +++ b/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/birthNames.json @@ -213,6 +213,7 @@ "datasource": "3__table", "viz_type": "table", "slice_id": 86, + "include_search": true, "url_params": {}, "granularity_sqla": "ds", "time_grain_sqla": "P0.25Y", @@ -353,7 +354,7 @@ "gender": "boy", "name": "Juan", "sum__num": 149, - "SUM(num_girls)": 0, + "SUM(num_girls)": -5120, "SUM(num_boys)": 149, "pct_boys": 149, "% sum__num": 0.00013234268762240587, @@ -380,7 +381,7 @@ "name": "Morgan", "sum__num": 396, "SUM(num_girls)": 396, - "SUM(num_boys)": 0, + "SUM(num_boys)": -100, "pct_boys": 0, "% sum__num": 0.00035172955905015253, "% SUM(num_girls)": 0.0008255744622299683, diff --git a/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts b/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts index daa7168b66..2c3582ae61 100644 --- a/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts +++ b/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/testData.ts @@ -16,8 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import { TableChartProps } from '@superset-ui/plugin-chart-table'; +import { TableChartProps } from '@superset-ui/plugin-chart-table/src'; // @ts-ignore +// eslint-disable-next-line import/extensions import birthNamesJson from './birthNames.json'; export const birthNames = (birthNamesJson as unknown) as TableChartProps; diff --git a/plugins/plugin-chart-table/src/transformProps.ts b/plugins/plugin-chart-table/src/transformProps.ts index eac94270e2..5f2a544d47 100644 --- a/plugins/plugin-chart-table/src/transformProps.ts +++ b/plugins/plugin-chart-table/src/transformProps.ts @@ -19,7 +19,6 @@ import memoizeOne from 'memoize-one'; import { DataRecord, - QueryFormMetric, getNumberFormatter, NumberFormats, getTimeFormatter, @@ -89,8 +88,6 @@ const processColumns = memoizeOne(function processColumns(props: TableChartProps const percentMetricsSet = new Set(percentMetrics); const rawPercentMetricsSet = new Set(rawPercentMetrics); - console.log(metrics, rawPercentMetrics); - const columns: DataColumnMeta[] = (colnames || []) .filter(key => { // if a metric was only added to percent_metrics, they should not show up in the table.