This is an automated email from the ASF dual-hosted git repository. kristw pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push: new 731c19b refactor: use deck.gl plugins from npm package (#8258) 731c19b is described below commit 731c19b6305ea865bff9ec469e0f77195da5258f Author: Krist Wongsuphasawat <krist.wo...@gmail.com> AuthorDate: Thu Sep 19 16:55:44 2019 -0700 refactor: use deck.gl plugins from npm package (#8258) * refactor: use deck.gl plugins from npm package * fix: remove test files --- superset/assets/package-lock.json | 41 ++- superset/assets/package.json | 13 +- .../visualizations/deckgl/layers/common_spec.jsx | 110 -------- .../visualizations/deckgl/utils_spec.js | 131 ---------- superset/assets/src/visualizations/Legend.css | 44 ---- superset/assets/src/visualizations/Legend.jsx | 105 -------- superset/assets/src/visualizations/PlaySlider.css | 46 ---- superset/assets/src/visualizations/PlaySlider.jsx | 170 ------------ .../deckgl/AnimatableDeckGLContainer.jsx | 115 -------- .../deckgl/CategoricalDeckGLContainer.jsx | 248 ------------------ .../src/visualizations/deckgl/DeckGLContainer.jsx | 115 -------- .../src/visualizations/deckgl/Multi/Multi.jsx | 131 ---------- .../deckgl/Multi/MultiChartPlugin.js | 39 --- .../deckgl/Multi/images/thumbnail.png | Bin 106790 -> 0 bytes .../deckgl/Multi/images/thumbnailLarge.png | Bin 991412 -> 0 bytes .../src/visualizations/deckgl/TooltipRow.jsx | 36 --- .../assets/src/visualizations/deckgl/factory.jsx | 134 ---------- .../src/visualizations/deckgl/layers/Arc/Arc.jsx | 61 ----- .../deckgl/layers/Arc/ArcChartPlugin.js | 39 --- .../deckgl/layers/Arc/images/thumbnail.png | Bin 38815 -> 0 bytes .../deckgl/layers/Arc/images/thumbnailLarge.png | Bin 230107 -> 0 bytes .../deckgl/layers/Geojson/Geojson.jsx | 171 ------------ .../deckgl/layers/Geojson/GeojsonChartPlugin.js | 39 --- .../deckgl/layers/Geojson/images/thumbnail.png | Bin 42386 -> 0 bytes .../layers/Geojson/images/thumbnailLarge.png | Bin 181512 -> 0 bytes .../src/visualizations/deckgl/layers/Grid/Grid.jsx | 71 ----- .../deckgl/layers/Grid/GridChartPlugin.js | 39 --- .../deckgl/layers/Grid/images/thumbnail.png | Bin 143670 -> 0 bytes .../deckgl/layers/Grid/images/thumbnailLarge.png | Bin 2125810 -> 0 bytes .../src/visualizations/deckgl/layers/Hex/Hex.jsx | 70 ----- .../deckgl/layers/Hex/HexChartPlugin.js | 39 --- .../deckgl/layers/Hex/images/thumbnail.png | Bin 85015 -> 0 bytes .../deckgl/layers/Hex/images/thumbnailLarge.png | Bin 1090997 -> 0 bytes .../src/visualizations/deckgl/layers/Path/Path.jsx | 72 ------ .../deckgl/layers/Path/PathChartPlugin.js | 39 --- .../deckgl/layers/Path/images/thumbnail.png | Bin 75705 -> 0 bytes .../deckgl/layers/Path/images/thumbnailLarge.png | Bin 523094 -> 0 bytes .../deckgl/layers/Polygon/Polygon.jsx | 288 --------------------- .../deckgl/layers/Polygon/PolygonChartPlugin.js | 39 --- .../deckgl/layers/Polygon/images/thumbnail.png | Bin 37261 -> 0 bytes .../layers/Polygon/images/thumbnailLarge.png | Bin 443630 -> 0 bytes .../deckgl/layers/Scatter/Scatter.jsx | 71 ----- .../deckgl/layers/Scatter/ScatterChartPlugin.js | 39 --- .../deckgl/layers/Scatter/images/thumbnail.png | Bin 120091 -> 0 bytes .../layers/Scatter/images/thumbnailLarge.png | Bin 795739 -> 0 bytes .../deckgl/layers/Screengrid/Screengrid.jsx | 202 --------------- .../layers/Screengrid/ScreengridChartPlugin.js | 39 --- .../deckgl/layers/Screengrid/images/thumbnail.png | Bin 76990 -> 0 bytes .../layers/Screengrid/images/thumbnailLarge.png | Bin 591701 -> 0 bytes .../src/visualizations/deckgl/layers/common.jsx | 155 ----------- .../src/visualizations/deckgl/layers/index.js | 40 --- .../src/visualizations/deckgl/transformProps.js | 43 --- superset/assets/src/visualizations/deckgl/utils.js | 122 --------- .../visualizations/presets/DeckGLChartPreset.js | 47 ---- .../src/visualizations/presets/MainPreset.js | 3 +- .../src/visualizations/stylesheets/deckgl.css | 22 -- 56 files changed, 38 insertions(+), 3190 deletions(-) diff --git a/superset/assets/package-lock.json b/superset/assets/package-lock.json index 8fc440a..f42cf33 100644 --- a/superset/assets/package-lock.json +++ b/superset/assets/package-lock.json @@ -3499,9 +3499,9 @@ } }, "@superset-ui/chart": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/@superset-ui/chart/-/chart-0.12.1.tgz", - "integrity": "sha512-fRrG44+ZP7VS4LE5bvtlvra2GVKD1/vF0II+IDd6qW8zq6fa25cmCT4hurxt7XnLeM546DyAQRPsEaPs+0oxOg==", + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/@superset-ui/chart/-/chart-0.12.3.tgz", + "integrity": "sha512-2GHzzOvcJHHj2y+IFAKEVNRiS60Eaf+BL74gJQY+mw7QCZpDLy6eL/azgAzV446h+TEikx9D0THvfyGLTCCEsw==", "requires": { "@types/react": "^16.7.17", "@types/react-loadable": "^5.4.2", @@ -3575,9 +3575,9 @@ } }, "@superset-ui/connection": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@superset-ui/connection/-/connection-0.12.0.tgz", - "integrity": "sha512-Qjaj7B6AzSE6HzjJF1Kor/zCMUa4KpNODQ/UzlqdoeiQhN+y7bKzYqyayYzSL0vbC7X9yaWys5aWy6v4DBHeLA==", + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/@superset-ui/connection/-/connection-0.12.3.tgz", + "integrity": "sha512-McIOI3u41MUvLZKeiPbVGXV1IXs5UfAWpbjQ8dfkXaNW03dTFlsDdF52UKap72opsamOm9ppb6RVh0rYhkQcfQ==", "requires": { "@babel/runtime": "^7.1.2", "whatwg-fetch": "^3.0.0" @@ -3592,9 +3592,9 @@ } }, "@superset-ui/dimension": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@superset-ui/dimension/-/dimension-0.12.0.tgz", - "integrity": "sha512-6HbXU7VFbKzNjEu3XbFPXqQO1MSJzNqG4kGqnMVk8NWQ/f0ptO4F0ITKWfW84BAUXEnDDHDBI8WYNDwLL+mdkw==" + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/@superset-ui/dimension/-/dimension-0.12.3.tgz", + "integrity": "sha512-9Eq+62IYjWv1qoio8fLgynjYacf/411Ehdqx70nhrQaBxabD9yablJHtIok0vTYo3QQUHJ2f93igE8z0PCCPEA==" }, "@superset-ui/legacy-plugin-chart-calendar": { "version": "0.11.0", @@ -3926,6 +3926,29 @@ "shortid": "^2.2.14" } }, + "@superset-ui/legacy-preset-chart-deckgl": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@superset-ui/legacy-preset-chart-deckgl/-/legacy-preset-chart-deckgl-0.1.0.tgz", + "integrity": "sha512-TnbYyGdRErkm5vvrcA2WrLGjQxIWsi+KVgarCrbSD+1bkdu6G6X8gRr6x6E59r6FsQiTLE/uO5bQiwKJW619lg==", + "requires": { + "bootstrap-slider": "^10.0.0", + "d3-array": "^1.2.4", + "d3-color": "^1.2.0", + "d3-scale": "^2.1.2", + "deck.gl": "^5.3.5", + "jquery": "^3.4.1", + "lodash": "^4.17.15", + "mapbox-gl": "^0.53.0", + "moment": "^2.20.1", + "mousetrap": "^1.6.1", + "prop-types": "^15.6.0", + "react-bootstrap-slider": "2.1.5", + "react-map-gl": "^4.0.10", + "underscore": "^1.8.3", + "urijs": "^1.18.10", + "viewport-mercator-project": "^6.1.1" + } + }, "@superset-ui/legacy-preset-chart-nvd3": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@superset-ui/legacy-preset-chart-nvd3/-/legacy-preset-chart-nvd3-0.11.0.tgz", diff --git a/superset/assets/package.json b/superset/assets/package.json index 2407c26..2787cc7 100644 --- a/superset/assets/package.json +++ b/superset/assets/package.json @@ -47,12 +47,12 @@ "homepage": "https://superset.apache.org/", "dependencies": { "@data-ui/sparkline": "^0.0.54", - "@superset-ui/chart": "^0.12.1", + "@superset-ui/chart": "^0.12.3", "@superset-ui/chart-composition": "^0.12.1", "@superset-ui/color": "^0.12.1", - "@superset-ui/connection": "^0.12.0", + "@superset-ui/connection": "^0.12.3", "@superset-ui/core": "^0.12.0", - "@superset-ui/dimension": "^0.12.0", + "@superset-ui/dimension": "^0.12.3", "@superset-ui/legacy-plugin-chart-calendar": "^0.11.0", "@superset-ui/legacy-plugin-chart-chord": "^0.11.0", "@superset-ui/legacy-plugin-chart-country-map": "^0.11.0", @@ -76,6 +76,7 @@ "@superset-ui/legacy-plugin-chart-word-cloud": "^0.11.0", "@superset-ui/legacy-plugin-chart-world-map": "^0.11.0", "@superset-ui/legacy-preset-chart-big-number": "^0.11.0", + "@superset-ui/legacy-preset-chart-deckgl": "^0.1.0", "@superset-ui/legacy-preset-chart-nvd3": "^0.11.0", "@superset-ui/number-format": "^0.12.1", "@superset-ui/query": "^0.12.2", @@ -96,7 +97,6 @@ "d3-array": "^1.2.4", "d3-color": "^1.2.0", "d3-scale": "^2.1.2", - "deck.gl": "^5.3.5", "dnd-core": "^2.6.0", "dompurify": "^1.0.3", "geolib": "^2.0.24", @@ -104,7 +104,6 @@ "jquery": "^3.4.1", "json-bigint": "^0.3.0", "lodash": "^4.17.15", - "mapbox-gl": "^0.53.0", "mathjs": "^3.20.2", "moment": "^2.20.1", "mousetrap": "^1.6.1", @@ -126,7 +125,6 @@ "react-hot-loader": "^4.3.6", "react-json-tree": "^0.11.2", "react-jsonschema-form": "^1.2.0", - "react-map-gl": "^4.0.10", "react-markdown": "^3.3.0", "react-redux": "^5.0.2", "react-search-input": "^0.11.3", @@ -147,8 +145,7 @@ "regenerator-runtime": "^0.13.3", "shortid": "^2.2.6", "underscore": "^1.8.3", - "urijs": "^1.18.10", - "viewport-mercator-project": "^6.1.1" + "urijs": "^1.18.10" }, "devDependencies": { "@babel/cli": "^7.5.5", diff --git a/superset/assets/spec/javascripts/visualizations/deckgl/layers/common_spec.jsx b/superset/assets/spec/javascripts/visualizations/deckgl/layers/common_spec.jsx deleted file mode 100644 index c82eeee..0000000 --- a/superset/assets/spec/javascripts/visualizations/deckgl/layers/common_spec.jsx +++ /dev/null @@ -1,110 +0,0 @@ -/** - * 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 { max } from 'd3-array'; -import { getAggFunc, getBounds } from '../../../../../src/visualizations/deckgl/layers/common'; - -describe('deckgl layers common', () => { - it('getAggFunc', () => { - const arr = [10, 0.5, 55, 128, -10]; - expect(getAggFunc('max')(arr)).toEqual(128); - expect(getAggFunc('min')(arr)).toEqual(-10); - expect(getAggFunc('count')(arr)).toEqual(5); - expect(getAggFunc('median')(arr)).toEqual(10); - expect(getAggFunc('mean')(arr)).toEqual(36.7); - expect(getAggFunc('p1')(arr)).toEqual(-9.58); - expect(getAggFunc('p5')(arr)).toEqual(-7.9); - expect(getAggFunc('p95')(arr)).toEqual(113.39999999999998); - expect(getAggFunc('p99')(arr)).toEqual(125.08); - }); - it('getAggFunc with accessor', () => { - const arr = [{ foo: 1 }, { foo: 2 }, { foo: 3 }]; - const accessor = o => o.foo; - expect(getAggFunc('count')(arr, accessor)).toEqual(3); - expect(max(arr, accessor)).toEqual(3); - expect(getAggFunc('max', accessor)(arr)).toEqual(3); - expect(getAggFunc('min', accessor)(arr)).toEqual(1); - expect(getAggFunc('median', accessor)(arr)).toEqual(2); - expect(getAggFunc('mean', accessor)(arr)).toEqual(2); - expect(getAggFunc('p1', accessor)(arr)).toEqual(1.02); - expect(getAggFunc('p5', accessor)(arr)).toEqual(1.1); - expect(getAggFunc('p95', accessor)(arr)).toEqual(2.9); - expect(getAggFunc('p99', accessor)(arr)).toEqual(2.98); - }); - - describe('getBounds', () => { - it('should return valid bounds for multiple points', () => { - const points = [ - [0, 20], - [5, 25], - [10, 15], - ]; - expect(getBounds(points)).toEqual([ - [0, 15], - [10, 25], - ]); - }); - it('should return valid bounds for single latitude point', () => { - const points = [ - [0, 0], - [5, 0], - ]; - expect(getBounds(points)).toEqual([ - [0, -0.25], - [5, 0.25], - ]); - }); - it('should return valid bounds for single longitude point', () => { - const points = [ - [0, 0], - [0, 5], - ]; - expect(getBounds(points)).toEqual([ - [-0.25, 0], - [0.25, 5], - ]); - }); - it('should return valid bounds for single point', () => { - const points = [ - [0, 0], - ]; - expect(getBounds(points)).toEqual([ - [-0.25, -0.25], - [0.25, 0.25], - ]); - }); - it('should return valid bounds for point 90, 180', () => { - const points = [ - [180, 90], - ]; - expect(getBounds(points)).toEqual([ - [179.75, 89.75], - [180, 90], - ]); - }); - it('should return valid bounds for point -90, -180', () => { - const points = [ - [-180, -90], - ]; - expect(getBounds(points)).toEqual([ - [-180, -90], - [-179.75, -89.75], - ]); - }); - }); -}); diff --git a/superset/assets/spec/javascripts/visualizations/deckgl/utils_spec.js b/superset/assets/spec/javascripts/visualizations/deckgl/utils_spec.js deleted file mode 100644 index bd256a4..0000000 --- a/superset/assets/spec/javascripts/visualizations/deckgl/utils_spec.js +++ /dev/null @@ -1,131 +0,0 @@ -/** - * 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 { - getBreakPoints, - getBreakPointColorScaler, - getBuckets, -} from '../../../../src/visualizations/deckgl/utils'; - -const metricAccessor = d => d.count; - -describe('getBreakPoints', () => { - it('is a function', () => { - expect(typeof getBreakPoints).toBe('function'); - }); - - it('returns sorted break points', () => { - const fd = { break_points: ['0', '10', '100', '50', '1000'] }; - const result = getBreakPoints(fd, [], metricAccessor); - const expected = ['0', '10', '50', '100', '1000']; - expect(result).toEqual(expected); - }); - - it('returns evenly distributed break points when no break points are specified', () => { - const fd = { metric: 'count' }; - const features = [0, 1, 2, 10].map(count => ({ count })); - const result = getBreakPoints(fd, features, metricAccessor); - const expected = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; - expect(result).toEqual(expected); - }); - - it('formats number with proper precision', () => { - const fd = { metric: 'count', num_buckets: 2 }; - const features = [0, 1 / 3, 2 / 3, 1].map(count => ({ count })); - const result = getBreakPoints(fd, features, metricAccessor); - const expected = ['0.0', '0.5', '1.0']; - expect(result).toEqual(expected); - }); - - it('works with a zero range', () => { - const fd = { metric: 'count', num_buckets: 1 }; - const features = [1, 1, 1].map(count => ({ count })); - const result = getBreakPoints(fd, features, metricAccessor); - const expected = ['1', '1']; - expect(result).toEqual(expected); - }); -}); - -describe('getBreakPointColorScaler', () => { - it('is a function', () => { - expect(typeof getBreakPointColorScaler).toBe('function'); - }); - - it('returns linear color scaler if there are no break points', () => { - const fd = { - metric: 'count', - linear_color_scheme: ['#000000', '#ffffff'], - opacity: 100, - }; - const features = [10, 20, 30].map(count => ({ count })); - const scaler = getBreakPointColorScaler(fd, features, metricAccessor); - expect(scaler({ count: 10 })).toEqual([0, 0, 0, 255]); - expect(scaler({ count: 15 })).toEqual([64, 64, 64, 255]); - expect(scaler({ count: 30 })).toEqual([255, 255, 255, 255]); - }); - - it('returns bucketing scaler if there are break points', () => { - const fd = { - metric: 'count', - linear_color_scheme: ['#000000', '#ffffff'], - break_points: ['0', '1', '10'], - opacity: 100, - }; - const features = []; - const scaler = getBreakPointColorScaler(fd, features, metricAccessor); - expect(scaler({ count: 0 })).toEqual([0, 0, 0, 255]); - expect(scaler({ count: 0.5 })).toEqual([0, 0, 0, 255]); - expect(scaler({ count: 1 })).toEqual([255, 255, 255, 255]); - expect(scaler({ count: 5 })).toEqual([255, 255, 255, 255]); - }); - - it('mask values outside the break points', () => { - const fd = { - metric: 'count', - linear_color_scheme: ['#000000', '#ffffff'], - break_points: ['0', '1', '10'], - opacity: 100, - }; - const features = []; - const scaler = getBreakPointColorScaler(fd, features, metricAccessor); - expect(scaler({ count: -1 })).toEqual([0, 0, 0, 0]); - expect(scaler({ count: 11 })).toEqual([255, 255, 255, 0]); - }); -}); - -describe('getBuckets', () => { - it('is a function', () => { - expect(typeof getBuckets).toBe('function'); - }); - - it('computes buckets for break points', () => { - const fd = { - metric: 'count', - linear_color_scheme: ['#000000', '#ffffff'], - break_points: ['0', '1', '10'], - opacity: 100, - }; - const features = []; - const result = getBuckets(fd, features, metricAccessor); - const expected = { - '0 - 1': { color: [0, 0, 0, 255], enabled: true }, - '1 - 10': { color: [255, 255, 255, 255], enabled: true }, - }; - expect(result).toEqual(expected); - }); -}); diff --git a/superset/assets/src/visualizations/Legend.css b/superset/assets/src/visualizations/Legend.css deleted file mode 100644 index 6b6345c..0000000 --- a/superset/assets/src/visualizations/Legend.css +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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. - */ -div.legend { - font-size: 90%; - position: absolute; - background: #fff; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.15); - margin: 24px; - padding: 12px 20px; - outline: none; - overflow-y: scroll; - max-height: 200px; -} - -ul.categories { - list-style: none; - padding-left: 0; - margin: 0; -} - -ul.categories li a { - color: rgb(51, 51, 51); - text-decoration: none; -} - -ul.categories li a span { - margin-right: 10px; -} diff --git a/superset/assets/src/visualizations/Legend.jsx b/superset/assets/src/visualizations/Legend.jsx deleted file mode 100644 index 355f632..0000000 --- a/superset/assets/src/visualizations/Legend.jsx +++ /dev/null @@ -1,105 +0,0 @@ -/** - * 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 { formatNumber } from '@superset-ui/number-format'; - -import './Legend.css'; - -const categoryDelimiter = ' - '; - -const propTypes = { - categories: PropTypes.object, - toggleCategory: PropTypes.func, - showSingleCategory: PropTypes.func, - format: PropTypes.string, - position: PropTypes.oneOf([null, 'tl', 'tr', 'bl', 'br']), -}; - -const defaultProps = { - categories: {}, - toggleCategory: () => {}, - showSingleCategory: () => {}, - format: null, - position: 'tr', -}; - -export default class Legend extends React.PureComponent { - format(value) { - if (!this.props.format) { - return value; - } - - const numValue = parseFloat(value); - return formatNumber(this.props.format, numValue); - - } - - formatCategoryLabel(k) { - if (!this.props.format) { - return k; - } - - if (k.includes(categoryDelimiter)) { - const values = k.split(categoryDelimiter); - return this.format(values[0]) + categoryDelimiter + this.format(values[1]); - } - - return this.format(k); - } - - render() { - if (Object.keys(this.props.categories).length === 0 || this.props.position === null) { - return null; - } - - const categories = Object.entries(this.props.categories).map(([k, v]) => { - const style = { color: 'rgba(' + v.color.join(', ') + ')' }; - const icon = v.enabled ? '\u25FC' : '\u25FB'; - return ( - <li key={k}> - <a - href="#" - onClick={() => this.props.toggleCategory(k)} - onDoubleClick={() => this.props.showSingleCategory(k)} - > - <span style={style}>{icon}</span> {this.formatCategoryLabel(k)} - </a> - </li> - ); - }); - - const vertical = this.props.position.charAt(0) === 't' ? 'top' : 'bottom'; - const horizontal = this.props.position.charAt(1) === 'r' ? 'right' : 'left'; - const style = { - position: 'absolute', - [vertical]: '0px', - [horizontal]: '10px', - }; - - return ( - <div className={'legend'} style={style}> - <ul className={'categories'}>{categories}</ul> - </div> - ); - } -} - -Legend.propTypes = propTypes; -Legend.defaultProps = defaultProps; diff --git a/superset/assets/src/visualizations/PlaySlider.css b/superset/assets/src/visualizations/PlaySlider.css deleted file mode 100644 index 0c21b3e..0000000 --- a/superset/assets/src/visualizations/PlaySlider.css +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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. - */ -.play-slider { - display: flex; - height: 40px; - width: 100%; - margin: 0; -} - -.play-slider-controls { - flex: 0 0 80px; - text-align: middle; -} - -.play-slider-scrobbler { - flex: 1; -} - -.slider.slider-horizontal { - width: 100% !important; -} - -.slider-button { - color: #b3b3b3; - margin-right: 5px; -} - -div.slider > div.tooltip.tooltip-main.top.in { - margin-left: 0 !important; -} diff --git a/superset/assets/src/visualizations/PlaySlider.jsx b/superset/assets/src/visualizations/PlaySlider.jsx deleted file mode 100644 index f660022..0000000 --- a/superset/assets/src/visualizations/PlaySlider.jsx +++ /dev/null @@ -1,170 +0,0 @@ -/** - * 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 Mousetrap from 'mousetrap'; -import { t } from '@superset-ui/translation'; -import BootrapSliderWrapper from '../components/BootstrapSliderWrapper'; -import './PlaySlider.css'; - -const propTypes = { - start: PropTypes.number.isRequired, - step: PropTypes.number.isRequired, - end: PropTypes.number.isRequired, - values: PropTypes.array.isRequired, - onChange: PropTypes.func, - loopDuration: PropTypes.number, - maxFrames: PropTypes.number, - orientation: PropTypes.oneOf(['horizontal', 'vertical']), - reversed: PropTypes.bool, - disabled: PropTypes.bool, - range: PropTypes.bool, -}; - -const defaultProps = { - onChange: () => {}, - loopDuration: 15000, - maxFrames: 100, - orientation: 'horizontal', - reversed: false, - disabled: false, - range: true, -}; - -export default class PlaySlider extends React.PureComponent { - constructor(props) { - super(props); - this.state = { intervalId: null }; - - const range = props.end - props.start; - const frames = Math.min(props.maxFrames, range / props.step); - const width = range / frames; - this.intervalMilliseconds = props.loopDuration / frames; - this.increment = width < props.step ? props.step : width - (width % props.step); - - this.onChange = this.onChange.bind(this); - this.play = this.play.bind(this); - this.pause = this.pause.bind(this); - this.stepBackward = this.stepBackward.bind(this); - this.stepForward = this.stepForward.bind(this); - this.getPlayClass = this.getPlayClass.bind(this); - this.formatter = this.formatter.bind(this); - } - componentDidMount() { - Mousetrap.bind(['space'], this.play); - } - componentWillUnmount() { - Mousetrap.unbind(['space']); - } - onChange(event) { - this.props.onChange(event.target.value); - if (this.state.intervalId != null) { - this.pause(); - } - } - getPlayClass() { - if (this.state.intervalId == null) { - return 'fa fa-play fa-lg slider-button'; - } - return 'fa fa-pause fa-lg slider-button'; - } - play() { - if (this.props.disabled) { - return; - } - if (this.state.intervalId != null) { - this.pause(); - } else { - const id = setInterval(this.stepForward, this.intervalMilliseconds); - this.setState({ intervalId: id }); - } - } - pause() { - clearInterval(this.state.intervalId); - this.setState({ intervalId: null }); - } - stepForward() { - const { start, end, step, values, disabled } = this.props; - - if (disabled) { - return; - } - - const currentValues = Array.isArray(values) ? values : [values, values + step]; - const nextValues = currentValues.map(value => value + this.increment); - const carriageReturn = (nextValues[1] > end) ? (nextValues[0] - start) : 0; - - this.props.onChange(nextValues.map(value => value - carriageReturn)); - } - stepBackward() { - const { start, end, step, values, disabled } = this.props; - - if (disabled) { - return; - } - - const currentValues = Array.isArray(values) ? values : [values, values + step]; - const nextValues = currentValues.map(value => value - this.increment); - const carriageReturn = (nextValues[0] < start) ? (end - nextValues[1]) : 0; - - this.props.onChange(nextValues.map(value => value + carriageReturn)); - } - formatter(values) { - if (this.props.disabled) { - return t('Data has no time steps'); - } - - let parts = values; - if (!Array.isArray(values)) { - parts = [values]; - } else if (values[0] === values[1]) { - parts = [values[0]]; - } - return parts.map(value => (new Date(value)).toUTCString()).join(' : '); - } - render() { - const { start, end, step, orientation, reversed, disabled, range, values } = this.props; - return ( - <div className="play-slider"> - <div className="play-slider-controls padded"> - <i className="fa fa-step-backward fa-lg slider-button " onClick={this.stepBackward} /> - <i className={this.getPlayClass()} onClick={this.play} /> - <i className="fa fa-step-forward fa-lg slider-button " onClick={this.stepForward} /> - </div> - <div className="play-slider-scrobbler padded"> - <BootrapSliderWrapper - value={range ? values : values[0]} - range={range} - formatter={this.formatter} - change={this.onChange} - min={start} - max={end} - step={step} - orientation={orientation} - reversed={reversed} - disabled={disabled ? 'disabled' : 'enabled'} - /> - </div> - </div> - ); - } -} - -PlaySlider.propTypes = propTypes; -PlaySlider.defaultProps = defaultProps; diff --git a/superset/assets/src/visualizations/deckgl/AnimatableDeckGLContainer.jsx b/superset/assets/src/visualizations/deckgl/AnimatableDeckGLContainer.jsx deleted file mode 100644 index fe2c716..0000000 --- a/superset/assets/src/visualizations/deckgl/AnimatableDeckGLContainer.jsx +++ /dev/null @@ -1,115 +0,0 @@ -/** - * 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; diff --git a/superset/assets/src/visualizations/deckgl/CategoricalDeckGLContainer.jsx b/superset/assets/src/visualizations/deckgl/CategoricalDeckGLContainer.jsx deleted file mode 100644 index 2a3e7b3..0000000 --- a/superset/assets/src/visualizations/deckgl/CategoricalDeckGLContainer.jsx +++ /dev/null @@ -1,248 +0,0 @@ -/** - * 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. - */ -/* eslint no-underscore-dangle: ["error", { "allow": ["", "__timestamp"] }] */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { CategoricalColorNamespace } from '@superset-ui/color'; -import AnimatableDeckGLContainer from './AnimatableDeckGLContainer'; -import Legend from '../Legend'; -import { hexToRGB } from '../../modules/colors'; -import { getPlaySliderParams } from '../../modules/time'; -import sandboxedEval from '../../modules/sandbox'; -import { fitViewport } from './layers/common'; - -const { getScale } = CategoricalColorNamespace; - -function getCategories(fd, data) { - const c = fd.color_picker || { r: 0, g: 0, b: 0, a: 1 }; - const fixedColor = [c.r, c.g, c.b, 255 * c.a]; - const colorFn = getScale(fd.color_scheme); - const categories = {}; - data.forEach((d) => { - if (d.cat_color != null && !categories.hasOwnProperty(d.cat_color)) { - let color; - if (fd.dimension) { - color = hexToRGB(colorFn(d.cat_color), c.a * 255); - } else { - color = fixedColor; - } - categories[d.cat_color] = { color, enabled: true }; - } - }); - return categories; -} - -const propTypes = { - formData: PropTypes.object.isRequired, - mapboxApiKey: PropTypes.string.isRequired, - setControlValue: PropTypes.func.isRequired, - viewport: PropTypes.object.isRequired, - getLayer: PropTypes.func.isRequired, - getPoints: PropTypes.func.isRequired, - payload: PropTypes.object.isRequired, - onAddFilter: PropTypes.func, - setTooltip: PropTypes.func, -}; - -export default class CategoricalDeckGLContainer extends React.PureComponent { - /* - * A Deck.gl container that handles categories. - * - * The container will have an interactive legend, populated from the - * categories present in the data. - */ - constructor(props) { - super(props); - this.state = this.getStateFromProps(props); - - this.getLayers = this.getLayers.bind(this); - this.onValuesChange = this.onValuesChange.bind(this); - this.onViewportChange = this.onViewportChange.bind(this); - this.toggleCategory = this.toggleCategory.bind(this); - this.showSingleCategory = this.showSingleCategory.bind(this); - } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.payload.form_data !== this.state.formData) { - this.setState({ ...this.getStateFromProps(nextProps) }); - } - } - onValuesChange(values) { - this.setState({ - values: Array.isArray(values) - ? values - : [values, values + this.state.getStep(values)], - }); - } - onViewportChange(viewport) { - this.setState({ viewport }); - } - getStateFromProps(props, state) { - const features = props.payload.data.features || []; - const timestamps = features.map(f => f.__timestamp); - const categories = getCategories(props.formData, features); - - // the state is computed only from the payload; if it hasn't changed, do - // not recompute state since this would reset selections and/or the play - // slider position due to changes in form controls - if (state && props.payload.form_data === state.formData) { - return { ...state, categories }; - } - - // the granularity has to be read from the payload form_data, not the - // props formData which comes from the instantaneous controls state - const granularity = ( - props.payload.form_data.time_grain_sqla || - props.payload.form_data.granularity || - 'P1D' - ); - - const { - start, - end, - getStep, - values, - disabled, - } = getPlaySliderParams(timestamps, granularity); - - const viewport = props.formData.autozoom - ? fitViewport(props.viewport, props.getPoints(features)) - : props.viewport; - - return { - start, - end, - getStep, - values, - disabled, - viewport, - selected: [], - lastClick: 0, - formData: props.payload.form_data, - categories, - }; - } - getLayers(values) { - const { - getLayer, - payload, - formData: fd, - onAddFilter, - setTooltip, - } = this.props; - let features = payload.data.features - ? [...payload.data.features] - : []; - - // Add colors from categories or fixed color - features = this.addColor(features, fd); - - // Apply user defined data mutator if defined - if (fd.js_data_mutator) { - const jsFnMutator = sandboxedEval(fd.js_data_mutator); - features = jsFnMutator(features); - } - - // Filter by time - if (values[0] === values[1] || values[1] === this.end) { - features = features.filter(d => d.__timestamp >= values[0] && d.__timestamp <= values[1]); - } else { - features = features.filter(d => d.__timestamp >= values[0] && d.__timestamp < values[1]); - } - - // Show only categories selected in the legend - const cats = this.state.categories; - if (fd.dimension) { - features = features.filter(d => cats[d.cat_color] && cats[d.cat_color].enabled); - } - - const filteredPayload = { - ...payload, - data: { ...payload.data, features }, - }; - - return [getLayer(fd, filteredPayload, onAddFilter, setTooltip)]; - } - addColor(data, fd) { - const c = fd.color_picker || { r: 0, g: 0, b: 0, a: 1 }; - const colorFn = getScale(fd.color_scheme); - return data.map((d) => { - let color; - if (fd.dimension) { - color = hexToRGB(colorFn(d.cat_color), c.a * 255); - return { ...d, color }; - } - return d; - }); - } - toggleCategory(category) { - const categoryState = this.state.categories[category]; - const categories = { - ...this.state.categories, - [category]: { - ...categoryState, - enabled: !categoryState.enabled, - }, - }; - - // if all categories are disabled, enable all -- similar to nvd3 - if (Object.values(categories).every(v => !v.enabled)) { - /* eslint-disable no-param-reassign */ - Object.values(categories).forEach((v) => { v.enabled = true; }); - } - this.setState({ categories }); - } - showSingleCategory(category) { - const categories = { ...this.state.categories }; - /* eslint-disable no-param-reassign */ - Object.values(categories).forEach((v) => { v.enabled = false; }); - categories[category].enabled = true; - this.setState({ categories }); - } - render() { - return ( - <div style={{ position: 'relative' }}> - <AnimatableDeckGLContainer - getLayers={this.getLayers} - start={this.state.start} - end={this.state.end} - getStep={this.state.getStep} - values={this.state.values} - onValuesChange={this.onValuesChange} - disabled={this.state.disabled} - viewport={this.state.viewport} - onViewportChange={this.onViewportChange} - mapboxApiAccessToken={this.props.mapboxApiKey} - mapStyle={this.props.formData.mapbox_style} - setControlValue={this.props.setControlValue} - > - <Legend - categories={this.state.categories} - toggleCategory={this.toggleCategory} - showSingleCategory={this.showSingleCategory} - position={this.props.formData.legend_position} - format={this.props.formData.legend_format} - /> - </AnimatableDeckGLContainer> - </div> - ); - } -} - -CategoricalDeckGLContainer.propTypes = propTypes; diff --git a/superset/assets/src/visualizations/deckgl/DeckGLContainer.jsx b/superset/assets/src/visualizations/deckgl/DeckGLContainer.jsx deleted file mode 100644 index ff414bf..0000000 --- a/superset/assets/src/visualizations/deckgl/DeckGLContainer.jsx +++ /dev/null @@ -1,115 +0,0 @@ -/** - * 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 MapGL from 'react-map-gl'; -import DeckGL from 'deck.gl'; -import 'mapbox-gl/dist/mapbox-gl.css'; -import { isEqual } from 'lodash'; -import '../stylesheets/deckgl.css'; - -const TICK = 2000; // milliseconds - -const propTypes = { - viewport: PropTypes.object.isRequired, - layers: PropTypes.array.isRequired, - setControlValue: PropTypes.func, - mapStyle: PropTypes.string, - mapboxApiAccessToken: PropTypes.string.isRequired, - onViewportChange: PropTypes.func, -}; -const defaultProps = { - mapStyle: 'light', - onViewportChange: () => {}, - setControlValue: () => {}, -}; - -export default class DeckGLContainer extends React.Component { - constructor(props) { - super(props); - this.tick = this.tick.bind(this); - this.onViewportChange = this.onViewportChange.bind(this); - // This has to be placed after this.tick is bound to this - this.state = { - previousViewport: props.viewport, - timer: setInterval(this.tick, TICK), - }; - } - static getDerivedStateFromProps(nextProps, prevState) { - if (nextProps.viewport !== prevState.viewport) { - return { - viewport: { ...nextProps.viewport }, - previousViewport: prevState.viewport, - }; - } - return null; - } - componentWillUnmount() { - clearInterval(this.state.timer); - } - onViewportChange(viewport) { - const vp = Object.assign({}, viewport); - // delete vp.width; - // delete vp.height; - const newVp = { ...this.state.previousViewport, ...vp }; - - // this.setState(() => ({ viewport: newVp })); - this.props.onViewportChange(newVp); - } - tick() { - // Limiting updating viewport controls through Redux at most 1*sec - // Deep compare is needed as shallow equality doesn't work here, viewport object - // changes id at every change - if (this.state && !isEqual(this.state.previousViewport, this.props.viewport)) { - const setCV = this.props.setControlValue; - const vp = this.props.viewport; - if (setCV) { - setCV('viewport', vp); - } - this.setState(() => ({ previousViewport: this.props.viewport })); - } - } - layers() { - // Support for layer factory - if (this.props.layers.some(l => typeof l === 'function')) { - return this.props.layers.map(l => typeof l === 'function' ? l() : l); - } - return this.props.layers; - } - render() { - const { viewport } = this.props; - return ( - <MapGL - {...viewport} - mapStyle={this.props.mapStyle} - onViewportChange={this.onViewportChange} - mapboxApiAccessToken={this.props.mapboxApiAccessToken} - > - <DeckGL - {...viewport} - layers={this.layers()} - initWebGLParameters - /> - </MapGL> - ); - } -} - -DeckGLContainer.propTypes = propTypes; -DeckGLContainer.defaultProps = defaultProps; diff --git a/superset/assets/src/visualizations/deckgl/Multi/Multi.jsx b/superset/assets/src/visualizations/deckgl/Multi/Multi.jsx deleted file mode 100644 index 335ba3a..0000000 --- a/superset/assets/src/visualizations/deckgl/Multi/Multi.jsx +++ /dev/null @@ -1,131 +0,0 @@ -/** - * 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 _ from 'lodash'; -import PropTypes from 'prop-types'; -import { SupersetClient } from '@superset-ui/connection'; - -import DeckGLContainer from '../DeckGLContainer'; -import { getExploreLongUrl } from '../../../explore/exploreUtils'; -import layerGenerators from '../layers'; - -const propTypes = { - formData: PropTypes.object.isRequired, - payload: PropTypes.object.isRequired, - setControlValue: PropTypes.func.isRequired, - viewport: PropTypes.object.isRequired, - onAddFilter: PropTypes.func, - setTooltip: PropTypes.func, - onSelect: PropTypes.func, -}; -const defaultProps = { - onAddFilter() {}, - setTooltip() {}, - onSelect() {}, -}; - -class DeckMulti extends React.PureComponent { - constructor(props) { - super(props); - this.state = { subSlicesLayers: {} }; - this.onViewportChange = this.onViewportChange.bind(this); - } - - componentDidMount() { - const { formData, payload } = this.props; - this.loadLayers(formData, payload); - } - - UNSAFE_componentWillReceiveProps(nextProps) { - const { formData, payload } = nextProps; - const hasChanges = !_.isEqual(this.props.formData.deck_slices, nextProps.formData.deck_slices); - if (hasChanges) { - this.loadLayers(formData, payload); - } - } - - onViewportChange(viewport) { - this.setState({ viewport }); - } - - loadLayers(formData, payload, viewport) { - this.setState({ subSlicesLayers: {}, viewport }); - payload.data.slices.forEach((subslice) => { - // Filters applied to multi_deck are passed down to underlying charts - // note that dashboard contextual information (filter_immune_slices and such) aren't - // taken into consideration here - const filters = [ - ...(subslice.form_data.filters || []), - ...(formData.filters || []), - ...(formData.extra_filters || []), - ]; - const subsliceCopy = { - ...subslice, - form_data: { - ...subslice.form_data, - filters, - }, - }; - - SupersetClient.get({ - endpoint: getExploreLongUrl(subsliceCopy.form_data, 'json'), - }) - .then(({ json }) => { - const layer = layerGenerators[subsliceCopy.form_data.viz_type]( - subsliceCopy.form_data, - json, - this.props.onAddFilter, - this.props.setTooltip, - [], - this.props.onSelect, - ); - this.setState({ - subSlicesLayers: { - ...this.state.subSlicesLayers, - [subsliceCopy.slice_id]: layer, - }, - }); - }) - .catch(() => {}); - }); - } - - render() { - const { payload, formData, setControlValue } = this.props; - const { subSlicesLayers } = this.state; - - const layers = Object.values(subSlicesLayers); - - return ( - <DeckGLContainer - mapboxApiAccessToken={payload.data.mapboxApiKey} - viewport={this.state.viewport || this.props.viewport} - onViewportChange={this.onViewportChange} - layers={layers} - mapStyle={formData.mapbox_style} - setControlValue={setControlValue} - /> - ); - } -} - -DeckMulti.propTypes = propTypes; -DeckMulti.defaultProps = defaultProps; - -export default DeckMulti; diff --git a/superset/assets/src/visualizations/deckgl/Multi/MultiChartPlugin.js b/superset/assets/src/visualizations/deckgl/Multi/MultiChartPlugin.js deleted file mode 100644 index c3cae62..0000000 --- a/superset/assets/src/visualizations/deckgl/Multi/MultiChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl Multiple Layers'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class MultiChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Multi.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/Multi/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/Multi/images/thumbnail.png deleted file mode 100644 index acedd5b..0000000 Binary files a/superset/assets/src/visualizations/deckgl/Multi/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/Multi/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/Multi/images/thumbnailLarge.png deleted file mode 100644 index 21c27c0..0000000 Binary files a/superset/assets/src/visualizations/deckgl/Multi/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/TooltipRow.jsx b/superset/assets/src/visualizations/deckgl/TooltipRow.jsx deleted file mode 100644 index cc85bfd..0000000 --- a/superset/assets/src/visualizations/deckgl/TooltipRow.jsx +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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'; - -const propTypes = { - label: PropTypes.string.isRequired, - value: PropTypes.string.isRequired, -}; - - -export default class TooltipRow extends React.PureComponent { - render() { - return ( - <div>{this.props.label}<strong>{this.props.value}</strong></div> - ); - } -} - -TooltipRow.propTypes = propTypes; diff --git a/superset/assets/src/visualizations/deckgl/factory.jsx b/superset/assets/src/visualizations/deckgl/factory.jsx deleted file mode 100644 index abbdcca..0000000 --- a/superset/assets/src/visualizations/deckgl/factory.jsx +++ /dev/null @@ -1,134 +0,0 @@ -/** - * 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 { isEqual } from 'lodash'; - -import DeckGLContainer from './DeckGLContainer'; -import CategoricalDeckGLContainer from './CategoricalDeckGLContainer'; -import { fitViewport } from './layers/common'; - -const propTypes = { - formData: PropTypes.object.isRequired, - payload: PropTypes.object.isRequired, - setControlValue: PropTypes.func.isRequired, - viewport: PropTypes.object.isRequired, - onAddFilter: PropTypes.func, - setTooltip: PropTypes.func, -}; -const defaultProps = { - onAddFilter() {}, - setTooltip() {}, -}; - -export function createDeckGLComponent(getLayer, getPoints) { - // Higher order component - class Component extends React.PureComponent { - constructor(props) { - super(props); - const originalViewport = props.viewport; - const viewport = props.formData.autozoom - ? fitViewport(originalViewport, getPoints(props.payload.data.features)) - : originalViewport; - this.state = { - viewport, - layer: this.computeLayer(props), - }; - this.onViewportChange = this.onViewportChange.bind(this); - } - UNSAFE_componentWillReceiveProps(nextProps) { - // Only recompute the layer if anything BUT the viewport has changed - const nextFdNoVP = { ...nextProps.formData, viewport: null }; - const currFdNoVP = { ...this.props.formData, viewport: null }; - if ( - !isEqual(nextFdNoVP, currFdNoVP) || - nextProps.payload !== this.props.payload - ) { - this.setState({ layer: this.computeLayer(nextProps) }); - } - } - onViewportChange(viewport) { - this.setState({ viewport }); - } - computeLayer(props) { - const { - formData, - payload, - onAddFilter, - setTooltip, - } = props; - return getLayer(formData, payload, onAddFilter, setTooltip); - } - render() { - const { - formData, - payload, - setControlValue, - } = this.props; - const { - layer, - viewport, - } = this.state; - return ( - <DeckGLContainer - mapboxApiAccessToken={payload.data.mapboxApiKey} - viewport={viewport} - layers={[layer]} - mapStyle={formData.mapbox_style} - setControlValue={setControlValue} - onViewportChange={this.onViewportChange} - />); - } - } - Component.propTypes = propTypes; - Component.defaultProps = defaultProps; - return Component; -} - -export function createCategoricalDeckGLComponent(getLayer, getPoints) { - function Component(props) { - const { - formData, - payload, - setControlValue, - onAddFilter, - setTooltip, - viewport, - } = props; - - return ( - <CategoricalDeckGLContainer - formData={formData} - mapboxApiKey={payload.data.mapboxApiKey} - setControlValue={setControlValue} - viewport={viewport} - getLayer={getLayer} - payload={payload} - onAddFilter={onAddFilter} - setTooltip={setTooltip} - getPoints={getPoints} - /> - ); - } - - Component.propTypes = propTypes; - Component.defaultProps = defaultProps; - - return Component; -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Arc/Arc.jsx b/superset/assets/src/visualizations/deckgl/layers/Arc/Arc.jsx deleted file mode 100644 index 2c0a99b..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Arc/Arc.jsx +++ /dev/null @@ -1,61 +0,0 @@ -/** - * 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 { ArcLayer } from 'deck.gl'; -import React from 'react'; -import { t } from '@superset-ui/translation'; -import { commonLayerProps } from '../common'; -import { createCategoricalDeckGLComponent } from '../../factory'; -import TooltipRow from '../../TooltipRow'; - -function getPoints(data) { - const points = []; - data.forEach((d) => { - points.push(d.sourcePosition); - points.push(d.targetPosition); - }); - return points; -} - -function setTooltipContent(formData) { - return o => ( - <div className="deckgl-tooltip"> - <TooltipRow label={`${t('Start (Longitude, Latitude)')}: `} value={`${o.object.sourcePosition[0]}, ${o.object.sourcePosition[1]}`} /> - <TooltipRow label={`${t('End (Longitude, Latitude)')}: `} value={`${o.object.targetPosition[0]}, ${o.object.targetPosition[1]}`} /> - { - formData.dimension && <TooltipRow label={`${formData.dimension}: `} value={`${o.object.cat_color}`} /> - } - </div> - ); -} - -export function getLayer(fd, payload, onAddFilter, setTooltip) { - const data = payload.data.features; - const sc = fd.color_picker; - const tc = fd.target_color_picker; - return new ArcLayer({ - id: `path-layer-${fd.slice_id}`, - data, - getSourceColor: d => d.sourceColor || d.color || [sc.r, sc.g, sc.b, 255 * sc.a], - getTargetColor: d => d.targetColor || d.color || [tc.r, tc.g, tc.b, 255 * tc.a], - strokeWidth: (fd.stroke_width) ? fd.stroke_width : 3, - ...commonLayerProps(fd, setTooltip, setTooltipContent(fd)), - }); -} - -export default createCategoricalDeckGLComponent(getLayer, getPoints); diff --git a/superset/assets/src/visualizations/deckgl/layers/Arc/ArcChartPlugin.js b/superset/assets/src/visualizations/deckgl/layers/Arc/ArcChartPlugin.js deleted file mode 100644 index 8f59763..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Arc/ArcChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl Arc'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class ArcChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Arc.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Arc/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/layers/Arc/images/thumbnail.png deleted file mode 100644 index 02b84b1..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Arc/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Arc/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/layers/Arc/images/thumbnailLarge.png deleted file mode 100644 index f79f283..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Arc/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Geojson/Geojson.jsx b/superset/assets/src/visualizations/deckgl/layers/Geojson/Geojson.jsx deleted file mode 100644 index 7488a3d..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Geojson/Geojson.jsx +++ /dev/null @@ -1,171 +0,0 @@ -/** - * 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 { GeoJsonLayer } from 'deck.gl'; -// TODO import geojsonExtent from 'geojson-extent'; - -import DeckGLContainer from '../../DeckGLContainer'; -import { hexToRGB } from '../../../../modules/colors'; -import sandboxedEval from '../../../../modules/sandbox'; -import { commonLayerProps } from '../common'; -import TooltipRow from '../../TooltipRow'; - -const propertyMap = { - fillColor: 'fillColor', - color: 'fillColor', - fill: 'fillColor', - 'fill-color': 'fillColor', - strokeColor: 'strokeColor', - 'stroke-color': 'strokeColor', - 'stroke-width': 'strokeWidth', -}; - -const alterProps = (props, propOverrides) => { - const newProps = {}; - Object.keys(props).forEach((k) => { - if (k in propertyMap) { - newProps[propertyMap[k]] = props[k]; - } else { - newProps[k] = props[k]; - } - }); - if (typeof props.fillColor === 'string') { - newProps.fillColor = hexToRGB(props.fillColor); - } - if (typeof props.strokeColor === 'string') { - newProps.strokeColor = hexToRGB(props.strokeColor); - } - return { - ...newProps, - ...propOverrides, - }; -}; -let features; -const recurseGeoJson = (node, propOverrides, extraProps) => { - if (node && node.features) { - node.features.forEach((obj) => { - recurseGeoJson(obj, propOverrides, node.extraProps || extraProps); - }); - } - if (node && node.geometry) { - const newNode = { - ...node, - properties: alterProps(node.properties, propOverrides), - }; - if (!newNode.extraProps) { - newNode.extraProps = extraProps; - } - features.push(newNode); - } -}; - -function setTooltipContent(o) { - return ( - o.object.extraProps && - <div className="deckgl-tooltip"> - { - Object.keys(o.object.extraProps).map((prop, index) => - <TooltipRow key={`prop-${index}`} label={`${prop}: `} value={`${o.object.extraProps[prop]}`} />, - ) - } - </div> - ); -} - -export function getLayer(formData, payload, onAddFilter, setTooltip) { - const fd = formData; - const fc = fd.fill_color_picker; - const sc = fd.stroke_color_picker; - const fillColor = [fc.r, fc.g, fc.b, 255 * fc.a]; - const strokeColor = [sc.r, sc.g, sc.b, 255 * sc.a]; - const propOverrides = {}; - if (fillColor[3] > 0) { - propOverrides.fillColor = fillColor; - } - if (strokeColor[3] > 0) { - propOverrides.strokeColor = strokeColor; - } - - features = []; - recurseGeoJson(payload.data, propOverrides); - - let jsFnMutator; - if (fd.js_data_mutator) { - // Applying user defined data mutator if defined - jsFnMutator = sandboxedEval(fd.js_data_mutator); - features = jsFnMutator(features); - } - - return new GeoJsonLayer({ - id: `geojson-layer-${fd.slice_id}`, - filled: fd.filled, - data: features, - stroked: fd.stroked, - extruded: fd.extruded, - pointRadiusScale: fd.point_radius_scale, - ...commonLayerProps(fd, setTooltip, setTooltipContent), - }); -} - -const propTypes = { - formData: PropTypes.object.isRequired, - payload: PropTypes.object.isRequired, - setControlValue: PropTypes.func.isRequired, - viewport: PropTypes.object.isRequired, - onAddFilter: PropTypes.func, - setTooltip: PropTypes.func, -}; -const defaultProps = { - onAddFilter() {}, - setTooltip() {}, -}; - -function deckGeoJson(props) { - const { - formData, - payload, - setControlValue, - onAddFilter, - setTooltip, - viewport, - } = props; - - // TODO get this to work - // if (formData.autozoom) { - // viewport = common.fitViewport(viewport, geojsonExtent(payload.data.features)); - // } - - const layer = getLayer(formData, payload, onAddFilter, setTooltip); - - return ( - <DeckGLContainer - mapboxApiAccessToken={payload.data.mapboxApiKey} - viewport={viewport} - layers={[layer]} - mapStyle={formData.mapbox_style} - setControlValue={setControlValue} - /> - ); -} - -deckGeoJson.propTypes = propTypes; -deckGeoJson.defaultProps = defaultProps; - -export default deckGeoJson; diff --git a/superset/assets/src/visualizations/deckgl/layers/Geojson/GeojsonChartPlugin.js b/superset/assets/src/visualizations/deckgl/layers/Geojson/GeojsonChartPlugin.js deleted file mode 100644 index 06fded5d..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Geojson/GeojsonChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl Geojson'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class GeojsonChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Geojson.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Geojson/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/layers/Geojson/images/thumbnail.png deleted file mode 100644 index 9c1a732..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Geojson/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Geojson/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/layers/Geojson/images/thumbnailLarge.png deleted file mode 100644 index acc452c..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Geojson/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Grid/Grid.jsx b/superset/assets/src/visualizations/deckgl/layers/Grid/Grid.jsx deleted file mode 100644 index a0cc861..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Grid/Grid.jsx +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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 { GridLayer } from 'deck.gl'; -import React from 'react'; -import { t } from '@superset-ui/translation'; - -import { commonLayerProps, getAggFunc } from '../common'; -import sandboxedEval from '../../../../modules/sandbox'; -import { createDeckGLComponent } from '../../factory'; -import TooltipRow from '../../TooltipRow'; - -function setTooltipContent(o) { - return ( - <div className="deckgl-tooltip"> - <TooltipRow label={`${t('Longitude and Latitude')}: `} value={`${o.object.position[0]}, ${o.object.position[1]}`} /> - <TooltipRow label={`${t('Height')}: `} value={`${o.object.elevationValue}`} /> - </div> - ); -} - -export function getLayer(formData, payload, onAddFilter, setTooltip) { - const fd = formData; - const c = fd.color_picker; - let data = payload.data.features.map(d => ({ - ...d, - color: [c.r, c.g, c.b, 255 * c.a], - })); - - if (fd.js_data_mutator) { - // Applying user defined data mutator if defined - const jsFnMutator = sandboxedEval(fd.js_data_mutator); - data = jsFnMutator(data); - } - - const aggFunc = getAggFunc(fd.js_agg_function, p => p.weight); - return new GridLayer({ - id: `grid-layer-${fd.slice_id}`, - data, - pickable: true, - cellSize: fd.grid_size, - minColor: [0, 0, 0, 0], - extruded: fd.extruded, - maxColor: [c.r, c.g, c.b, 255 * c.a], - outline: false, - getElevationValue: aggFunc, - getColorValue: aggFunc, - ...commonLayerProps(fd, setTooltip, setTooltipContent), - }); -} - -function getPoints(data) { - return data.map(d => d.position); -} - -export default createDeckGLComponent(getLayer, getPoints); diff --git a/superset/assets/src/visualizations/deckgl/layers/Grid/GridChartPlugin.js b/superset/assets/src/visualizations/deckgl/layers/Grid/GridChartPlugin.js deleted file mode 100644 index 291b967..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Grid/GridChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl Grid'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class GridChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Grid.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Grid/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/layers/Grid/images/thumbnail.png deleted file mode 100644 index 2710d9f..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Grid/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Grid/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/layers/Grid/images/thumbnailLarge.png deleted file mode 100644 index cd93965..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Grid/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Hex/Hex.jsx b/superset/assets/src/visualizations/deckgl/layers/Hex/Hex.jsx deleted file mode 100644 index 9901b22..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Hex/Hex.jsx +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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 { HexagonLayer } from 'deck.gl'; -import React from 'react'; -import { t } from '@superset-ui/translation'; - -import { commonLayerProps, getAggFunc } from '../common'; -import sandboxedEval from '../../../../modules/sandbox'; -import { createDeckGLComponent } from '../../factory'; -import TooltipRow from '../../TooltipRow'; - -function setTooltipContent(o) { - return ( - <div className="deckgl-tooltip"> - <TooltipRow label={`${t('Centroid (Longitude and Latitude)')}: `} value={`(${o.object.centroid[0]}, ${o.object.centroid[1]})`} /> - <TooltipRow label={`${t('Height')}: `} value={`${o.object.elevationValue}`} /> - </div> - ); -} - -export function getLayer(formData, payload, onAddFilter, setTooltip) { - const fd = formData; - const c = fd.color_picker; - let data = payload.data.features.map(d => ({ - ...d, - color: [c.r, c.g, c.b, 255 * c.a], - })); - - if (fd.js_data_mutator) { - // Applying user defined data mutator if defined - const jsFnMutator = sandboxedEval(fd.js_data_mutator); - data = jsFnMutator(data); - } - const aggFunc = getAggFunc(fd.js_agg_function, p => p.weight); - return new HexagonLayer({ - id: `hex-layer-${fd.slice_id}`, - data, - pickable: true, - radius: fd.grid_size, - minColor: [0, 0, 0, 0], - extruded: fd.extruded, - maxColor: [c.r, c.g, c.b, 255 * c.a], - outline: false, - getElevationValue: aggFunc, - getColorValue: aggFunc, - ...commonLayerProps(fd, setTooltip, setTooltipContent), - }); -} - -function getPoints(data) { - return data.map(d => d.position); -} - -export default createDeckGLComponent(getLayer, getPoints); diff --git a/superset/assets/src/visualizations/deckgl/layers/Hex/HexChartPlugin.js b/superset/assets/src/visualizations/deckgl/layers/Hex/HexChartPlugin.js deleted file mode 100644 index 940ae5b..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Hex/HexChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl 3D Hexagon'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class HexChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Hex.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Hex/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/layers/Hex/images/thumbnail.png deleted file mode 100644 index 99149db..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Hex/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Hex/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/layers/Hex/images/thumbnailLarge.png deleted file mode 100644 index 31feff5..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Hex/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Path/Path.jsx b/superset/assets/src/visualizations/deckgl/layers/Path/Path.jsx deleted file mode 100644 index 7bf0982..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Path/Path.jsx +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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 { PathLayer } from 'deck.gl'; -import React from 'react'; -import { commonLayerProps } from '../common'; -import sandboxedEval from '../../../../modules/sandbox'; -import { createDeckGLComponent } from '../../factory'; -import TooltipRow from '../../TooltipRow'; - -function setTooltipContent(o) { - return ( - o.object.extraProps && - <div className="deckgl-tooltip"> - { - Object.keys(o.object.extraProps).map((prop, index) => - <TooltipRow key={`prop-${index}`} label={`${prop}: `} value={`${o.object.extraProps[prop]}`} />, - ) - } - </div> - ); -} - -export function getLayer(formData, payload, onAddFilter, setTooltip) { - const fd = formData; - const c = fd.color_picker; - const fixedColor = [c.r, c.g, c.b, 255 * c.a]; - let data = payload.data.features.map(feature => ({ - ...feature, - path: feature.path, - width: fd.line_width, - color: fixedColor, - })); - - if (fd.js_data_mutator) { - const jsFnMutator = sandboxedEval(fd.js_data_mutator); - data = jsFnMutator(data); - } - - return new PathLayer({ - id: `path-layer-${fd.slice_id}`, - data, - rounded: true, - widthScale: 1, - ...commonLayerProps(fd, setTooltip, setTooltipContent), - }); -} - -function getPoints(data) { - let points = []; - data.forEach((d) => { - points = points.concat(d.path); - }); - return points; -} - -export default createDeckGLComponent(getLayer, getPoints); diff --git a/superset/assets/src/visualizations/deckgl/layers/Path/PathChartPlugin.js b/superset/assets/src/visualizations/deckgl/layers/Path/PathChartPlugin.js deleted file mode 100644 index 5b584c5..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Path/PathChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl Path'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class PathChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Path.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Path/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/layers/Path/images/thumbnail.png deleted file mode 100644 index d783a14..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Path/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Path/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/layers/Path/images/thumbnailLarge.png deleted file mode 100644 index eede9da..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Path/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Polygon/Polygon.jsx b/superset/assets/src/visualizations/deckgl/layers/Polygon/Polygon.jsx deleted file mode 100644 index 891856d..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Polygon/Polygon.jsx +++ /dev/null @@ -1,288 +0,0 @@ -/** - * 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. - */ -/* eslint no-underscore-dangle: ["error", { "allow": ["", "__timestamp"] }] */ - -import React from 'react'; -import PropTypes from 'prop-types'; - -import { PolygonLayer } from 'deck.gl'; - -import AnimatableDeckGLContainer from '../../AnimatableDeckGLContainer'; -import Legend from '../../../Legend'; -import TooltipRow from '../../TooltipRow'; -import { getBuckets, getBreakPointColorScaler } from '../../utils'; - -import { commonLayerProps, fitViewport } from '../common'; -import { getPlaySliderParams } from '../../../../modules/time'; -import sandboxedEval from '../../../../modules/sandbox'; - -const DOUBLE_CLICK_TRESHOLD = 250; // milliseconds - -function getPoints(features) { - return features.map(d => d.polygon).flat(); -} - -function getElevation(d, colorScaler) { - /* in deck.gl 5.3.4 (used in Superset as of 2018-10-24), if a polygon has - * opacity zero it will make everything behind it have opacity zero, - * effectively showing the map layer no matter what other polygons are - * behind it. - */ - return colorScaler(d)[3] === 0 - ? 0 - : d.elevation; -} - -function setTooltipContent(formData) { - return (o) => { - const metricLabel = formData.metric.label || formData.metric; - return ( - <div className="deckgl-tooltip"> - <TooltipRow label={`${formData.line_column}: `} value={`${o.object[formData.line_column]}`} /> - {formData.metric && <TooltipRow label={`${metricLabel}: `} value={`${o.object[metricLabel]}`} />} - </div> - ); - }; -} - -export function getLayer(formData, payload, onAddFilter, setTooltip, selected, onSelect, filters) { - const fd = formData; - const fc = fd.fill_color_picker; - const sc = fd.stroke_color_picker; - let data = [...payload.data.features]; - - if (filters != null) { - filters.forEach((f) => { - data = data.filter(f); - }); - } - - if (fd.js_data_mutator) { - // Applying user defined data mutator if defined - const jsFnMutator = sandboxedEval(fd.js_data_mutator); - data = jsFnMutator(data); - } - - const metricLabel = fd.metric ? fd.metric.label || fd.metric : null; - const accessor = d => d[metricLabel]; - // base color for the polygons - const baseColorScaler = fd.metric === null - ? () => [fc.r, fc.g, fc.b, 255 * fc.a] - : getBreakPointColorScaler(fd, data, accessor); - - // when polygons are selected, reduce the opacity of non-selected polygons - const colorScaler = (d) => { - const baseColor = baseColorScaler(d); - if (selected.length > 0 && selected.indexOf(d[fd.line_column]) === -1) { - baseColor[3] /= 2; - } - return baseColor; - }; - const tooltipContentGenerator = (fd.line_column && fd.metric && ['geohash', 'zipcode'].indexOf(fd.line_type) >= 0) - ? setTooltipContent(fd) - : undefined; - return new PolygonLayer({ - id: `path-layer-${fd.slice_id}`, - data, - pickable: true, - filled: fd.filled, - stroked: fd.stroked, - getPolygon: d => d.polygon, - getFillColor: colorScaler, - getLineColor: [sc.r, sc.g, sc.b, 255 * sc.a], - getLineWidth: fd.line_width, - extruded: fd.extruded, - getElevation: d => getElevation(d, colorScaler), - elevationScale: fd.multiplier, - fp64: true, - ...commonLayerProps(fd, setTooltip, tooltipContentGenerator, onSelect), - }); -} - -const propTypes = { - formData: PropTypes.object.isRequired, - payload: PropTypes.object.isRequired, - setControlValue: PropTypes.func.isRequired, - viewport: PropTypes.object.isRequired, - onAddFilter: PropTypes.func, - setTooltip: PropTypes.func, -}; - -const defaultProps = { - onAddFilter() {}, - setTooltip() {}, -}; - -class DeckGLPolygon extends React.Component { - constructor(props) { - super(props); - - this.state = DeckGLPolygon.getDerivedStateFromProps(props); - - this.getLayers = this.getLayers.bind(this); - this.onSelect = this.onSelect.bind(this); - this.onValuesChange = this.onValuesChange.bind(this); - this.onViewportChange = this.onViewportChange.bind(this); - } - static getDerivedStateFromProps(props, state) { - // the state is computed only from the payload; if it hasn't changed, do - // not recompute state since this would reset selections and/or the play - // slider position due to changes in form controls - if (state && props.payload.form_data === state.formData) { - return null; - } - - const features = props.payload.data.features || []; - const timestamps = features.map(f => f.__timestamp); - - // the granularity has to be read from the payload form_data, not the - // props formData which comes from the instantaneous controls state - const granularity = ( - props.payload.form_data.time_grain_sqla || - props.payload.form_data.granularity || - 'P1D' - ); - - const { - start, - end, - getStep, - values, - disabled, - } = getPlaySliderParams(timestamps, granularity); - - const viewport = props.formData.autozoom - ? fitViewport(props.viewport, getPoints(features)) - : props.viewport; - - return { - start, - end, - getStep, - values, - disabled, - viewport, - selected: [], - lastClick: 0, - formData: props.payload.form_data, - }; - } - onSelect(polygon) { - const { formData, onAddFilter } = this.props; - - const now = new Date(); - const doubleClick = (now - this.state.lastClick) <= DOUBLE_CLICK_TRESHOLD; - - // toggle selected polygons - const selected = [...this.state.selected]; - if (doubleClick) { - selected.splice(0, selected.length, polygon); - } else if (formData.toggle_polygons) { - const i = selected.indexOf(polygon); - if (i === -1) { - selected.push(polygon); - } else { - selected.splice(i, 1); - } - } else { - selected.splice(0, 1, polygon); - } - - this.setState({ selected, lastClick: now }); - if (formData.table_filter) { - onAddFilter(formData.line_column, selected, false, true); - } - } - onValuesChange(values) { - this.setState({ - values: Array.isArray(values) - ? values - : [values, values + this.state.getStep(values)], - }); - } - onViewportChange(viewport) { - this.setState({ viewport }); - } - getLayers(values) { - if (this.props.payload.data.features === undefined) { - return []; - } - - const filters = []; - - // time filter - if (values[0] === values[1] || values[1] === this.end) { - filters.push(d => d.__timestamp >= values[0] && d.__timestamp <= values[1]); - } else { - filters.push(d => d.__timestamp >= values[0] && d.__timestamp < values[1]); - } - - const layer = getLayer( - this.props.formData, - this.props.payload, - this.props.onAddFilter, - this.props.setTooltip, - this.state.selected, - this.onSelect, - filters); - - return [layer]; - } - render() { - const { payload, formData, setControlValue } = this.props; - const { start, end, getStep, values, disabled, viewport } = this.state; - - const fd = formData; - const metricLabel = fd.metric ? fd.metric.label || fd.metric : null; - const accessor = d => d[metricLabel]; - - const buckets = getBuckets(formData, payload.data.features, accessor); - return ( - <div style={{ position: 'relative' }}> - <AnimatableDeckGLContainer - getLayers={this.getLayers} - start={start} - end={end} - getStep={getStep} - values={values} - onValuesChange={this.onValuesChange} - disabled={disabled} - viewport={viewport} - onViewportChange={this.onViewportChange} - mapboxApiAccessToken={payload.data.mapboxApiKey} - mapStyle={formData.mapbox_style} - setControlValue={setControlValue} - aggregation - > - {formData.metric !== null && - <Legend - categories={buckets} - position={formData.legend_position} - format={formData.legend_format} - />} - </AnimatableDeckGLContainer> - </div> - ); - } -} - -DeckGLPolygon.propTypes = propTypes; -DeckGLPolygon.defaultProps = defaultProps; - -export default DeckGLPolygon; diff --git a/superset/assets/src/visualizations/deckgl/layers/Polygon/PolygonChartPlugin.js b/superset/assets/src/visualizations/deckgl/layers/Polygon/PolygonChartPlugin.js deleted file mode 100644 index 4b5f7c0..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Polygon/PolygonChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl Polygon'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class PolygonChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Polygon.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Polygon/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/layers/Polygon/images/thumbnail.png deleted file mode 100644 index b32c540..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Polygon/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Polygon/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/layers/Polygon/images/thumbnailLarge.png deleted file mode 100644 index dfae861..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Polygon/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Scatter/Scatter.jsx b/superset/assets/src/visualizations/deckgl/layers/Scatter/Scatter.jsx deleted file mode 100644 index 42dd7c8..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Scatter/Scatter.jsx +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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 { ScatterplotLayer } from 'deck.gl'; -import React from 'react'; -import { t } from '@superset-ui/translation'; -import { commonLayerProps } from '../common'; -import { createCategoricalDeckGLComponent } from '../../factory'; -import TooltipRow from '../../TooltipRow'; -import { unitToRadius } from '../../../../modules/geo'; - -function getPoints(data) { - return data.map(d => d.position); -} - -function setTooltipContent(formData) { - return o => ( - <div className="deckgl-tooltip"> - <TooltipRow label={`${t('Longitude and Latitude')}: `} value={`${o.object.position[0]}, ${o.object.position[1]}`} /> - { - o.object.cat_color && <TooltipRow label={`${t('Category')}: `} value={`${o.object.cat_color}`} /> - } - { - o.object.metric && <TooltipRow label={`${formData.point_radius_fixed.value.label}: `} value={`${o.object.metric}`} /> - } - </div> - ); -} - -export function getLayer(formData, payload, onAddFilter, setTooltip) { - const fd = formData; - const dataWithRadius = payload.data.features.map((d) => { - let radius = unitToRadius(fd.point_unit, d.radius) || 10; - if (fd.multiplier) { - radius *= fd.multiplier; - } - if (d.color) { - return { ...d, radius }; - } - const c = fd.color_picker || { r: 0, g: 0, b: 0, a: 1 }; - const color = [c.r, c.g, c.b, c.a * 255]; - return { ...d, radius, color }; - }); - - return new ScatterplotLayer({ - id: `scatter-layer-${fd.slice_id}`, - data: dataWithRadius, - fp64: true, - radiusMinPixels: fd.min_radius || null, - radiusMaxPixels: fd.max_radius || null, - outline: false, - ...commonLayerProps(fd, setTooltip, setTooltipContent(fd)), - }); -} - -export default createCategoricalDeckGLComponent(getLayer, getPoints); diff --git a/superset/assets/src/visualizations/deckgl/layers/Scatter/ScatterChartPlugin.js b/superset/assets/src/visualizations/deckgl/layers/Scatter/ScatterChartPlugin.js deleted file mode 100644 index 093a751..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Scatter/ScatterChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl Scatterplot'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class ScatterChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Scatter.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Scatter/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/layers/Scatter/images/thumbnail.png deleted file mode 100644 index a111a15..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Scatter/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Scatter/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/layers/Scatter/images/thumbnailLarge.png deleted file mode 100644 index 11f38cc..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Scatter/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Screengrid/Screengrid.jsx b/superset/assets/src/visualizations/deckgl/layers/Screengrid/Screengrid.jsx deleted file mode 100644 index d9fba4c..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Screengrid/Screengrid.jsx +++ /dev/null @@ -1,202 +0,0 @@ -/** - * 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. - */ -/* eslint no-underscore-dangle: ["error", { "allow": ["", "__timestamp"] }] */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { ScreenGridLayer } from 'deck.gl'; -import { t } from '@superset-ui/translation'; -import AnimatableDeckGLContainer from '../../AnimatableDeckGLContainer'; -import { getPlaySliderParams } from '../../../../modules/time'; -import sandboxedEval from '../../../../modules/sandbox'; -import { commonLayerProps, fitViewport } from '../common'; -import TooltipRow from '../../TooltipRow'; - -function getPoints(data) { - return data.map(d => d.position); -} - -function setTooltipContent(o) { - return ( - <div className="deckgl-tooltip"> - <TooltipRow label={`${t('Longitude and Latitude')}: `} value={`${o.object.position[0]}, ${o.object.position[1]}`} /> - <TooltipRow label={`${t('Weight')}: `} value={`${o.object.weight}`} /> - </div> - ); -} - -export function getLayer(formData, payload, onAddFilter, setTooltip, selected, onSelect, filters) { - const fd = formData; - const c = fd.color_picker; - let data = payload.data.features.map(d => ({ - ...d, - color: [c.r, c.g, c.b, 255 * c.a], - })); - - if (fd.js_data_mutator) { - // Applying user defined data mutator if defined - const jsFnMutator = sandboxedEval(fd.js_data_mutator); - data = jsFnMutator(data); - } - - if (filters != null) { - filters.forEach((f) => { - data = data.filter(f); - }); - } - - // Passing a layer creator function instead of a layer since the - // layer needs to be regenerated at each render - return new ScreenGridLayer({ - id: `screengrid-layer-${fd.slice_id}`, - data, - pickable: true, - cellSizePixels: fd.grid_size, - minColor: [c.r, c.g, c.b, 0], - maxColor: [c.r, c.g, c.b, 255 * c.a], - outline: false, - getWeight: d => d.weight || 0, - ...commonLayerProps(fd, setTooltip, setTooltipContent), - }); -} - -const propTypes = { - formData: PropTypes.object.isRequired, - payload: PropTypes.object.isRequired, - setControlValue: PropTypes.func.isRequired, - viewport: PropTypes.object.isRequired, - onAddFilter: PropTypes.func, - setTooltip: PropTypes.func, -}; -const defaultProps = { - onAddFilter() {}, - setTooltip() {}, -}; - -class DeckGLScreenGrid extends React.PureComponent { - constructor(props) { - super(props); - - this.state = DeckGLScreenGrid.getDerivedStateFromProps(props); - - this.getLayers = this.getLayers.bind(this); - this.onValuesChange = this.onValuesChange.bind(this); - this.onViewportChange = this.onViewportChange.bind(this); - } - static getDerivedStateFromProps(props, state) { - // the state is computed only from the payload; if it hasn't changed, do - // not recompute state since this would reset selections and/or the play - // slider position due to changes in form controls - if (state && props.payload.form_data === state.formData) { - return null; - } - - const features = props.payload.data.features || []; - const timestamps = features.map(f => f.__timestamp); - - // the granularity has to be read from the payload form_data, not the - // props formData which comes from the instantaneous controls state - const granularity = ( - props.payload.form_data.time_grain_sqla || - props.payload.form_data.granularity || - 'P1D' - ); - - const { - start, - end, - getStep, - values, - disabled, - } = getPlaySliderParams(timestamps, granularity); - - const viewport = props.formData.autozoom - ? fitViewport(props.viewport, getPoints(features)) - : props.viewport; - - return { - start, - end, - getStep, - values, - disabled, - viewport, - selected: [], - lastClick: 0, - formData: props.payload.form_data, - }; - } - onValuesChange(values) { - this.setState({ - values: Array.isArray(values) - ? values - : [values, values + this.state.getStep(values)], - }); - } - onViewportChange(viewport) { - this.setState({ viewport }); - } - getLayers(values) { - const filters = []; - - // time filter - if (values[0] === values[1] || values[1] === this.end) { - filters.push(d => d.__timestamp >= values[0] && d.__timestamp <= values[1]); - } else { - filters.push(d => d.__timestamp >= values[0] && d.__timestamp < values[1]); - } - - const layer = getLayer( - this.props.formData, - this.props.payload, - this.props.onAddFilter, - this.props.setTooltip, - filters); - - return [layer]; - } - - render() { - const { formData, payload, setControlValue } = this.props; - return ( - <div> - <AnimatableDeckGLContainer - getLayers={this.getLayers} - start={this.state.start} - end={this.state.end} - getStep={this.state.getStep} - values={this.state.values} - onValuesChange={this.onValuesChange} - disabled={this.state.disabled} - viewport={this.state.viewport} - onViewportChange={this.onViewportChange} - mapboxApiAccessToken={payload.data.mapboxApiKey} - mapStyle={formData.mapbox_style} - setControlValue={setControlValue} - aggregation - /> - </div> - ); - } -} - -DeckGLScreenGrid.propTypes = propTypes; -DeckGLScreenGrid.defaultProps = defaultProps; - -export default DeckGLScreenGrid; diff --git a/superset/assets/src/visualizations/deckgl/layers/Screengrid/ScreengridChartPlugin.js b/superset/assets/src/visualizations/deckgl/layers/Screengrid/ScreengridChartPlugin.js deleted file mode 100644 index dc96758..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/Screengrid/ScreengridChartPlugin.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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 } from '@superset-ui/translation'; -import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; -import thumbnail from './images/thumbnail.png'; -import transformProps from '../../transformProps'; - -const metadata = new ChartMetadata({ - name: t('deck.gl Screen Grid'), - description: '', - credits: ['https://uber.github.io/deck.gl'], - thumbnail, -}); - -export default class ScreengridChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - loadChart: () => import('./Screengrid.jsx'), - transformProps, - }); - } -} diff --git a/superset/assets/src/visualizations/deckgl/layers/Screengrid/images/thumbnail.png b/superset/assets/src/visualizations/deckgl/layers/Screengrid/images/thumbnail.png deleted file mode 100644 index 78a26e6..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Screengrid/images/thumbnail.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/Screengrid/images/thumbnailLarge.png b/superset/assets/src/visualizations/deckgl/layers/Screengrid/images/thumbnailLarge.png deleted file mode 100644 index d5da29c..0000000 Binary files a/superset/assets/src/visualizations/deckgl/layers/Screengrid/images/thumbnailLarge.png and /dev/null differ diff --git a/superset/assets/src/visualizations/deckgl/layers/common.jsx b/superset/assets/src/visualizations/deckgl/layers/common.jsx deleted file mode 100644 index aaee553..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/common.jsx +++ /dev/null @@ -1,155 +0,0 @@ -/** - * 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 { fitBounds } from 'viewport-mercator-project'; -import * as d3array from 'd3-array'; -import sandboxedEval from '../../../modules/sandbox'; - -const PADDING = 0.25; -const GEO_BOUNDS = { - LAT_MIN: -90, - LAT_MAX: 90, - LNG_MIN: -180, - LNG_MAX: 180, -}; - -/** - * Get the latitude bounds if latitude is a single coordinate - * @param latExt Latitude range - */ -function getLatBoundsForSingleCoordinate(latExt) { - const latMin = latExt[0] - PADDING < GEO_BOUNDS.LAT_MIN - ? GEO_BOUNDS.LAT_MIN - : latExt[0] - PADDING; - const latMax = latExt[1] + PADDING > GEO_BOUNDS.LAT_MAX - ? GEO_BOUNDS.LAT_MAX - : latExt[1] + PADDING; - return [latMin, latMax]; -} - -/** - * Get the longitude bounds if longitude is a single coordinate - * @param lngExt Longitude range - */ -function getLngBoundsForSingleCoordinate(lngExt) { - const lngMin = lngExt[0] - PADDING < GEO_BOUNDS.LNG_MIN - ? GEO_BOUNDS.LNG_MIN - : lngExt[0] - PADDING; - const lngMax = lngExt[1] + PADDING > GEO_BOUNDS.LNG_MAX - ? GEO_BOUNDS.LNG_MAX - : lngExt[1] + PADDING; - return [lngMin, lngMax]; -} - -export function getBounds(points) { - const latExt = d3array.extent(points, d => d[1]); - const lngExt = d3array.extent(points, d => d[0]); - const latBounds = latExt[0] === latExt[1] ? getLatBoundsForSingleCoordinate(latExt) : latExt; - const lngBounds = lngExt[0] === lngExt[1] ? getLngBoundsForSingleCoordinate(lngExt) : lngExt; - return [ - [lngBounds[0], latBounds[0]], - [lngBounds[1], latBounds[1]], - ]; -} - -export function fitViewport(viewport, points, padding = 10) { - try { - const bounds = getBounds(points); - return { - ...viewport, - ...fitBounds({ - height: viewport.height, - width: viewport.width, - padding, - bounds, - }), - }; - } catch (e) { - /* eslint no-console: 0 */ - console.error('Could not auto zoom', e); - return viewport; - } -} - -export function commonLayerProps(formData, setTooltip, setTooltipContent, onSelect) { - const fd = formData; - let onHover; - let tooltipContentGenerator = setTooltipContent; - if (fd.js_tooltip) { - tooltipContentGenerator = sandboxedEval(fd.js_tooltip); - } - if (tooltipContentGenerator) { - onHover = (o) => { - if (o.picked) { - setTooltip({ - content: tooltipContentGenerator(o), - x: o.x, - y: o.y + 30, - }); - } else { - setTooltip(null); - } - }; - } - let onClick; - if (fd.js_onclick_href) { - onClick = (o) => { - const href = sandboxedEval(fd.js_onclick_href)(o); - window.open(href); - }; - } else if (fd.table_filter && onSelect !== undefined) { - onClick = o => onSelect(o.object[fd.line_column]); - } - return { - onClick, - onHover, - pickable: Boolean(onHover), - }; -} - -const percentiles = { - p1: 0.01, - p5: 0.05, - p95: 0.95, - p99: 0.99, -}; - -/* Get an a stat function that operates on arrays, aligns with control=js_agg_function */ -export function getAggFunc(type = 'sum', accessor = null) { - if (type === 'count') { - return arr => arr.length; - } - let d3func; - if (type in percentiles) { - d3func = (arr, acc) => { - let sortedArr; - if (accessor) { - sortedArr = arr.sort((o1, o2) => d3array.ascending(accessor(o1), accessor(o2))); - } else { - sortedArr = arr.sort(d3array.ascending); - } - return d3array.quantile(sortedArr, percentiles[type], acc); - }; - } else { - d3func = d3array[type]; - } - if (!accessor) { - return arr => d3func(arr); - } - return arr => d3func(arr.map(accessor)); -} diff --git a/superset/assets/src/visualizations/deckgl/layers/index.js b/superset/assets/src/visualizations/deckgl/layers/index.js deleted file mode 100644 index b77d5bd..0000000 --- a/superset/assets/src/visualizations/deckgl/layers/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * 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. - */ -/* eslint camelcase: 0 */ -import { getLayer as deck_grid } from './Grid/Grid'; -import { getLayer as deck_screengrid } from './Screengrid/Screengrid'; -import { getLayer as deck_path } from './Path/Path'; -import { getLayer as deck_hex } from './Hex/Hex'; -import { getLayer as deck_scatter } from './Scatter/Scatter'; -import { getLayer as deck_geojson } from './Geojson/Geojson'; -import { getLayer as deck_arc } from './Arc/Arc'; -import { getLayer as deck_polygon } from './Polygon/Polygon'; - -const layerGenerators = { - deck_grid, - deck_screengrid, - deck_path, - deck_hex, - deck_scatter, - deck_geojson, - deck_arc, - deck_polygon, -}; - -export default layerGenerators; diff --git a/superset/assets/src/visualizations/deckgl/transformProps.js b/superset/assets/src/visualizations/deckgl/transformProps.js deleted file mode 100644 index 9e7350b..0000000 --- a/superset/assets/src/visualizations/deckgl/transformProps.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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. - */ -const NOOP = () => {}; - -export default function transformProps(chartProps) { - const { - width, - height, - rawFormData, - queryData, - hooks, - } = chartProps; - const { onAddFilter = NOOP, setControlValue = NOOP, setTooltip = NOOP } = hooks; - - return { - formData: rawFormData, - payload: queryData, - setControlValue, - viewport: { - ...rawFormData.viewport, - width, - height, - }, - onAddFilter, - setTooltip, - }; -} diff --git a/superset/assets/src/visualizations/deckgl/utils.js b/superset/assets/src/visualizations/deckgl/utils.js deleted file mode 100644 index 62024ef..0000000 --- a/superset/assets/src/visualizations/deckgl/utils.js +++ /dev/null @@ -1,122 +0,0 @@ -/** - * 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 { extent } from 'd3-array'; -import { scaleThreshold } from 'd3-scale'; -import { getSequentialSchemeRegistry, SequentialScheme } from '@superset-ui/color'; -import { hexToRGB } from '../../modules/colors'; - -const DEFAULT_NUM_BUCKETS = 10; - -export function getBreakPoints({ - break_points: formDataBreakPoints, - num_buckets: formDataNumBuckets, - }, features, accessor) { - if (!features) { - return []; - } - if (formDataBreakPoints === undefined || formDataBreakPoints.length === 0) { - // compute evenly distributed break points based on number of buckets - const numBuckets = formDataNumBuckets ? parseInt(formDataNumBuckets, 10) : DEFAULT_NUM_BUCKETS; - const [minValue, maxValue] = extent(features, accessor); - if (minValue === undefined) { - return []; - } - const delta = (maxValue - minValue) / numBuckets; - const precision = delta === 0 - ? 0 - : Math.max(0, Math.ceil(Math.log10(1 / delta))); - const extraBucket = maxValue > maxValue.toFixed(precision) ? 1 : 0; - return Array(numBuckets + 1 + extraBucket) - .fill() - .map((_, i) => (minValue + i * delta).toFixed(precision)); - } - return formDataBreakPoints.sort((a, b) => parseFloat(a) - parseFloat(b)); -} - -export function getBreakPointColorScaler({ - break_points: formDataBreakPoints, - num_buckets: formDataNumBuckets, - linear_color_scheme: linearColorScheme, - opacity, - }, features, accessor) { - const breakPoints = formDataBreakPoints || formDataNumBuckets - ? getBreakPoints({ - break_points: formDataBreakPoints, - num_buckets: formDataNumBuckets, - }, features, accessor) - : null; - const colorScheme = Array.isArray(linearColorScheme) - ? new SequentialScheme({ - id: 'custom', - colors: linearColorScheme, - }) - : getSequentialSchemeRegistry().get(linearColorScheme); - - let scaler; - let maskPoint; - if (breakPoints !== null) { - // bucket colors into discrete colors - const n = breakPoints.length - 1; - const bucketedColors = n > 1 - ? colorScheme.getColors(n) - : [colorScheme.colors[colorScheme.colors.length - 1]]; - - // repeat ends - const first = bucketedColors[0]; - const last = bucketedColors[bucketedColors.length - 1]; - bucketedColors.unshift(first); - bucketedColors.push(last); - - const points = breakPoints.map(p => parseFloat(p)); - scaler = scaleThreshold().domain(points).range(bucketedColors); - maskPoint = value => value > breakPoints[n] || value < breakPoints[0]; - } else { - // interpolate colors linearly - scaler = colorScheme.createLinearScale(extent(features, accessor)); - maskPoint = () => false; - } - - return (d) => { - const v = accessor(d); - const c = hexToRGB(scaler(v)); - if (maskPoint(v)) { - c[3] = 0; - } else { - c[3] = (opacity / 100.0) * 255; - } - return c; - }; -} - -export function getBuckets(fd, features, accessor) { - const breakPoints = getBreakPoints(fd, features, accessor); - const colorScaler = getBreakPointColorScaler(fd, features, accessor); - const buckets = {}; - breakPoints.slice(1).forEach((value, i) => { - const range = breakPoints[i] + ' - ' + breakPoints[i + 1]; - const mid = 0.5 * (parseFloat(breakPoints[i]) + parseFloat(breakPoints[i + 1])); - // fix polygon doesn't show - const metricLabel = fd.metric ? fd.metric.label || fd.metric : null; - buckets[range] = { - color: colorScaler({ [metricLabel || fd.metric]: mid }), - enabled: true, - }; - }); - return buckets; -} diff --git a/superset/assets/src/visualizations/presets/DeckGLChartPreset.js b/superset/assets/src/visualizations/presets/DeckGLChartPreset.js deleted file mode 100644 index fe06ece..0000000 --- a/superset/assets/src/visualizations/presets/DeckGLChartPreset.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * 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 { Preset } from '@superset-ui/core'; -import ArcChartPlugin from '../deckgl/layers/Arc/ArcChartPlugin'; -import GeoJsonChartPlugin from '../deckgl/layers/Geojson/GeojsonChartPlugin'; -import GridChartPlugin from '../deckgl/layers/Grid/GridChartPlugin'; -import HexChartPlugin from '../deckgl/layers/Hex/HexChartPlugin'; -import MultiChartPlugin from '../deckgl/Multi/MultiChartPlugin'; -import PathChartPlugin from '../deckgl/layers/Path/PathChartPlugin'; -import PolygonChartPlugin from '../deckgl/layers/Polygon/PolygonChartPlugin'; -import ScatterChartPlugin from '../deckgl/layers/Scatter/ScatterChartPlugin'; -import ScreengridChartPlugin from '../deckgl/layers/Screengrid/ScreengridChartPlugin'; - -export default class DeckGLChartPreset extends Preset { - constructor() { - super({ - name: 'deck.gl charts', - plugins: [ - new ArcChartPlugin().configure({ key: 'deck_arc' }), - new GeoJsonChartPlugin().configure({ key: 'deck_geojson' }), - new GridChartPlugin().configure({ key: 'deck_grid' }), - new HexChartPlugin().configure({ key: 'deck_hex' }), - new MultiChartPlugin().configure({ key: 'deck_multi' }), - new PathChartPlugin().configure({ key: 'deck_path' }), - new PolygonChartPlugin().configure({ key: 'deck_polygon' }), - new ScatterChartPlugin().configure({ key: 'deck_scatter' }), - new ScreengridChartPlugin().configure({ key: 'deck_screengrid' }), - ], - }); - } -} diff --git a/superset/assets/src/visualizations/presets/MainPreset.js b/superset/assets/src/visualizations/presets/MainPreset.js index 9dc3f81..3ea5592 100644 --- a/superset/assets/src/visualizations/presets/MainPreset.js +++ b/superset/assets/src/visualizations/presets/MainPreset.js @@ -49,8 +49,7 @@ import { AreaChartPlugin, BarChartPlugin, BubbleChartPlugin, BulletChartPlugin, CompareChartPlugin, DistBarChartPlugin, DualLineChartPlugin, LineChartPlugin, LineMultiChartPlugin, PieChartPlugin, TimePivotChartPlugin } from '@superset-ui/legacy-preset-chart-nvd3/lib'; import { BoxPlotChartPlugin } from '@superset-ui/preset-chart-xy/esm/legacy'; - -import DeckGLChartPreset from './DeckGLChartPreset'; +import { DeckGLChartPreset } from '@superset-ui/legacy-preset-chart-deckgl'; import FilterBoxChartPlugin from '../FilterBox/FilterBoxChartPlugin'; import TimeTableChartPlugin from '../TimeTable/TimeTableChartPlugin'; diff --git a/superset/assets/src/visualizations/stylesheets/deckgl.css b/superset/assets/src/visualizations/stylesheets/deckgl.css deleted file mode 100644 index b085d1c..0000000 --- a/superset/assets/src/visualizations/stylesheets/deckgl.css +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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. - */ - .deckgl-tooltip > div { - overflow: hidden; - text-overflow: ellipsis; - }