From 0433df8e423b68e47e2e772d8b4226abe2592d4f Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Thu, 22 Jul 2021 15:57:48 +0200 Subject: [PATCH] feat(plugin-chart-pivot-table): multiple improvements (#1232) * feat(plugin-chart-pivot-table): multiple improvements * emotion syntax fix --- .../plugin-chart-pivot-table/package.json | 2 +- .../src/PivotTableChart.tsx | 15 +++-- .../src/plugin/controlPanel.ts | 58 ++++++++++--------- .../plugin-chart-pivot-table/src/types.ts | 1 + 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-pivot-table/package.json b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-pivot-table/package.json index 64a430a3a8f95..e92c10294288c 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-pivot-table/package.json +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-pivot-table/package.json @@ -28,7 +28,7 @@ "dependencies": { "@superset-ui/chart-controls": "0.17.69", "@superset-ui/core": "0.17.64", - "@superset-ui/react-pivottable": "^0.12.9" + "@superset-ui/react-pivottable": "^0.12.10" }, "peerDependencies": { "@ant-design/icons": "^4.2.2", diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx index bf782628d3e37..91f9ac9ba8392 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx @@ -24,6 +24,7 @@ import { getNumberFormatter, DataRecordValue, NumberFormatter, + useTheme, } from '@superset-ui/core'; // @ts-ignore import PivotTable from '@superset-ui/react-pivottable/PivotTable'; @@ -39,11 +40,12 @@ import { } from './types'; const Styles = styled.div` - padding: ${({ theme }) => theme.gridUnit * 4}px; - height: ${({ height }) => height}px; - width: ${({ width }) => width}px; - overflow-y: scroll; - } + ${({ height, width, margin }) => ` + margin: ${margin}px; + height: ${height - margin * 2}px; + width: ${width - margin * 2}px; + overflow-y: scroll; + `} `; const METRIC_KEY = 'metric'; @@ -122,6 +124,7 @@ export default function PivotTableChart(props: PivotTableProps) { dateFormatters, } = props; + const theme = useTheme(); const defaultFormatter = getNumberFormatter(valueFormat); const columnFormatsArray = Object.entries(columnFormats); const hasCustomMetricFormatters = columnFormatsArray.length > 0; @@ -244,7 +247,7 @@ export default function PivotTableChart(props: PivotTableProps) { ); return ( - + ;