Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
Update table chart stories
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed Jan 9, 2021
1 parent addec6e commit 4d9faf1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
3 changes: 2 additions & 1 deletion packages/superset-ui-core/src/query/types/PostProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,5 @@ export type PostProcessingRule =
| PostProcessingAggregation
| PostProcessingBoxplot
| PostProcessingContribution
| PostProcessingPivot;
| PostProcessingPivot
| PostProcessingProphet;
Original file line number Diff line number Diff line change
Expand Up @@ -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 || [];
Expand All @@ -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,
};
Expand Down Expand Up @@ -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 <SuperChart chartType="table" {...chartProps} width={width} height={height} />;
};
BigTable.story = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -353,7 +354,7 @@
"gender": "boy",
"name": "<a href=\"http://superset.apache.org\" style=\"color: red;\">Juan</a>",
"sum__num": 149,
"SUM(num_girls)": 0,
"SUM(num_girls)": -5120,
"SUM(num_boys)": 149,
"pct_boys": 149,
"% sum__num": 0.00013234268762240587,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions plugins/plugin-chart-table/src/transformProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import memoizeOne from 'memoize-one';
import {
DataRecord,
QueryFormMetric,
getNumberFormatter,
NumberFormats,
getTimeFormatter,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4d9faf1

Please sign in to comment.