diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-time-table/Stories.tsx b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-time-table/Stories.tsx deleted file mode 100644 index 73b19eadf152f..0000000000000 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-time-table/Stories.tsx +++ /dev/null @@ -1,74 +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-disable no-magic-numbers */ -import React from 'react'; -import { SuperChart } from '@superset-ui/core'; -import TimeTableChartPlugin from '@superset-ui/legacy-plugin-chart-time-table'; -import data from './data'; - -new TimeTableChartPlugin().configure({ key: 'time-table' }).register(); - -export default { - title: 'Legacy Chart Plugins/legacy-plugin-chart-time-table', -}; - -export const basic = () => ( - -); diff --git a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-time-table/data.ts b/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-time-table/data.ts deleted file mode 100644 index b9990d59255ce..0000000000000 --- a/superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/legacy-plugin-chart-time-table/data.ts +++ /dev/null @@ -1,230 +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. - */ -export default { - '1980-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 88, - 'Sub-Saharan Africa': 92, - }, - '1981-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 98, - 'Middle East & North Africa': 80, - 'Sub-Saharan Africa': 96, - }, - '1982-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 89, - 'Sub-Saharan Africa': 94, - }, - '1983-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 88, - 'Sub-Saharan Africa': 98, - }, - '1984-01-01 00:00:00': { - 'East Asia & Pacific': 97, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 91, - 'Sub-Saharan Africa': 98, - }, - '1985-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 94, - 'Sub-Saharan Africa': 97, - }, - '1986-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 98, - 'Sub-Saharan Africa': 99, - }, - '1987-01-01 00:00:00': { - 'East Asia & Pacific': 98, - 'Latin America & Caribbean': 98, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '1988-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 98, - 'Sub-Saharan Africa': 99, - }, - '1989-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 98, - 'Sub-Saharan Africa': 99, - }, - '1990-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '1991-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 98, - 'Sub-Saharan Africa': 99, - }, - '1992-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '1993-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '1994-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '1995-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '1996-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 98, - 'Sub-Saharan Africa': 99, - }, - '1997-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '1998-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '1999-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2000-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2001-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2002-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2003-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2004-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2005-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2006-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2007-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2008-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2009-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2010-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2011-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2012-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2013-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, - '2014-01-01 00:00:00': { - 'East Asia & Pacific': 99, - 'Latin America & Caribbean': 99, - 'Middle East & North Africa': 99, - 'Sub-Saharan Africa': 99, - }, -}; diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/CHANGELOG.md b/superset-frontend/plugins/legacy-plugin-chart-time-table/CHANGELOG.md deleted file mode 100644 index 2cb283c0a4146..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/CHANGELOG.md +++ /dev/null @@ -1,43 +0,0 @@ - - -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [0.18.0](https://github.com/apache-superset/superset-ui/compare/v0.17.87...v0.18.0) (2021-08-30) - -**Note:** Version bump only for package @superset-ui/legacy-plugin-chart-time-table - - - - - -## [0.17.63](https://github.com/apache-superset/superset-ui/compare/v0.17.62...v0.17.63) (2021-07-02) - -**Note:** Version bump only for package @superset-ui/legacy-plugin-chart-time-table - - - - - -## [0.17.61](https://github.com/apache-superset/superset-ui/compare/v0.17.60...v0.17.61) (2021-07-02) - -**Note:** Version bump only for package @superset-ui/legacy-plugin-chart-time-table diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/README.md b/superset-frontend/plugins/legacy-plugin-chart-time-table/README.md deleted file mode 100644 index 5b3a95dd0a0ca..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/README.md +++ /dev/null @@ -1,52 +0,0 @@ - - -## @superset-ui/plugin-chart-time-table - -[![Version](https://img.shields.io/npm/v/@superset-ui/plugin-time-table.svg?style=flat-square)](https://www.npmjs.com/package/@superset-ui/plugin-chart-time-table) -[![David (path)](https://img.shields.io/david/apache-superset/superset-ui-plugins.svg?path=packages%2Fsuperset-ui-plugin-chart-time-table&style=flat-square)](https://david-dm.org/apache-superset/superset-ui-plugins?path=packages/superset-ui-plugin-chart-time-table) - -This plugin provides Time Table for Superset. - -### Usage - -Configure `key`, which can be any `string`, and register the plugin. This `key` will be used to -lookup this chart throughout the app. - -```js -import TimeTableChartPlugin from '@superset-ui/legacy-plugin-chart-time-table'; - -new TimeTableChartPlugin().configure({ key: 'time-table' }).register(); -``` - -Then use it via `SuperChart`. See -[storybook](https://apache-superset.github.io/superset-ui-plugins/?selectedKind=plugin-chart-time-table) -for more details. - -```js - -``` diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/package.json b/superset-frontend/plugins/legacy-plugin-chart-time-table/package.json deleted file mode 100644 index 635f1b8865c64..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "@superset-ui/legacy-plugin-chart-time-table", - "version": "0.18.25", - "description": "Superset Chart Plugin - Time Table", - "sideEffects": [ - "*.css" - ], - "main": "lib/index.js", - "module": "esm/index.js", - "files": [ - "esm", - "lib" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/apache-superset/superset-ui.git" - }, - "keywords": [ - "superset" - ], - "author": "Superset", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/apache-superset/superset-ui/issues" - }, - "homepage": "https://github.com/apache-superset/superset-ui#readme", - "publishConfig": { - "access": "public" - }, - "dependencies": { - "@data-ui/sparkline": "^0.0.84", - "@superset-ui/chart-controls": "0.18.25", - "@superset-ui/core": "0.18.25", - "@types/d3-scale": "^2.0.2", - "d3-scale": "^3.2.1", - "moment": "^2.26.0", - "mustache": "^4.0.1", - "prop-types": "^15.7.2", - "reactable-arc": "^0.15.0" - }, - "peerDependencies": { - "@types/react": "*", - "react": "^16.3.1" - } -} diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/FormattedNumber.tsx b/superset-frontend/plugins/legacy-plugin-chart-time-table/src/FormattedNumber.tsx deleted file mode 100644 index 249aa28508e00..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/FormattedNumber.tsx +++ /dev/null @@ -1,34 +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 { formatNumber } from '@superset-ui/core'; - -interface Props { - format: string; - num: number; -} - -function FormattedNumber({ num = 0, format = '' }: Props) { - if (format) { - return {formatNumber(format, num)}; - } - return {num}; -} - -export default FormattedNumber; diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/TimeTable.tsx b/superset-frontend/plugins/legacy-plugin-chart-time-table/src/TimeTable.tsx deleted file mode 100644 index 20076e1268da5..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/TimeTable.tsx +++ /dev/null @@ -1,330 +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 Mustache from 'mustache'; -import { scaleLinear } from 'd3-scale'; -import { Table, Thead, Th, Tr, Td } from 'reactable-arc'; -import { formatNumber, formatTime, styled } from '@superset-ui/core'; -import { - InfoTooltipWithTrigger, - MetricOption, -} from '@superset-ui/chart-controls'; -import moment from 'moment'; - -import FormattedNumber from './FormattedNumber'; -import SparklineCell from './SparklineCell'; - -const ACCESSIBLE_COLOR_BOUNDS = ['#ca0020', '#0571b0']; -interface ColorFromBoundProps { - value: number; - bounds: Array; - colorBounds: Array; -} -function colorFromBounds( - value: number, - bounds: number[], - colorBounds = ACCESSIBLE_COLOR_BOUNDS, -): ColorFromBoundProps | null { - if (bounds) { - const [min, max] = bounds; - const [minColor, maxColor] = colorBounds; - if (min !== null && max !== null) { - const colorScale = scaleLinear() - .domain([min, (max + min) / 2, max]) - // @ts-ignore - .range([minColor, 'grey', maxColor]); - - // @ts-ignore - return colorScale(value); - } - if (min !== null) { - // @ts-ignore - return value >= min ? maxColor : minColor; - } - if (max !== null) { - // @ts-ignore - return value < max ? maxColor : minColor; - } - } - return null; -} - -interface ColumnConfigProps { - colType: string; - comparisonType: string; - d3format: string; - key: string; - label: string; - timeLag: number; - tooltip: any; - bounds: number[]; - dateFormat: string; - width: string; - height: string; - yAxisBounds: number[]; - showYAxis: boolean; - timeRatio: number; -} - -interface RowData { - label: string; - // eslint-disable-next-line camelcase - metric_name: string; -} - -interface ChartProps { - className: string | undefined; - columnConfigs: Array; - data: object; - height: number; - rows: Array; - rowType: string; - url: string; - row: Array; -} -interface Entry { - [key: string]: number; -} - -class TimeTable extends React.PureComponent { - renderLeftCell(row: RowData) { - const { rowType, url } = this.props; - const context = { metric: row }; - const fullUrl = url ? Mustache.render(url, context) : null; - - if (rowType === 'column') { - const column = row; - if (fullUrl) { - return ( - - {column.label} - - ); - } - return column.label; - } - - return ( - - ); - } - - // eslint-disable-next-line class-methods-use-this - renderSparklineCell( - valueField: string, - column: ColumnConfigProps, - entries: Entry[], - ) { - let sparkData: number[]; - if (column.timeRatio) { - // Period ratio sparkline - sparkData = []; - for (let i = column.timeRatio; i < entries.length; i += 1) { - const prevData = entries[i - column.timeRatio][valueField]; - if (prevData && prevData !== 0) { - sparkData.push(entries[i][valueField] / prevData); - } else { - // @ts-ignore - sparkData.push(null); - } - } - } else { - sparkData = entries.map(d => d[valueField]); - } - - return ( - - ( -
- {formatNumber(column.d3format, sparkData[index])} -
- {formatTime( - column.dateFormat, - moment.utc(entries[index].time).toDate(), - )} -
-
- )} - /> - - ); - } - - // eslint-disable-next-line class-methods-use-this - renderValueCell( - valueField: string, - column: ColumnConfigProps, - reversedEntries: Entry[], - ) { - const recent = reversedEntries[0][valueField]; - let v = 0; - let errorMsg; - if (column.colType === 'time') { - // Time lag ratio - const timeLag = column.timeLag || 0; - const totalLag = Object.keys(reversedEntries).length; - if (timeLag >= totalLag) { - errorMsg = `The time lag set at ${timeLag} is too large for the length of data at ${reversedEntries.length}. No data available.`; - } else { - v = reversedEntries[timeLag][valueField]; - } - if (column.comparisonType === 'diff') { - v = recent - v; - } else if (column.comparisonType === 'perc') { - v = recent / v; - } else if (column.comparisonType === 'perc_change') { - v = recent / v - 1; - } - v = v || 0; - } else if (column.colType === 'contrib') { - // contribution to column total - v = - recent / - Object.keys(reversedEntries[0]) - .map(k => (k === 'time' ? 0 : reversedEntries[0][k])) - .reduce((a, b) => a + b); - } else if (column.colType === 'avg') { - // Average over the last {timeLag} - v = - reversedEntries - .map((k: Entry, i: number) => - i < column.timeLag ? k[valueField] : 0, - ) - .reduce((a: number, b: number) => a + b) / column.timeLag; - } - - const color = colorFromBounds(v, column.bounds); - - return ( - - {errorMsg ? ( -
{errorMsg}
- ) : ( - // @ts-ignore -
- -
- )} - - ); - } - - renderRow(row: RowData, entries: Entry[], reversedEntries: Entry[]) { - const { columnConfigs } = this.props; - const valueField: string = row.label || row.metric_name; - const leftCell = this.renderLeftCell(row); - return ( - - - {leftCell} - - {columnConfigs.map(c => - c.colType === 'spark' - ? this.renderSparklineCell(valueField, c, entries) - : this.renderValueCell(valueField, c, reversedEntries), - )} - - ); - } - - render() { - const { className, height, data, columnConfigs, rowType, rows } = - this.props; - const entries = Object.keys(data) - .sort() - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - .map(time => ({ ...data[time], time })); - - const reversedEntries = entries.concat().reverse(); - - const defaultSort = - rowType === 'column' && columnConfigs.length > 0 - ? { - column: columnConfigs[0].key, - direction: 'desc', - } - : false; - - return ( -
- c.key)} - > - - - {columnConfigs.map((c, i) => ( - - ))} - - {rows.map(row => this.renderRow(row, entries, reversedEntries))} -
Metric - {c?.label}{' '} - {c?.tooltip && ( - - )} -
-
- ); - } -} - -export default styled(TimeTable)` - .time-table { - overflow: auto; - } -`; diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/TimeTableChartPlugin.ts b/superset-frontend/plugins/legacy-plugin-chart-time-table/src/TimeTableChartPlugin.ts deleted file mode 100644 index ef1933bfcda95..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/TimeTableChartPlugin.ts +++ /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, ChartMetadata, ChartPlugin } from '@superset-ui/core'; -import transformProps from './transformProps'; -import thumbnail from './images/thumbnail.png'; - -const metadata = new ChartMetadata({ - name: t('Time-series Table'), - description: '', - thumbnail, - useLegacyApi: true, -}); - -export default class TimeTableChartPlugin extends ChartPlugin { - constructor() { - super({ - metadata, - // @ts-ignore - transformProps, - loadChart: () => import('./TimeTable'), - }); - } -} diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/controlPanel.ts b/superset-frontend/plugins/legacy-plugin-chart-time-table/src/controlPanel.ts deleted file mode 100644 index 941bd1fe0dcc1..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/controlPanel.ts +++ /dev/null @@ -1,68 +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, validateNonEmpty } from '@superset-ui/core'; -import { ControlPanelConfig, sections } from '@superset-ui/chart-controls'; - -const config: ControlPanelConfig = { - controlPanelSections: [ - sections.legacyTimeseriesTime, - { - label: t('Query'), - expanded: true, - controlSetRows: [ - ['metrics'], - ['adhoc_filters'], - ['groupby'], - ['limit'], - [ - { - name: 'column_collection', - config: { - type: 'CollectionControl', - label: t('Time Series Columns'), - validators: [validateNonEmpty], - controlName: 'TimeSeriesColumnControl', - }, - }, - ], - [ - { - name: 'url', - config: { - type: 'TextControl', - label: t('URL'), - description: t( - "Templated link, it's possible to include {{ metric }} " + - 'or other values coming from the controls.', - ), - default: '', - }, - }, - ], - ], - }, - ], - controlOverrides: { - groupby: { - multiple: false, - }, - }, -}; - -export default config; diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/images/thumbnail.png b/superset-frontend/plugins/legacy-plugin-chart-time-table/src/images/thumbnail.png deleted file mode 100644 index 22c2ee2904390..0000000000000 Binary files a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/images/thumbnail.png and /dev/null differ diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/images/thumbnailLarge.png b/superset-frontend/plugins/legacy-plugin-chart-time-table/src/images/thumbnailLarge.png deleted file mode 100644 index 4dd4b925c7c1b..0000000000000 Binary files a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/images/thumbnailLarge.png and /dev/null differ diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/index.ts b/superset-frontend/plugins/legacy-plugin-chart-time-table/src/index.ts deleted file mode 100644 index 586524f506a99..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/index.ts +++ /dev/null @@ -1,52 +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, ChartMetadata, ChartPlugin } from '@superset-ui/core'; -import transformProps from './transformProps'; -import thumbnail from './images/thumbnail.png'; -import controlPanel from './controlPanel'; - -const metadata = new ChartMetadata({ - category: t('Table'), - name: t('Time-series Table'), - description: t( - 'Compare multiple time series charts (as sparklines) and related metrics quickly. ', - ), - tags: [ - t('Multi-Variables'), - t('Comparison'), - t('Legacy'), - t('Percentages'), - t('Tabular'), - t('Description'), - t('Trend'), - ], - thumbnail, - useLegacyApi: true, -}); -export default class TimeTableChartPlugin extends ChartPlugin { - constructor() { - super({ - loadChart: () => import('./TimeTable'), - metadata, - // @ts-ignore - transformProps, - controlPanel, - }); - } -} diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/tsconfig.json b/superset-frontend/plugins/legacy-plugin-chart-time-table/tsconfig.json deleted file mode 100644 index b6bfaa2d98446..0000000000000 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "declarationDir": "lib", - "outDir": "lib", - "rootDir": "src" - }, - "exclude": [ - "lib", - "test" - ], - "extends": "../../tsconfig.json", - "include": [ - "src/**/*", - "types/**/*", - "../../types/**/*" - ], - "references": [ - { - "path": "../../packages/superset-ui-chart-controls" - }, - { - "path": "../../packages/superset-ui-core" - } - ] -} diff --git a/superset-frontend/src/visualizations/TimeTable/SparklineCell.jsx b/superset-frontend/src/visualizations/TimeTable/SparklineCell.jsx deleted file mode 100644 index fc1e0077ee9c2..0000000000000 --- a/superset-frontend/src/visualizations/TimeTable/SparklineCell.jsx +++ /dev/null @@ -1,203 +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 { - Sparkline, - LineSeries, - PointSeries, - HorizontalReferenceLine, - VerticalReferenceLine, - WithTooltip, -} from '@data-ui/sparkline'; -import { getTextDimension, formatNumber } from '@superset-ui/core'; - -const propTypes = { - className: PropTypes.string, - width: PropTypes.number, - height: PropTypes.number, - data: PropTypes.array.isRequired, - ariaLabel: PropTypes.string, - numberFormat: PropTypes.string, - yAxisBounds: PropTypes.array, - showYAxis: PropTypes.bool, - renderTooltip: PropTypes.func, -}; -const defaultProps = { - className: '', - width: 300, - height: 50, - ariaLabel: '', - numberFormat: undefined, - yAxisBounds: [null, null], - showYAxis: false, - renderTooltip() { - return
; - }, -}; - -const MARGIN = { - top: 8, - right: 8, - bottom: 8, - left: 8, -}; -const tooltipProps = { - style: { - opacity: 0.8, - }, - offsetTop: 0, -}; - -function getSparklineTextWidth(text) { - return ( - getTextDimension({ - text, - style: { - fontSize: '12px', - fontWeight: 200, - letterSpacing: 0.4, - }, - }).width + 5 - ); -} - -function isValidBoundValue(value) { - return ( - value !== null && - value !== undefined && - value !== '' && - !Number.isNaN(value) - ); -} - -class SparklineCell extends React.Component { - renderHorizontalReferenceLine(value, label) { - return ( - label} - stroke="#bbb" - strokeDasharray="3 3" - strokeWidth={1} - /> - ); - } - - render() { - const { - width, - height, - data, - ariaLabel, - numberFormat, - yAxisBounds, - showYAxis, - renderTooltip, - } = this.props; - - const yScale = {}; - let hasMinBound = false; - let hasMaxBound = false; - - if (yAxisBounds) { - const [minBound, maxBound] = yAxisBounds; - hasMinBound = isValidBoundValue(minBound); - if (hasMinBound) { - yScale.min = minBound; - } - hasMaxBound = isValidBoundValue(maxBound); - if (hasMaxBound) { - yScale.max = maxBound; - } - } - - let min; - let max; - let minLabel; - let maxLabel; - let labelLength = 0; - if (showYAxis) { - const [minBound, maxBound] = yAxisBounds; - min = hasMinBound - ? minBound - : data.reduce((acc, current) => Math.min(acc, current), data[0]); - max = hasMaxBound - ? maxBound - : data.reduce((acc, current) => Math.max(acc, current), data[0]); - - minLabel = formatNumber(numberFormat, min); - maxLabel = formatNumber(numberFormat, max); - labelLength = Math.max( - getSparklineTextWidth(minLabel), - getSparklineTextWidth(maxLabel), - ); - } - - const margin = { - ...MARGIN, - right: MARGIN.right + labelLength, - }; - - return ( - - {({ onMouseLeave, onMouseMove, tooltipData }) => ( - - {showYAxis && this.renderHorizontalReferenceLine(min, minLabel)} - {showYAxis && this.renderHorizontalReferenceLine(max, maxLabel)} - - {tooltipData && ( - - )} - {tooltipData && ( - - )} - - )} - - ); - } -} - -SparklineCell.propTypes = propTypes; -SparklineCell.defaultProps = defaultProps; - -export default SparklineCell; diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/SparklineCell.tsx b/superset-frontend/src/visualizations/TimeTable/SparklineCell.tsx similarity index 100% rename from superset-frontend/plugins/legacy-plugin-chart-time-table/src/SparklineCell.tsx rename to superset-frontend/src/visualizations/TimeTable/SparklineCell.tsx diff --git a/superset-frontend/src/visualizations/TimeTable/TimeTableChartPlugin.js b/superset-frontend/src/visualizations/TimeTable/TimeTableChartPlugin.ts similarity index 100% rename from superset-frontend/src/visualizations/TimeTable/TimeTableChartPlugin.js rename to superset-frontend/src/visualizations/TimeTable/TimeTableChartPlugin.ts diff --git a/superset-frontend/src/visualizations/TimeTable/transformProps.js b/superset-frontend/src/visualizations/TimeTable/transformProps.js deleted file mode 100644 index 93e0e7df70aa8..0000000000000 --- a/superset-frontend/src/visualizations/TimeTable/transformProps.js +++ /dev/null @@ -1,62 +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. - */ -export default function transformProps(chartProps) { - const { height, datasource, formData, queriesData } = chartProps; - const { columnCollection = [], groupby, metrics, url } = formData; - const { records, columns } = queriesData[0].data; - const isGroupBy = groupby?.length > 0; - - // When there is a "group by", - // each row in the table is a database column - // Otherwise, - // each row in the table is a metric - let rows; - if (isGroupBy) { - rows = columns.map(column => - typeof column === 'object' ? column : { label: column }, - ); - } else { - const metricMap = datasource.metrics.reduce((acc, current) => { - const map = acc; - map[current.metric_name] = current; - return map; - }, {}); - - rows = metrics.map(metric => - typeof metric === 'object' ? metric : metricMap[metric], - ); - } - - // TODO: Better parse this from controls instead of mutative value here. - columnCollection.forEach(column => { - const c = column; - if (c.timeLag !== undefined && c.timeLag !== null && c.timeLag !== '') { - c.timeLag = parseInt(c.timeLag, 10); - } - }); - - return { - height, - data: records, - columnConfigs: columnCollection, - rows, - rowType: isGroupBy ? 'column' : 'metric', - url, - }; -} diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/transformProps.ts b/superset-frontend/src/visualizations/TimeTable/transformProps.ts similarity index 92% rename from superset-frontend/plugins/legacy-plugin-chart-time-table/src/transformProps.ts rename to superset-frontend/src/visualizations/TimeTable/transformProps.ts index 3db4362ed7f0c..f408cc21869da 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/src/transformProps.ts +++ b/superset-frontend/src/visualizations/TimeTable/transformProps.ts @@ -42,14 +42,13 @@ interface ColumnData { } export default function transformProps(chartProps: TableChartProps) { const { height, datasource, formData, queriesData } = chartProps; - const { columnCollection, groupby, metrics, url } = formData; + const { columnCollection = [], groupby, metrics, url } = formData; const { records, columns } = queriesData[0].data; const isGroupBy = groupby?.length > 0; // When there is a "group by", // each row in the table is a database column - // Otherwise,`` - // each row in the table is a metric + // Otherwise each row in the table is a metric let rows; if (isGroupBy) { rows = columns.map(column => @@ -58,9 +57,7 @@ export default function transformProps(chartProps: TableChartProps) { } else { const metricMap = datasource.metrics.reduce((acc, current) => { const map = acc; - if (current.metric_name) { - map[current.metric_name] = current; - } + map[current.metric_name] = current; return map; }, {} as Record); rows = metrics.map(metric => diff --git a/superset-frontend/plugins/legacy-plugin-chart-time-table/types/external.d.ts b/superset-frontend/src/visualizations/TimeTable/types.d.ts similarity index 90% rename from superset-frontend/plugins/legacy-plugin-chart-time-table/types/external.d.ts rename to superset-frontend/src/visualizations/TimeTable/types.d.ts index a9c7ec89cef8b..71ee4453d29a6 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-time-table/types/external.d.ts +++ b/superset-frontend/src/visualizations/TimeTable/types.d.ts @@ -1,4 +1,4 @@ -/* +/** * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -declare module '*.png'; declare module '@data-ui/sparkline'; -declare module 'reactable-arc'; -declare module 'mustache'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/.eslintrc.js b/superset-frontend/temporary_superset_ui/superset-ui/.eslintrc.js index 5a0a248331768..0ad67c24e17ee 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/.eslintrc.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/.eslintrc.js @@ -61,7 +61,6 @@ module.exports = { '@superset-ui/legacy-plugin-chart-sankey', '@superset-ui/legacy-plugin-chart-sankey-loop', '@superset-ui/legacy-plugin-chart-sunburst', - '@superset-ui/legacy-plugin-chart-time-table', '@superset-ui/legacy-plugin-chart-treemap', '@superset-ui/legacy-plugin-chart-world-map', '@superset-ui/legacy-preset-chart-big-number',