Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e529224
feat(deckgl): scaffold Vector Tiles chart with control panel and laye…
sohil-chhabra Nov 25, 2026
3721afc
"feat(deckgl): render vector tiles with MVTLayer"
sohil-chhabra Nov 25, 2026
1b96a9d
Update comments
sohil-chhabra Nov 25, 2026
e8cb1c2
chore(deckgl): regenerate lockfile and some formatting
sohil-chhabra Nov 25, 2026
170adff
feat(deckgl): show feature properties on hover in Vector Tiles chart
sohil-chhabra Nov 26, 2026
78e882c
feat(deckgl): add tooltip contents and template controls to Vector ti…
sohil-chhabra Nov 26, 2026
9814927
feat(deckgl): flatten tile properties for tooltip templates
sohil-chhabra Nov 26, 2026
0ae9f13
feat(deckgl): store Vector tiles tooltip fields under their own key
sohil-chhabra Nov 26, 2026
f63b663
feat(deckgl): list TileJSON properties in Vector Tiles tooltip picker
sohil-chhabra Nov 26, 2026
345a7b7
feat(deckgl): colour Vector Tile features through a Maplibre expression
sohil-chhabra Nov 27, 2026
d3629bc
feat(deckgl): colour Vector tiles features by a categorical property
sohil-chhabra Nov 27, 2026
2102ce6
feat(deckgl): colour Vector Tiles features by numeric breakpoints
sohil-chhabra Nov 27, 2026
202cfc8
feat(deckgl): add a legend to the Vector Tiles chart
sohil-chhabra Nov 27, 2026
cd49a6e
refactor(deckgl): tidy Vector Tiles comments, labels and legend source
sohil-chhabra Nov 27, 2026
59461ef
test(deckgl): cover Vector Tiles layer settings normalization
sohil-chhabra Nov 27, 2026
0235f26
test(deckgl): cover Vector Tiles query and control panel
sohil-chhabra Nov 27, 2026
06b9279
test(deckgl): cover Vector Tiles layer options and tooltips
sohil-chhabra Nov 27, 2026
80b8504
docs(deckgl): Document the vector tiles and its configuration
sohil-chhabra Nov 27, 2026
f240532
feat(deckgl): add Vector Tiles chart thumbnails.
sohil-chhabra Nov 27, 2026
b0457b6
Merge remote-tracking branch 'upstream/master' into feat/deckgl-vecto…
sohil-chhabra Nov 27, 2026
ca80d22
chore(deckgl): resize Vector Tiles thumbnails to 512x512
sohil-chhabra Nov 27, 2026
f313ed0
feat(deckgl): register deckgl charts in mutliple layers
sohil-chhabra Nov 27, 2026
d01f988
fix(deckgl): address Vector Tiles review findings
sohil-chhabra Nov 27, 2026
26430c4
fix(deckgl): read the Vector Tiles legend from tile data and match ca…
sohil-chhabra Nov 27, 2026
8e357fe
fix(deckgl): load Vector Tiles in Multi tests and refresh the legend …
sohil-chhabra Nov 28, 2026
d05d936
Merge branch 'master' into feat/deckgl-vector-tiles
sohil-chhabra Nov 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion docs/admin_docs/configuration/map-tiles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Setting `DECKGL_BASE_MAP` overwrite default values
After defining your map tiles, set them in these variables:

- `CORS_OPTIONS`
- `connect-src` of `TALISMAN_CONFIG` and `TALISMAN_CONFIG_DEV` variables.
- `connect-src` of `TALISMAN_CONFIG` and `TALISMAN_DEV_CONFIG` variables.

```python
ENABLE_CORS = True
Expand Down Expand Up @@ -109,3 +109,32 @@ TALISMAN_CONFIG = {
...
}
```

## Vector tiles

The deck.gl Vector Tiles chart draws data from a vector tile server, such as
[Martin](https://maplibre.org/martin/), pg_tileserv or GeoServer, instead of from a
Superset query. This is separate from DECKGL_BASE_MAP, which only sets the background map.

To use the chart:

1. Serve Mapbox Vector Tiles (MVT) at a URL containing `{z}`, `{x}` and `{y}`. Optionally,
also serve a TileJSON document, which the chart uses to list the properties in the tiles.
2. Allow cross-origin requests from Superset on the tile server. Martin allows them by default.
3. Add the tile server to `connect-src` in both `TALISMAN_CONFIG` and `TALISMAN_DEV_CONFIG`.
Otherwise, the browser blocks the requests and the chart shows an empty map.

```python
TALISMAN_CONFIG = {
"content_security_policy": {
...
"connect-src": [
"'self'",
"https://api.mapbox.com",
"https://events.mapbox.com",
"https://tiles.example.com",
],
...
},
}
```
10 changes: 10 additions & 0 deletions docs/admin_docs/security/security.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,16 @@ this warning using the `CONTENT_SECURITY_POLICY_WARNING` key in `config.py`.
- Cartodiagram charts request map data (image and json) from external resources that can be edited by users,
and therefore either require a list of allowed domains to request from or a wildcard (`'*'`) for `img-src` and `connect-src`.

- deck.gl Vector Tiles charts load vector tiles and TileJSON directly from the tile server URLs
entered in each chart, which users can edit. Add the allowed tile servers to `connect-src`
(or use a wildcard, with the same trade-off as for Cartodiagram charts):

```
connect-src 'self' https://tiles.example.com
```

See [Map tiles](/admin-docs/configuration/map-tiles#vector-tiles) for the full setup.

- Other CSP directives default to `'self'` to limit content to the same origin as the Superset server.

In order to adjust provided CSP configuration to your needs, follow the instructions and examples provided in
Expand Down
5 changes: 4 additions & 1 deletion superset-frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ export default {
// @deck.gl/maplibre@9.4.0 ships ESM-only (no dist/*.cjs), unlike every
// other @deck.gl/* package - allowed through so babel-jest can convert
// its import/export syntax (see the moduleNameMapper entry above).
'node_modules/(?!@ant-design/(colors|fast-color)|@formatjs/.*|d3-(array|interpolate|color|time|scale|time-format|format|selection|hierarchy)|internmap|@mapbox/tiny-sdf|@deck.gl/maplibre|remark-gfm|(?!@ngrx|(?!deck.gl)|d3-scale)|markdown-table|micromark-*.|decode-named-character-reference|character-entities|mdast-util-*.|unist-util-*.|ccount|escape-string-regexp|nanoid|uuid|@rjsf/*.|@x0k/.*|echarts|zrender|fetch-mock|pretty-ms|parse-ms|ol|@babel/runtime|@emotion|cheerio|cheerio/lib|parse5|dom-serializer|entities|htmlparser2|rehype-sanitize|hast-util-sanitize|unified|react-markdown|vfile|web-namespaces|html-void-elements|html-url-attributes|estree-util-is-identifier-name|trim-lines|is-plain-obj|trough|unist-.*|hast-.*|hastscript|refractor|rehype-.*|remark-.*|mdast-.*|micromark-.*|parse-entities|character-reference-invalid|is-alphanumerical|is-alphabetical|is-decimal|is-hexadecimal|property-information|space-separated-tokens|comma-separated-tokens|bail|devlop|zwitch|longest-streak|geostyler|geostyler-.*|@turf/.*|(?!geostyler)lodash|react-error-boundary|react-json-tree|react-base16-styling|color|color-(convert|string|name)|lodash-es|rbush|quickselect|react-diff-viewer-continued|storybook/*.|json-stringify-pretty-compact|@x0k/json-schema-merge|content-disposition|gettext-parser|react-resize-detector|http-proxy-middleware|httpxy)',
//
// meshoptimizer is ESM-only and reaches the deck.gl plugin through
// @deck.gl/geo-layers -> @loaders.gl/gltf (used by the Vector Tiles chart).
'node_modules/(?!@ant-design/(colors|fast-color)|@formatjs/.*|d3-(array|interpolate|color|time|scale|time-format|format|selection|hierarchy)|internmap|@mapbox/tiny-sdf|@deck.gl/maplibre|meshoptimizer|remark-gfm|(?!@ngrx|(?!deck.gl)|d3-scale)|markdown-table|micromark-*.|decode-named-character-reference|character-entities|mdast-util-*.|unist-util-*.|ccount|escape-string-regexp|nanoid|uuid|@rjsf/*.|@x0k/.*|echarts|zrender|fetch-mock|pretty-ms|parse-ms|ol|@babel/runtime|@emotion|cheerio|cheerio/lib|parse5|dom-serializer|entities|htmlparser2|rehype-sanitize|hast-util-sanitize|unified|react-markdown|vfile|web-namespaces|html-void-elements|html-url-attributes|estree-util-is-identifier-name|trim-lines|is-plain-obj|trough|unist-.*|hast-.*|hastscript|refractor|rehype-.*|remark-.*|mdast-.*|micromark-.*|parse-entities|character-reference-invalid|is-alphanumerical|is-alphabetical|is-decimal|is-hexadecimal|property-information|space-separated-tokens|comma-separated-tokens|bail|devlop|zwitch|longest-streak|geostyler|geostyler-.*|@turf/.*|(?!geostyler)lodash|react-error-boundary|react-json-tree|react-base16-styling|color|color-(convert|string|name)|lodash-es|rbush|quickselect|react-diff-viewer-continued|storybook/*.|json-stringify-pretty-compact|@x0k/json-schema-merge|content-disposition|gettext-parser|react-resize-detector|http-proxy-middleware|httpxy)',
],
transform: {
'^.+\\.(mjs|js|jsx|ts|tsx)$': 'babel-jest',
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions superset-frontend/plugins/preset-chart-deckgl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
"@deck.gl/mapbox": "~9.4.0",
"@deck.gl/maplibre": "~9.4.0",
"@deck.gl/mesh-layers": "~9.4.0",
"@loaders.gl/mvt": "^4.4.3",
"@luma.gl/constants": "~9.4.0",
"@luma.gl/core": "~9.4.0",
"@luma.gl/engine": "~9.4.0",
"@luma.gl/shadertools": "~9.4.0",
"@luma.gl/webgl": "~9.4.0",
"@mapbox/geojson-extent": "^1.0.1",
"@maplibre/maplibre-gl-style-spec": "^26.4.4",
"@math.gl/web-mercator": "^4.1.0",
"@types/d3-array": "^3.2.2",
"@types/geojson": "^7946.0.16",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* 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 { useMemo } from 'react';
import { t } from '@apache-superset/core/translation';
import { Select } from '@superset-ui/core/components';
import { ControlHeader } from '@superset-ui/chart-controls';
import { useTileJsonProperties, isNumericTileType } from './tileJson';

export interface TilePropertyControlProps {
name: string;
label?: string;
description?: string;
value?: string | string[] | null;
multi?: boolean;
onChange: (value: string | string[] | undefined) => void;
tileJsonUrl?: string;
sourceLayer?: string;
/** [column_name, display name] pairs from the dataset, the fallback list. */
datasetChoices: string[][];
numericOnly?: boolean;
}

/**
* Select for tile property names (one or many). Lists TileJSON properties when
* a TileJSON URL loads, otherwise the dataset's columns; numericOnly hides
* non-numeric ones.
*/
export default function TilePropertyControl({
name,
label,
description,
value,
multi = true,
onChange,
tileJsonUrl,
sourceLayer,
datasetChoices,
numericOnly = false,
}: TilePropertyControlProps) {
const { properties, loading, error } = useTileJsonProperties(
tileJsonUrl,
sourceLayer,
);
const useTileJson = Boolean(tileJsonUrl?.trim()) && !error;

const options = useMemo(
() =>
useTileJson
? properties
.filter(
property => !numericOnly || isNumericTileType(property.type),
)
.map(property => ({
value: property.name,
label: property.name,
}))
: datasetChoices.map(([column, displayName]) => ({
value: column,
label: displayName,
})),
[useTileJson, properties, datasetChoices, numericOnly],
);

return (
<Select
ariaLabel={label ?? name}
allowClear
allowNewOptions
loading={loading}
options={options}
mode={multi ? 'multiple' : 'single'}
value={value ?? (multi ? [] : undefined)}
onChange={newValue => onChange(newValue as string | string[] | undefined)}
header={
<ControlHeader
name={name}
label={label}
description={description}
warning={
error
? t(
'Could not load TileJSON: %s. Showing dataset columns instead.',
error,
)
: undefined
}
/>
}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/**
* 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 type { ReactNode } from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import { render } from '@testing-library/react';
import { supersetTheme, ThemeProvider } from '@apache-superset/core/theme';
import { MVTLayer } from '@deck.gl/geo-layers';
import { MVTLoader } from '@loaders.gl/mvt';
import { getLayer } from './VectorTile';
import { VectorTileFormData } from './layerSettings';

// The real package pulls in an ES-module-only dependency Jest cannot load.
// A stand-in that keeps its props is enough to check what getLayer passes.
jest.mock('@deck.gl/geo-layers', () => ({
MVTLayer: class {
props: Record<string, unknown>;

constructor(props: Record<string, unknown>) {
this.props = props;
}
},
}));

// getLayer does not render a map; skip the map libraries it would load.
jest.mock('../../DeckGLContainer', () => ({
DeckGLContainerStyledWrapper: () => null,
}));

const TILE_URL = 'http://localhost:3000/places/{z}/{x}/{y}';

type LayerOptions = Omit<
Parameters<typeof getLayer>[0],
'formData' | 'payload'
>;

/** Builds the layer from minimal form data plus the given fields. */
const layerFor = (
overrides: Partial<VectorTileFormData> = {},
options: Partial<LayerOptions> = {},
) =>
getLayer({
formData: {
datasource: '1__table',
viz_type: 'deck_vector_tile',
slice_id: 7,
tile_url: TILE_URL,
...overrides,
} as VectorTileFormData,
payload: {},
setTooltip: jest.fn(),
...options,
});

/** Hovers a tile feature with the given properties and renders the tooltip. */
const renderTooltip = (
overrides: Partial<VectorTileFormData>,
properties: Record<string, unknown>,
) => {
const setTooltip = jest.fn();
const layer = layerFor(overrides, { setTooltip })!;
layer.props.onHover!(
{
picked: true,
x: 0,
y: 0,
object: { type: 'Feature', properties },
} as never,
{} as never,
);
const { content } = setTooltip.mock.calls[0][0] as { content: ReactNode };
return render(<ThemeProvider theme={supersetTheme}>{content}</ThemeProvider>);
};

test('returns no layer without a valid tile URL', () => {
expect(layerFor({ tile_url: 'http://localhost:3000/places' })).toBeNull();
});

test('loads tiles from the URL within the zoom range', () => {
const layer = layerFor({ min_zoom: 2, max_zoom: 12 })!;
expect(layer).toBeInstanceOf(MVTLayer);
expect(layer.props).toMatchObject({
data: TILE_URL,
minZoom: 2,
maxZoom: 12,
});
});

test('decodes tiles on the main thread, since the CSP blocks the CDN worker', () => {
const { loaders, loadOptions } = layerFor()!.props;
expect(loaders).toEqual([MVTLoader]);
expect(loadOptions).toMatchObject({ core: { worker: false } });
});

test('decodes only the source layer when one is set', () => {
expect(layerFor()!.props.loadOptions.mvt).toBeUndefined();
expect(layerFor({ source_layer: 'places' })!.props.loadOptions.mvt).toEqual({
layers: ['places'],
});
});

test('passes a new tiles array each time the viewport loads', () => {
const onViewportLoad = jest.fn();
const tiles = [{ id: '0-0-0' }];
layerFor({}, { onViewportLoad })!.props.onViewportLoad!(tiles as never);

expect(onViewportLoad).toHaveBeenCalledWith(tiles);
// A copy, so React re-renders the legend even if deck.gl reuses its array.
expect(onViewportLoad.mock.calls[0][0]).not.toBe(tiles);
});

test('sets no viewport callback when none is given', () => {
expect(layerFor()!.props.onViewportLoad).toBeFalsy();
});

test('the default tooltip lists properties but not the loader-added layerName', () => {
const { container } = renderTooltip(
{},
{ name: 'Cafe', layerName: 'places' },
);
expect(container.textContent).toContain('name: Cafe');
expect(container.textContent).not.toContain('layerName');
});

test('the tooltip lists only the chosen properties', () => {
const { container } = renderTooltip(
{ tooltip_properties: ['rating'] },
{ name: 'Cafe', rating: '4.5' },
);
expect(container.textContent).toContain('4.5');
expect(container.textContent).not.toContain('Cafe');
});

test('tooltip templates can use property names directly', async () => {
const { findByText } = renderTooltip(
{ tooltip_template: '<b>{{name}}</b>' },
{ name: 'Cafe' },
);
expect((await findByText('Cafe')).tagName).toBe('B');
});
Loading