diff --git a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/buildQuery.ts b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/buildQuery.ts deleted file mode 100644 index 294a0f997bf..00000000000 --- a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/buildQuery.ts +++ /dev/null @@ -1,34 +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 interface DeckContourFormData extends SpatialFormData { - cellSize?: string; - aggregation?: string; - contours?: Array<{ - color: { r: number; g: number; b: number }; - lowerThreshold: number; - upperThreshold?: number; - strokeWidth?: number; - }>; -} - -export default function buildQuery(formData: DeckContourFormData) { - return buildSpatialQuery(formData); -} diff --git a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/index.ts b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/index.ts deleted file mode 100644 index 5fa660e8d04..00000000000 --- a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/index.ts +++ /dev/null @@ -1,55 +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 Contour'), - thumbnail, - thumbnailDark, - tags: [t('deckGL'), t('Spatial'), t('Comparison')], - behaviors: [Behavior.InteractiveChart], -}); - -export default class ContourChartPlugin extends ChartPlugin { - constructor() { - super({ - buildQuery, - loadChart: () => import('./Contour'), - controlPanel, - metadata, - transformProps, - }); - } -} - -export { getSafeCellSize } from './getSafeCellSize'; diff --git a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/controlPanel.ts b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/index.tsx similarity index 60% rename from superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/controlPanel.ts rename to superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/index.tsx index dc394a32e05..59e0d6164b7 100644 --- a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/controlPanel.ts +++ b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/index.tsx @@ -16,12 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -import { - ControlPanelConfig, - getStandardizedControls, -} from '@superset-ui/chart-controls'; import { t } from '@apache-superset/core/translation'; -import { validateNonEmpty } from '@superset-ui/core'; +import { Behavior, validateNonEmpty } from '@superset-ui/core'; +import { getStandardizedControls } from '@superset-ui/chart-controls'; +import { defineChart } from '@superset-ui/glyph-core'; +import ContourComponent from './Contour'; +import { + SpatialFormData, + buildSpatialQuery, + transformSpatialProps, +} from '../spatialUtils'; import { autozoom, filterNulls, @@ -37,9 +41,46 @@ import { tooltipContents, tooltipTemplate, } from '../../utilities/Shared_DeckGL'; +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 config: ControlPanelConfig = { - controlPanelSections: [ +export { getSafeCellSize } from './getSafeCellSize'; + +// ─── Types ─────────────────────────────────────────────────────────────────── + +export interface DeckContourFormData extends SpatialFormData { + cellSize?: string; + aggregation?: string; + contours?: Array<{ + color: { r: number; g: number; b: number }; + lowerThreshold: number; + upperThreshold?: number; + strokeWidth?: number; + }>; +} + +// ─── Plugin definition ─────────────────────────────────────────────────────── + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export default defineChart, any>({ + metadata: { + name: t('deck.gl Contour'), + 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, @@ -124,7 +165,7 @@ const config: ControlPanelConfig = { ], }, ], - controlOverrides: { + additionalControlOverrides: { size: { label: t('Weight'), description: t("Metric used as a weight for the grid's coloring"), @@ -135,6 +176,12 @@ const config: ControlPanelConfig = { ...formData, size: getStandardizedControls().shiftMetric(), }), -}; - -export default config; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + buildQuery: (formData: any) => + buildSpatialQuery(formData as DeckContourFormData), + transform: chartProps => transformSpatialProps(chartProps), + render: ({ transformedProps }) => ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + + ), +}); diff --git a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/transformProps.ts b/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/transformProps.ts deleted file mode 100644 index 1ca8144242c..00000000000 --- a/superset-frontend/plugins/preset-chart-deckgl/src/layers/Contour/transformProps.ts +++ /dev/null @@ -1,21 +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 { transformSpatialProps } from '../spatialUtils'; - -export default transformSpatialProps;