Skip to content

Commit

Permalink
feat: add deckgl files
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 30, 2021
1 parent 3b7cec5 commit ad74e60
Show file tree
Hide file tree
Showing 53 changed files with 2,665 additions and 144 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@superset-ui/plugins-monorepo",
"name": "@superset-ui/plugins-deckgl-monorepo",
"version": "0.0.0-master",
"description": "Superset UI Plugins",
"description": "Superset UI Plugins - deck.gl",
"private": true,
"scripts": {
"build": "yarn build:cjs && yarn build:esm && yarn run type:dts && yarn build:assets",
Expand All @@ -24,7 +24,7 @@
"test": "yarn run type && yarn run jest",
"test:watch": "yarn run lint:fix && beemo create-config jest --react && jest --watch"
},
"repository": "https://github.com/apache-superset/superset-ui-plugins.git",
"repository": "https://github.com/apache-superset/superset-ui-plugins-deckgl.git",
"keywords": [
"apache",
"superset",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## @superset-ui/legacy-preset-chart-nvd3

[![Version](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-nvd3.svg?style=flat-square)](https://img.shields.io/npm/v/@superset-ui/legacy-preset-chart-nvd3.svg?style=flat-square)
[![David (path)](https://img.shields.io/david/apache-superset/superset-ui-plugins.svg?path=packages%2Fsuperset-ui-legacy-preset-chart-nvd3&style=flat-square)](https://david-dm.org/apache-superset/superset-ui-plugins?path=packages/superset-ui-legacy-preset-chart-nvd3)

This plugin provides Big Number for Superset.

### Usage

Import the preset and register. This will register all the chart plugins under nvd3.

```js
import { NVD3ChartPreset } from '@superset-ui/legacy-preset-chart-nvd3';

new NVD3ChartPreset().register();
```

or register charts one by one. Configure `key`, which can be any `string`, and register the plugin. This `key` will be used to lookup this chart throughout the app.

```js
import { AreaChartPlugin, LineChartPlugin } from '@superset-ui/legacy-preset-chart-nvd3';

new AreaChartPlugin()
.configure({ key: 'area' })
.register();
new LineChartPlugin()
.configure({ key: 'line' })
.register();
```

Then use it via `SuperChart`. See [storybook](https://apache-superset.github.io/superset-ui-plugins/?selectedKind=plugin-chart-nvd3) for more details.

```js
<SuperChart
chartType="line"
width={600}
height={600}
formData={...}
queryData={{
data: {...},
}}
/>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@superset-ui/legacy-preset-chart-deckgl",
"version": "0.11.0",
"description": "Superset Legacy Chart - deck.gl",
"sideEffects": [
"*.css"
],
"main": "lib/index.js",
"module": "esm/index.js",
"files": [
"esm",
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/apache-superset/superset-ui-plugins-deckgl.git"
},
"keywords": [
"superset"
],
"author": "Superset",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/apache-superset/superset-ui-plugins-deckgl/issues"
},
"homepage": "https://github.com/apache-superset/superset-ui-plugins-deckgl#readme",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@data-ui/xy-chart": "^0.0.80",
"d3": "^3.5.17",
"d3-tip": "^0.9.1",
"dompurify": "^1.0.3",
"fast-safe-stringify": "^2.0.6",
"lodash": "^4.17.11",
"mathjs": "^3.20.2",
"moment": "^2.20.1",
"nvd3": "1.8.6",
"prop-types": "^15.6.2",
"urijs": "^1.18.10"
},
"peerDependencies": {
"@superset-ui/chart": "^0.12.0",
"@superset-ui/color": "^0.12.0",
"@superset-ui/core": "^0.12.0",
"@superset-ui/dimension": "^0.12.0",
"@superset-ui/number-format": "^0.12.0",
"@superset-ui/time-format": "^0.12.0",
"@superset-ui/translation": "^0.12.0",
"react": "^15 || ^16"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* 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 React from 'react';
import PropTypes from 'prop-types';

import DeckGLContainer from './DeckGLContainer';
import PlaySlider from '../PlaySlider';

const PLAYSLIDER_HEIGHT = 20; // px

const propTypes = {
getLayers: PropTypes.func.isRequired,
start: PropTypes.number.isRequired,
end: PropTypes.number.isRequired,
getStep: PropTypes.func,
values: PropTypes.array.isRequired,
aggregation: PropTypes.bool,
disabled: PropTypes.bool,
viewport: PropTypes.object.isRequired,
children: PropTypes.node,
mapStyle: PropTypes.string,
mapboxApiAccessToken: PropTypes.string.isRequired,
setControlValue: PropTypes.func,
onViewportChange: PropTypes.func,
onValuesChange: PropTypes.func,
};

const defaultProps = {
aggregation: false,
disabled: false,
mapStyle: 'light',
setControlValue: () => {},
onViewportChange: () => {},
onValuesChange: () => {},
};

export default class AnimatableDeckGLContainer extends React.Component {
constructor(props) {
super(props);
this.onViewportChange = this.onViewportChange.bind(this);
}
onViewportChange(viewport) {
const originalViewport = this.props.disabled
? { ...viewport }
: { ...viewport, height: viewport.height + PLAYSLIDER_HEIGHT };
this.props.onViewportChange(originalViewport);
}
render() {
const {
start,
end,
getStep,
disabled,
aggregation,
children,
getLayers,
values,
onValuesChange,
viewport,
setControlValue,
mapStyle,
mapboxApiAccessToken,
} = this.props;
const layers = getLayers(values);

// leave space for the play slider
const modifiedViewport = {
...viewport,
height: disabled ? viewport.height : viewport.height - PLAYSLIDER_HEIGHT,
};

return (
<div>
<DeckGLContainer
viewport={modifiedViewport}
layers={layers}
setControlValue={setControlValue}
mapStyle={mapStyle}
mapboxApiAccessToken={mapboxApiAccessToken}
onViewportChange={this.onViewportChange}
/>
{!disabled &&
<PlaySlider
start={start}
end={end}
step={getStep(start)}
values={values}
range={!aggregation}
onChange={onValuesChange}
/>
}
{children}
</div>
);
}
}

AnimatableDeckGLContainer.propTypes = propTypes;
AnimatableDeckGLContainer.defaultProps = defaultProps;

0 comments on commit ad74e60

Please sign in to comment.