forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into joe/no-playwright
- Loading branch information
Showing
34 changed files
with
1,315 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Contour/Contour.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* 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 { ContourLayer } from 'deck.gl'; | ||
import React from 'react'; | ||
import { t } from '@superset-ui/core'; | ||
import { commonLayerProps } from '../common'; | ||
import sandboxedEval from '../../utils/sandbox'; | ||
import { createDeckGLComponent, getLayerType } from '../../factory'; | ||
import { ColorType } from '../../types'; | ||
import TooltipRow from '../../TooltipRow'; | ||
|
||
function setTooltipContent(o: any) { | ||
return ( | ||
<div className="deckgl-tooltip"> | ||
<TooltipRow | ||
label={t('Centroid (Longitude and Latitude): ')} | ||
value={`(${o?.coordinate[0]}, ${o?.coordinate[1]})`} | ||
/> | ||
<TooltipRow | ||
label={t('Threshold: ')} | ||
value={`${o?.object?.contour?.threshold}`} | ||
/> | ||
</div> | ||
); | ||
} | ||
export const getLayer: getLayerType<unknown> = function ( | ||
formData, | ||
payload, | ||
onAddFilter, | ||
setTooltip, | ||
) { | ||
const fd = formData; | ||
const { | ||
aggregation = 'SUM', | ||
js_data_mutator: jsFnMutator, | ||
contours: rawContours, | ||
cellSize = '200', | ||
} = fd; | ||
let data = payload.data.features; | ||
|
||
const contours = rawContours?.map( | ||
(contour: { | ||
color: ColorType; | ||
lowerThreshold: number; | ||
upperThreshold?: number; | ||
strokeWidth?: number; | ||
}) => { | ||
const { lowerThreshold, upperThreshold, color, strokeWidth } = contour; | ||
if (upperThreshold) { | ||
// Isoband format | ||
return { | ||
threshold: [lowerThreshold, upperThreshold], | ||
color: [color.r, color.g, color.b], | ||
}; | ||
} | ||
// Isoline format | ||
return { | ||
threshold: lowerThreshold, | ||
color: [color.r, color.g, color.b], | ||
strokeWidth, | ||
}; | ||
}, | ||
); | ||
|
||
if (jsFnMutator) { | ||
// Applying user defined data mutator if defined | ||
const jsFnMutatorFunction = sandboxedEval(fd.js_data_mutator); | ||
data = jsFnMutatorFunction(data); | ||
} | ||
|
||
return new ContourLayer({ | ||
id: `contourLayer-${fd.slice_id}`, | ||
data, | ||
contours, | ||
cellSize: Number(cellSize || '200'), | ||
aggregation: aggregation.toUpperCase(), | ||
getPosition: (d: { position: number[]; weight: number }) => d.position, | ||
getWeight: (d: { weight: number }) => d.weight || 0, | ||
...commonLayerProps(fd, setTooltip, setTooltipContent), | ||
}); | ||
}; | ||
|
||
function getPoints(data: any[]) { | ||
return data.map(d => d.position); | ||
} | ||
|
||
export default createDeckGLComponent(getLayer, getPoints); |
133 changes: 133 additions & 0 deletions
133
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Contour/controlPanel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/** | ||
* 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 { | ||
ControlPanelConfig, | ||
getStandardizedControls, | ||
sections, | ||
} from '@superset-ui/chart-controls'; | ||
import { t, validateNonEmpty } from '@superset-ui/core'; | ||
import { | ||
autozoom, | ||
filterNulls, | ||
jsColumns, | ||
jsDataMutator, | ||
jsOnclickHref, | ||
jsTooltip, | ||
mapboxStyle, | ||
spatial, | ||
viewport, | ||
} from '../../utilities/Shared_DeckGL'; | ||
|
||
const config: ControlPanelConfig = { | ||
controlPanelSections: [ | ||
sections.legacyRegularTime, | ||
{ | ||
label: t('Query'), | ||
expanded: true, | ||
controlSetRows: [ | ||
[spatial], | ||
['row_limit'], | ||
['size'], | ||
[filterNulls], | ||
['adhoc_filters'], | ||
], | ||
}, | ||
{ | ||
label: t('Map'), | ||
expanded: true, | ||
controlSetRows: [ | ||
[mapboxStyle, viewport], | ||
[autozoom], | ||
[ | ||
{ | ||
name: 'cellSize', | ||
config: { | ||
type: 'TextControl', | ||
label: t('Cell Size'), | ||
default: 300, | ||
isInt: true, | ||
description: t('The size of each cell in meters'), | ||
renderTrigger: true, | ||
clearable: false, | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
name: 'aggregation', | ||
config: { | ||
type: 'SelectControl', | ||
label: t('Aggregation'), | ||
description: t( | ||
'The function to use when aggregating points into groups', | ||
), | ||
default: 'sum', | ||
clearable: false, | ||
renderTrigger: true, | ||
choices: [ | ||
['sum', t('sum')], | ||
['min', t('min')], | ||
['max', t('max')], | ||
['mean', t('mean')], | ||
], | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
name: 'contours', | ||
config: { | ||
type: 'ContourControl', | ||
label: t('Contours'), | ||
renderTrigger: true, | ||
description: t( | ||
'Define contour layers. Isolines represent a collection of line segments that ' + | ||
'serparate the area above and below a given threshold. Isobands represent a ' + | ||
'collection of polygons that fill the are containing values in a given ' + | ||
'threshold range.', | ||
), | ||
}, | ||
}, | ||
], | ||
], | ||
}, | ||
{ | ||
label: t('Advanced'), | ||
controlSetRows: [ | ||
[jsColumns], | ||
[jsDataMutator], | ||
[jsTooltip], | ||
[jsOnclickHref], | ||
], | ||
}, | ||
], | ||
controlOverrides: { | ||
size: { | ||
label: t('Weight'), | ||
description: t("Metric used as a weight for the grid's coloring"), | ||
validators: [validateNonEmpty], | ||
}, | ||
}, | ||
formDataOverrides: formData => ({ | ||
...formData, | ||
size: getStandardizedControls().shiftMetric(), | ||
}), | ||
}; | ||
|
||
export default config; |
Binary file added
BIN
+63.4 KB
...tend/plugins/legacy-preset-chart-deckgl/src/layers/Contour/images/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
...plugins/legacy-preset-chart-deckgl/src/layers/Contour/images/thumbnailLarge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions
45
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Contour/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* 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, ChartMetadata, ChartPlugin } from '@superset-ui/core'; | ||
import transformProps from '../../transformProps'; | ||
import controlPanel from './controlPanel'; | ||
import thumbnail from './images/thumbnail.png'; | ||
|
||
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', | ||
), | ||
name: t('deck.gl Countour'), | ||
thumbnail, | ||
useLegacyApi: true, | ||
tags: [t('deckGL'), t('Spatial'), t('Comparison'), t('Experimental')], | ||
}); | ||
|
||
export default class ContourChartPlugin extends ChartPlugin { | ||
constructor() { | ||
super({ | ||
loadChart: () => import('./Contour'), | ||
controlPanel, | ||
metadata, | ||
transformProps, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.