-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
466dda2
commit 6a774e4
Showing
72 changed files
with
8,441 additions
and
174 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
71 changes: 71 additions & 0 deletions
71
superset-frontend/plugins/plugin-chart-cartodiagram/README.md
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,71 @@ | ||
<!-- | ||
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. | ||
--> | ||
|
||
## @superset-ui/plugin-chart-cartodiagram | ||
|
||
This plugin allows visualizing charts on a map. To do so, the plugin makes use of existing charts and renders them on the | ||
provided locations. | ||
|
||
Configuring the charts: Charts will be configured in their respective editors. So all configuration options of any chart are supported. | ||
|
||
Configuring the map: For the map, an arbitrary number of background layers (WMS, WFS, XYZ), the initial map extent, the chart background color and border radius, as well as the chart size (per zoom level) can be configured. | ||
|
||
### Usage | ||
|
||
The plugin is configured in `superset-frontend/src/visualizations/presets/MainPreset.js`. | ||
|
||
```js | ||
import { | ||
CartodiagramPlugin, | ||
} from '@superset-ui/plugin-chart-cartodiagram'; | ||
|
||
new CartodiagramPlugin().configure({ key: 'cartodiagram' }).register(); | ||
``` | ||
|
||
Default layers can be added to the constructor. These layers will be added to each chart by default (but can be removed by editors). See also `./src/types.ts` for the definitions of types `WmsLayerConf`, `WfsLayerConf` and `XyzLayerConf`. | ||
|
||
Example for an XYZ default layer: | ||
|
||
```js | ||
import { | ||
CartodiagramPlugin, | ||
} from '@superset-ui/plugin-chart-cartodiagram'; | ||
|
||
const opts = { | ||
defaultLayers: [ | ||
{ | ||
type: 'XYZ', | ||
url: 'example.com/path/to/xyz/layer', | ||
title: 'my default layer title', | ||
attribution: 'my default layer attribution', | ||
}, | ||
], | ||
}; | ||
|
||
new CartodiagramPlugin(opts).configure({ key: 'cartodiagram' }).register(); | ||
``` | ||
|
||
Please note that by default, Superset rejects requests to third-party domains. If you want to include | ||
layers from those, you have to adjust the CSP settings. See also docs/docs/security/security.mdx. | ||
|
||
### Geometry Column | ||
|
||
The plugin requires the selection of a geometry column for a dataset. | ||
This is expected to be a GeoJSON-Point-Geometry string in WGS 84/Pseudo-Mercator (EPSG:3857). Other formats and projections | ||
will be supported in the future. |
51 changes: 51 additions & 0 deletions
51
superset-frontend/plugins/plugin-chart-cartodiagram/package.json
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,51 @@ | ||
{ | ||
"name": "@superset-ui/plugin-chart-cartodiagram", | ||
"version": "0.0.1", | ||
"description": "An OpenLayers map that displays charts for single features.", | ||
"sideEffects": false, | ||
"main": "lib/index.js", | ||
"module": "esm/index.js", | ||
"files": [ | ||
"esm", | ||
"lib" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/apache-superset/superset-ui.git" | ||
}, | ||
"keywords": [ | ||
"superset" | ||
], | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/apache-superset/superset-ui/issues" | ||
}, | ||
"homepage": "https://github.com/apache-superset/superset-ui#readme", | ||
"contributors": [ | ||
"terrestris GmbH & Co. KG <[email protected]> (https://www.terrestris.de)", | ||
"meggsimum - Büro für Geoinformatik <[email protected]> (https://meggsimum.de)" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@types/geojson": "^7946.0.10", | ||
"geojson": "^0.5.0", | ||
"lodash": "^4.17.21", | ||
"ol": "^7.1.0" | ||
}, | ||
"peerDependencies": { | ||
"@ant-design/icons": "^5.0.1", | ||
"@superset-ui/chart-controls": "*", | ||
"@superset-ui/core": "*", | ||
"antd": "^4.10.3", | ||
"geostyler": "^12.0.0", | ||
"geostyler-data": "^1.0.0", | ||
"geostyler-openlayers-parser": "^4.0.0", | ||
"geostyler-style": "^7.2.0", | ||
"geostyler-wfs-parser": "^2.0.0", | ||
"polished": "*", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.0" | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
superset-frontend/plugins/plugin-chart-cartodiagram/src/CartodiagramPlugin.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,59 @@ | ||
/** | ||
* 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 { createRef, useState } from 'react'; | ||
import { styled, useTheme } from '@superset-ui/core'; | ||
import OlMap from 'ol/Map'; | ||
import { | ||
CartodiagramPluginProps, | ||
CartodiagramPluginStylesProps, | ||
} from './types'; | ||
|
||
import OlChartMap from './components/OlChartMap'; | ||
|
||
import 'ol/ol.css'; | ||
|
||
// The following Styles component is a <div> element, which has been styled using Emotion | ||
// For docs, visit https://emotion.sh/docs/styled | ||
|
||
// Theming variables are provided for your use via a ThemeProvider | ||
// imported from @superset-ui/core. For variables available, please visit | ||
// https://github.com/apache-superset/superset-ui/blob/master/packages/superset-ui-core/src/style/index.ts | ||
|
||
const Styles = styled.div<CartodiagramPluginStylesProps>` | ||
height: ${({ height }) => height}px; | ||
width: ${({ width }) => width}px; | ||
`; | ||
|
||
export default function CartodiagramPlugin(props: CartodiagramPluginProps) { | ||
const { height, width } = props; | ||
const theme = useTheme(); | ||
|
||
const rootElem = createRef<HTMLDivElement>(); | ||
|
||
const [mapId] = useState( | ||
`cartodiagram-plugin-${Math.floor(Math.random() * 1000)}`, | ||
); | ||
const [olMap] = useState(new OlMap({})); | ||
|
||
return ( | ||
<Styles ref={rootElem} height={height} width={width} theme={theme}> | ||
<OlChartMap mapId={mapId} olMap={olMap} {...props} /> | ||
</Styles> | ||
); | ||
} |
Oops, something went wrong.