You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/05/15 02:17:02 UTC
(superset) branch feat/glyph-single-file updated: feat(glyph): consolidate plugin-chart-pivot-table to defineChart()
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch feat/glyph-single-file
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/feat/glyph-single-file by this push:
new 816583b6029 feat(glyph): consolidate plugin-chart-pivot-table to defineChart()
816583b6029 is described below
commit 816583b6029a0a850883eba2ecf840ada7cdb124
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Thu May 14 19:16:53 2026 -0700
feat(glyph): consolidate plugin-chart-pivot-table to defineChart()
Move plugin/{buildQuery,controlPanel,transformProps} up to src/ as
siblings and replace the plugin/ entrypoint with a new src/index.tsx
that wraps everything via defineChart(). Thin-shim approach: keeps
the large existing controlPanel.tsx (~490 lines), buildQuery, and
transformProps as their own files and just composes them.
PivotTableChartPlugin is exported as both default and named to match
the prior public API.
Co-Authored-By: Claude Sonnet 4.6 <no...@anthropic.com>
---
.../src/{plugin => }/buildQuery.ts | 2 +-
.../src/{plugin => }/controlPanel.tsx | 2 +-
.../plugins/plugin-chart-pivot-table/src/index.ts | 27 --------
.../plugins/plugin-chart-pivot-table/src/index.tsx | 74 +++++++++++++++++++++
.../plugin-chart-pivot-table/src/plugin/index.ts | 76 ----------------------
.../src/{plugin => }/transformProps.ts | 2 +-
6 files changed, 77 insertions(+), 106 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/buildQuery.ts
similarity index 97%
rename from superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts
rename to superset-frontend/plugins/plugin-chart-pivot-table/src/buildQuery.ts
index dd870799757..da929f27c27 100644
--- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/buildQuery.ts
+++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/buildQuery.ts
@@ -24,7 +24,7 @@ import {
QueryFormColumn,
QueryFormOrderBy,
} from '@superset-ui/core';
-import { PivotTableQueryFormData } from '../types';
+import { PivotTableQueryFormData } from './types';
export default function buildQuery(formData: PivotTableQueryFormData) {
const { groupbyColumns = [], groupbyRows = [], extra_form_data } = formData;
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/controlPanel.tsx
similarity index 99%
rename from superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx
rename to superset-frontend/plugins/plugin-chart-pivot-table/src/controlPanel.tsx
index 4e916857b27..8fd2a11f56d 100644
--- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/controlPanel.tsx
@@ -33,7 +33,7 @@ import {
validateNonEmpty,
QueryFormColumn,
} from '@superset-ui/core';
-import { MetricsLayoutEnum } from '../types';
+import { MetricsLayoutEnum } from './types';
const config: ControlPanelConfig = {
controlPanelSections: [
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/index.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/index.ts
deleted file mode 100644
index 503c655e491..00000000000
--- a/superset-frontend/plugins/plugin-chart-pivot-table/src/index.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-// eslint-disable-next-line import/prefer-default-export
-export { default as PivotTableChartPlugin } from './plugin';
-/**
- * Note: this file exports the default export from PivotTableChart.tsx.
- * If you want to export multiple visualization modules, you will need to
- * either add additional plugin folders (similar in structure to ./plugin)
- * OR export multiple instances of `ChartPlugin` extensions in ./plugin/index.ts
- * which in turn load exports from PivotTableChart.tsx
- */
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/index.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/index.tsx
new file mode 100644
index 00000000000..2539e506ebb
--- /dev/null
+++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/index.tsx
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { t } from '@apache-superset/core/translation';
+import { Behavior, ChartProps, QueryFormData } from '@superset-ui/core';
+import { ControlPanelSectionConfig } from '@superset-ui/chart-controls';
+import { defineChart } from '@superset-ui/glyph-core';
+import buildQuery from './buildQuery';
+import transformProps from './transformProps';
+import controlPanel from './controlPanel';
+import PivotTableChart from './PivotTableChart';
+import thumbnail from './images/thumbnail.png';
+import thumbnailDark from './images/thumbnail-dark.png';
+import example from './images/example.jpg';
+import exampleDark from './images/example-dark.jpg';
+
+export * from './types';
+
+const PivotTableChartPlugin = defineChart<
+ Record<string, never>,
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ Record<string, any>
+>({
+ metadata: {
+ name: t('Pivot Table'),
+ description: t(
+ 'Used to summarize a set of data by grouping together multiple statistics along two axes. Examples: Sales numbers by region and month, tasks by status and assignee, active users by age and location. Not the most visually stunning visualization, but highly informative and versatile.',
+ ),
+ category: t('Table'),
+ behaviors: [
+ Behavior.InteractiveChart,
+ Behavior.DrillToDetail,
+ Behavior.DrillBy,
+ ],
+ tags: [t('Additive'), t('Report'), t('Tabular'), t('Featured')],
+ thumbnail,
+ thumbnailDark,
+ exampleGallery: [{ url: example, urlDark: exampleDark }],
+ },
+ arguments: {},
+ suppressQuerySection: true,
+ prependSections: (controlPanel.controlPanelSections?.filter(
+ (s): s is ControlPanelSectionConfig => s !== null && s !== undefined,
+ ) ?? []) as ControlPanelSectionConfig[],
+ additionalControlOverrides: controlPanel.controlOverrides as Record<
+ string,
+ Record<string, unknown>
+ >,
+ formDataOverrides: controlPanel.formDataOverrides,
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ buildQuery: (formData: any) => buildQuery(formData),
+ transform: chartProps =>
+ transformProps(chartProps as ChartProps<QueryFormData>),
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ render: ({ transformedProps }) => <PivotTableChart {...(transformedProps as any)} />,
+});
+
+export { PivotTableChartPlugin };
+export default PivotTableChartPlugin;
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/index.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/index.ts
deleted file mode 100644
index 4108faa0c59..00000000000
--- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/index.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { t } from '@apache-superset/core/translation';
-import {
- Behavior,
- ChartMetadata,
- ChartPlugin,
- ChartProps,
- QueryFormData,
-} from '@superset-ui/core';
-import buildQuery from './buildQuery';
-import controlPanel from './controlPanel';
-import transformProps from './transformProps';
-import thumbnail from '../images/thumbnail.png';
-import thumbnailDark from '../images/thumbnail-dark.png';
-import example from '../images/example.jpg';
-import exampleDark from '../images/example-dark.jpg';
-import { PivotTableQueryFormData } from '../types';
-
-export default class PivotTableChartPlugin extends ChartPlugin<
- PivotTableQueryFormData,
- ChartProps<QueryFormData>
-> {
- /**
- * The constructor is used to pass relevant metadata and callbacks that get
- * registered in respective registries that are used throughout the library
- * and application. A more thorough description of each property is given in
- * the respective imported file.
- *
- * It is worth noting that `buildQuery` and is optional, and only needed for
- * advanced visualizations that require either post processing operations
- * (pivoting, rolling aggregations, sorting etc) or submitting multiple queries.
- */
- constructor() {
- const metadata = new ChartMetadata({
- behaviors: [
- Behavior.InteractiveChart,
- Behavior.DrillToDetail,
- Behavior.DrillBy,
- ],
- category: t('Table'),
- description: t(
- 'Used to summarize a set of data by grouping together multiple statistics along two axes. Examples: Sales numbers by region and month, tasks by status and assignee, active users by age and location. Not the most visually stunning visualization, but highly informative and versatile.',
- ),
- exampleGallery: [{ url: example, urlDark: exampleDark }],
- name: t('Pivot Table'),
- tags: [t('Additive'), t('Report'), t('Tabular'), t('Featured')],
- thumbnail,
- thumbnailDark,
- });
-
- super({
- buildQuery,
- controlPanel,
- loadChart: () => import('../PivotTableChart'),
- metadata,
- transformProps,
- });
- }
-}
diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts b/superset-frontend/plugins/plugin-chart-pivot-table/src/transformProps.ts
similarity index 99%
rename from superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts
rename to superset-frontend/plugins/plugin-chart-pivot-table/src/transformProps.ts
index 1bba188ca05..d3157e993bd 100644
--- a/superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/transformProps.ts
@@ -28,7 +28,7 @@ import {
} from '@superset-ui/core';
import { GenericDataType } from '@apache-superset/core/common';
import { getColorFormatters } from '@superset-ui/chart-controls';
-import { DateFormatter } from '../types';
+import { DateFormatter } from './types';
const { DATABASE_DATETIME } = TimeFormats;