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
commit 1eae7b4ee57224c50741370db97448332da045ca Author: Evan Rusackas <[email protected]> AuthorDate: Thu May 14 18:49:50 2026 -0700 feat(glyph): consolidate deckgl Heatmap layer to defineChart() Collapse multi-file plugin into single index.tsx. Heatmap uses shared buildSpatialQuery/transformSpatialProps, plus intensity/radius_pixels controls and a linear color scheme palette. Heatmap.tsx component stays as sibling for Multi. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --- .../src/layers/Heatmap/buildQuery.ts | 23 --------- .../src/layers/Heatmap/index.ts | 53 -------------------- .../layers/Heatmap/{controlPanel.ts => index.tsx} | 57 ++++++++++++++++------ .../src/layers/Heatmap/transformProps.ts | 24 --------- 4 files changed, 42 insertions(+), 115 deletions(-) diff --git a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/buildQuery.ts b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/buildQuery.ts deleted file mode 100644 index 94607704acf..00000000000 --- a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/buildQuery.ts +++ /dev/null @@ -1,23 +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 { SpatialFormData, buildSpatialQuery } from '../spatialUtils'; - -export default function buildQuery(formData: SpatialFormData) { - return buildSpatialQuery(formData); -} diff --git a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/index.ts b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/index.ts deleted file mode 100644 index 465d9f740f0..00000000000 --- a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/index.ts +++ /dev/null @@ -1,53 +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 { ChartMetadata, ChartPlugin, Behavior } from '@superset-ui/core'; -import thumbnail from './images/thumbnail.png'; -import thumbnailDark from './images/thumbnail-dark.png'; -import example from './images/example.png'; -import exampleDark from './images/example-dark.png'; -import buildQuery from './buildQuery'; -import transformProps from './transformProps'; -import controlPanel from './controlPanel'; - -const metadata = new ChartMetadata({ - category: t('Map'), - credits: ['https://uber.github.io/deck.gl'], - description: t( - 'Uses Gaussian Kernel Density Estimation to visualize spatial distribution of data', - ), - exampleGallery: [{ url: example, urlDark: exampleDark }], - name: t('deck.gl Heatmap'), - thumbnail, - thumbnailDark, - tags: [t('deckGL'), t('Spatial'), t('Comparison')], - behaviors: [Behavior.InteractiveChart], -}); - -export default class HeatmapChartPlugin extends ChartPlugin { - constructor() { - super({ - buildQuery, - loadChart: () => import('./Heatmap'), - controlPanel, - metadata, - transformProps, - }); - } -} diff --git a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/controlPanel.ts b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/index.tsx similarity index 74% rename from superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/controlPanel.ts rename to superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/index.tsx index 9501ade372f..2b7167ec536 100644 --- a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/controlPanel.ts +++ b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/index.tsx @@ -16,16 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -import { - ControlPanelConfig, - formatSelectOptions, -} from '@superset-ui/chart-controls'; import { t } from '@apache-superset/core/translation'; import { - validateNonEmpty, - legacyValidateNumber, + Behavior, legacyValidateInteger, + legacyValidateNumber, + validateNonEmpty, } from '@superset-ui/core'; +import { formatSelectOptions } from '@superset-ui/chart-controls'; +import { defineChart } from '@superset-ui/glyph-core'; +import HeatmapComponent from './Heatmap'; +import { + SpatialFormData, + buildSpatialQuery, + transformSpatialProps, +} from '../spatialUtils'; import { autozoom, deckGLCategoricalColorSchemeTypeSelect, @@ -45,6 +50,10 @@ import { tooltipTemplate, } from '../../utilities/Shared_DeckGL'; import { COLOR_SCHEME_TYPES } from '../../utilities/utils'; +import thumbnail from './images/thumbnail.png'; +import thumbnailDark from './images/thumbnail-dark.png'; +import example from './images/example.png'; +import exampleDark from './images/example-dark.png'; const INTENSITY_OPTIONS = Array.from( { length: 10 }, @@ -55,8 +64,24 @@ const RADIUS_PIXEL_OPTIONS = Array.from( (_, index) => index * 5 + 5, ); -const config: ControlPanelConfig = { - controlPanelSections: [ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export default defineChart<Record<string, never>, any>({ + metadata: { + name: t('deck.gl Heatmap'), + description: t( + 'Uses Gaussian Kernel Density Estimation to visualize spatial distribution of data', + ), + category: t('Map'), + credits: ['https://uber.github.io/deck.gl'], + behaviors: [Behavior.InteractiveChart], + tags: [t('deckGL'), t('Spatial'), t('Comparison')], + thumbnail, + thumbnailDark, + exampleGallery: [{ url: example, urlDark: exampleDark }], + }, + arguments: {}, + suppressQuerySection: true, + prependSections: [ { label: t('Query'), expanded: true, @@ -158,16 +183,18 @@ const config: ControlPanelConfig = { ], }, ], - controlOverrides: { + additionalControlOverrides: { size: { label: t('Weight'), description: t("Metric used as a weight for the grid's coloring"), validators: [validateNonEmpty], }, }, - formDataOverrides: formData => ({ - ...formData, - }), -}; - -export default config; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + buildQuery: (formData: any) => buildSpatialQuery(formData as SpatialFormData), + transform: chartProps => transformSpatialProps(chartProps), + render: ({ transformedProps }) => ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + <HeatmapComponent {...(transformedProps as any)} /> + ), +}); diff --git a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/transformProps.ts b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/transformProps.ts deleted file mode 100644 index 4b8f437d7fc..00000000000 --- a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Heatmap/transformProps.ts +++ /dev/null @@ -1,24 +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 { ChartProps } from '@superset-ui/core'; -import { transformSpatialProps } from '../spatialUtils'; - -export default function transformProps(chartProps: ChartProps) { - return transformSpatialProps(chartProps); -}
