Skip to content

Commit

Permalink
Merge pull request apache#3 from terrestris/rename-plugin
Browse files Browse the repository at this point in the history
Rename plugin
  • Loading branch information
jansule authored Jan 5, 2023
2 parents 0acb66f + 8a28d5b commit d352063
Show file tree
Hide file tree
Showing 51 changed files with 100 additions and 60 deletions.
86 changes: 61 additions & 25 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: 1 addition & 1 deletion superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@superset-ui/legacy-preset-chart-nvd3": "file:./plugins/legacy-preset-chart-nvd3",
"@superset-ui/plugin-chart-echarts": "file:./plugins/plugin-chart-echarts",
"@superset-ui/plugin-chart-handlebars": "file:./plugins/plugin-chart-handlebars",
"@superset-ui/plugin-chart-ol": "file:./plugins/plugin-chart-ol",
"@superset-ui/plugin-chart-cartodiagram": "file:./plugins/plugin-chart-cartodiagram",
"@superset-ui/plugin-chart-pivot-table": "file:./plugins/plugin-chart-pivot-table",
"@superset-ui/plugin-chart-table": "file:./plugins/plugin-chart-table",
"@superset-ui/plugin-chart-word-cloud": "file:./plugins/plugin-chart-word-cloud",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# superset-ol-plugin
# plugin-chart-cartodiagram

An OpenLayers map that displays charts for single features. Superset Chart Plugin.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@superset-ui/plugin-chart-ol",
"name": "@superset-ui/plugin-chart-cartodiagram",
"version": "0.0.1",
"description": "An OpenLayers map that displays charts for single features.",
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import React, { createRef, useState } from 'react';
import { styled } from '@superset-ui/core';
import OlMap from 'ol/Map';
import { SupersetOlPluginProps, SupersetOlPluginStylesProps } from './types';
import {
CartodiagramPluginProps,
CartodiagramPluginStylesProps,
} from './types';

import OlChartMap from './components/OlChartMap';

Expand All @@ -32,17 +35,19 @@ import 'ol/ol.css';
// 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<SupersetOlPluginStylesProps>`
const Styles = styled.div<CartodiagramPluginStylesProps>`
height: ${({ height }) => height}px;
width: ${({ width }) => width}px;
`;

export default function SupersetOlPlugin(props: SupersetOlPluginProps) {
export default function CartodiagramPlugin(props: CartodiagramPluginProps) {
const { height, width } = props;

const rootElem = createRef<HTMLDivElement>();

const [mapId] = useState(`ol-plugin-${Math.floor(Math.random() * 1000)}`);
const [mapId] = useState(
`cartodiagram-plugin-${Math.floor(Math.random() * 1000)}`,
);
const [olMap] = useState(new OlMap({}));

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/
// eslint-disable-next-line import/prefer-default-export
export { default as SupersetOlPlugin } from './plugin';
export { default as CartodiagramPlugin } from './plugin';
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const config: ControlPanelConfig = {
},
{ col: 'viz_type', opr: 'neq', value: 'tree_chart' },
{ col: 'viz_type', opr: 'neq', value: 'handlebars' },
{ col: 'viz_type', opr: 'neq', value: 'ext-openlayers' },
{ col: 'viz_type', opr: 'neq', value: 'cartodiagram' },
{ col: 'viz_type', opr: 'neq', value: 'filter_groupby' },
{ col: 'viz_type', opr: 'neq', value: 'deck_arc' },
{ col: 'viz_type', opr: 'neq', value: 'deck_geojson' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import buildQuery from './buildQuery';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import thumbnail from '../images/thumbnail.png';
import { SupersetOlPluginConstructorOpts } from '../types';
import { CartodiagramPluginConstructorOpts } from '../types';
import { getLayerConfig } from '../util/controlPanelUtil';

export default class SupersetOlPlugin extends ChartPlugin {
export default class CartodiagramPlugin extends ChartPlugin {
/**
* The constructor is used to pass relevant metadata and callbacks that get
* registered in respective registries that are used throughout the library
Expand All @@ -35,11 +35,10 @@ export default class SupersetOlPlugin extends ChartPlugin {
* advanced visualizations that require either post processing operations
* (pivoting, rolling aggregations, sorting etc) or submitting multiple queries.
*/
constructor(opts: SupersetOlPluginConstructorOpts) {
constructor(opts: CartodiagramPluginConstructorOpts) {
const metadata = new ChartMetadata({
description:
'An OpenLayers map that displays charts for single features.',
name: t('OpenLayers'),
description: 'Display multiple charts on an OpenLayers map.',
name: t('Cartodiagram'),
thumbnail,
tags: [t('ECharts'), t('Popular'), t('Geo'), t('2D')],
category: t('Map'),
Expand All @@ -61,7 +60,7 @@ export default class SupersetOlPlugin extends ChartPlugin {
super({
buildQuery,
controlPanel,
loadChart: () => import('../SupersetOlPlugin'),
loadChart: () => import('../CartodiagramPlugin'),
metadata,
transformProps,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function transformProps(chartProps: ChartProps) {
*
* The transformProps function is also quite useful to return
* additional/modified props to your data viz component. The formData
* can also be accessed from your SupersetOlPlugin.tsx file, but
* can also be accessed from your CartodiagramPlugin.tsx file, but
* doing supplying custom props here is often handy for integrating third
* party libraries that rely on specific props.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { DataNode, TreeProps } from 'antd/lib/tree';
import { Map } from 'ol';
import { Feature, FeatureCollection, Point } from 'geojson';

export interface SupersetOlPluginStylesProps {
export interface CartodiagramPluginStylesProps {
height: number;
width: number;
}
Expand Down Expand Up @@ -63,7 +63,7 @@ export type ChartConfig = FeatureCollection<
ChartConfigFeature['properties']
>;

interface SupersetOlPluginCustomizeProps {
interface CartodiagramPluginCustomizeProps {
headerText: string;
geomColumn: string;
selectedChart: string;
Expand All @@ -83,16 +83,16 @@ interface SupersetOlPluginCustomizeProps {
setControlValue: Function;
}

export type SupersetOlPluginQueryFormData = QueryFormData &
SupersetOlPluginStylesProps &
SupersetOlPluginCustomizeProps;
export type CartodiagramPluginQueryFormData = QueryFormData &
CartodiagramPluginStylesProps &
CartodiagramPluginCustomizeProps;

export type SupersetOlPluginProps = SupersetOlPluginStylesProps &
SupersetOlPluginCustomizeProps & {
export type CartodiagramPluginProps = CartodiagramPluginStylesProps &
CartodiagramPluginCustomizeProps & {
data: TimeseriesDataRecord[];
};

export interface OlChartMapProps extends SupersetOlPluginProps {
export interface OlChartMapProps extends CartodiagramPluginProps {
mapId: string;
olMap: Map;
}
Expand Down Expand Up @@ -332,6 +332,6 @@ export interface MapViewPopoverContentProps {
mapViewConf: MapViewConfigs;
}

export type SupersetOlPluginConstructorOpts = {
export type CartodiagramPluginConstructorOpts = {
defaultLayers?: LayerConf[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SupersetOlPlugin } from '../src';
import { CartodiagramPlugin } from '../src';

/**
* The example tests in this file act as a starting point, and
Expand All @@ -26,8 +26,8 @@ import { SupersetOlPlugin } from '../src';
* treated correctly (e.g. formData from plugin controls
* properly transform the data and/or any resulting props).
*/
describe('superset-ol-plugin', () => {
describe('CartodiagramPlugin', () => {
it('exists', () => {
expect(SupersetOlPlugin).toBeDefined();
expect(CartodiagramPlugin).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import buildQuery from '../../src/plugin/buildQuery';

describe('SupersetOlPlugin buildQuery', () => {
describe('CartodiagramPlugin buildQuery', () => {
const formData = {
datasource: '5__table',
granularity_sqla: 'ds',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// import { ChartProps } from '@superset-ui/core';
// import transformProps from '../../src/plugin/transformProps';

describe('SupersetOlPlugin transformProps', () => {
describe('CartodiagramPlugin transformProps', () => {
// const formData = {
// colorScheme: 'bnbColors',
// datasource: '3__table',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"path": "../../../packages/superset-ui-core"
},
{
"path": "../plugin-chart-echarts"
"path": "../../plugin-chart-echarts"
},
]
}
6 changes: 3 additions & 3 deletions superset-frontend/src/visualizations/presets/MainPreset.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
TimePivotChartPlugin,
} from '@superset-ui/legacy-preset-chart-nvd3';
import { DeckGLChartPreset } from '@superset-ui/legacy-preset-chart-deckgl';
import { CartodiagramPlugin } from '@superset-ui/plugin-chart-cartodiagram';
import {
BigNumberChartPlugin,
BigNumberTotalChartPlugin,
Expand All @@ -69,7 +70,6 @@ import {
EchartsMixedTimeseriesChartPlugin,
EchartsTreeChartPlugin,
} from '@superset-ui/plugin-chart-echarts';
import { SupersetOlPlugin } from '@superset-ui/plugin-chart-ol';
import {
SelectFilterPlugin,
RangeFilterPlugin,
Expand Down Expand Up @@ -167,7 +167,7 @@ export default class MainPreset extends Preset {
new TimeGrainFilterPlugin().configure({ key: 'filter_timegrain' }),
new EchartsTreeChartPlugin().configure({ key: 'tree_chart' }),
new HandlebarsChartPlugin().configure({ key: 'handlebars' }),
new SupersetOlPlugin({
new CartodiagramPlugin({
defaultLayers: [
{
// TODO use other default layer here
Expand All @@ -178,7 +178,7 @@ export default class MainPreset extends Preset {
'<a href="https://www.imis.bfs.de/geoportal/resources/sitepolicy.html" target="_blank">© Bundesamt für Strahlenschutz</a>&nbsp;&nbsp;&#x007C;&nbsp;&nbsp;<a href="https://www.openstreetmap.org/copyright/en" target="_blank">OpenStreetMap</a>&nbsp;&nbsp;&#x007C;&nbsp;&nbsp;<a href="http://www.geodatenzentrum.de/geodaten/gdz?l=down_opendata" target="_blank">BKG</a>',
},
],
}).configure({ key: 'ext-openlayers' }),
}).configure({ key: 'cartodiagram' }),
...experimentalplugins,
],
});
Expand Down

0 comments on commit d352063

Please sign in to comment.