Skip to content

Commit 5e2e4ab

Browse files
authored
feat: migrate xy-chart to use encodable (apache-superset#438)
* feat: migrate xy-chart to use encodable (apache-superset#420) * feat: use encodable in BoxPlot * feat: migrate legend * docs: update storybook * fix: label overlap * fix: lint * fix: remove comments * fix: path * feat: migrate scatterplot to use encodable (apache-superset#421) * feat: migrate scatter plot (cherry picked from commit 0d607a6) * fix: legend * feat: migrate line chart to use encodable (apache-superset#427) * feat: migrate line to use encodable * fix: storybook ts * fix: remove comment * refactor: delete deprecated files (apache-superset#430) * refactor: delete outdated files * feat: update index exports and add test * refactor: delete more files * fix: import order * fix: update dependency * fix: update dependency * build: fix babel * fix: remvoe comments * fix: babel * refactor: move files (apache-superset#432) * refactor: move files * refactor: move files * fix: small issues with charts post-migration (apache-superset#433) * fix: scatterplot issue * fix: bump encodable and fix time scale nicing * fix: issue with label rotation * refactor: remove deep import * fix: demo import * feat: bump and remove unnecessary dependencies (apache-superset#436) * feat: bump dependencies * feat: remove unnecessary dependencies
1 parent 4f0b445 commit 5e2e4ab

File tree

80 files changed

+951
-2124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+951
-2124
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ test-changelog.md
3838
.eslintrc.js
3939
.flowconfig
4040
.prettierignore
41-
babel.config.js
4241
jest.config.js
4342
prettier.config.js
4443
tsconfig.eslint.json

babel.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// eslint-disable-next-line no-undef, import/no-extraneous-dependencies
2+
const { getConfig } = require('@airbnb/config-babel');
3+
4+
const config = getConfig({
5+
library: true,
6+
react: true,
7+
next: true,
8+
node: process.env.NODE_ENV === 'test',
9+
typescript: true,
10+
env: {
11+
targets: false,
12+
},
13+
});
14+
15+
if (process.env.NODE_ENV !== 'test') {
16+
config.presets[0][1].modules = false;
17+
}
18+
19+
// Override to allow transpile es modules inside vega-lite
20+
config.ignore = config.ignore.filter(item => item !== 'node_modules/');
21+
config.ignore.push('node_modules/(?!(vega-lite|lodash-es))');
22+
23+
// eslint-disable-next-line no-undef
24+
module.exports = config;

package.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"scripts": {
77
"build": "yarn babel && yarn type && yarn build:assets",
88
"babel": "yarn babel:cjs && yarn babel:esm",
9-
"babel:cjs": "nimbus babel --clean --workspaces=\"@superset-ui/!(plugins-demo)\"",
10-
"babel:esm": "nimbus babel --clean --workspaces=\"@superset-ui/!(plugins-demo)\" --esm",
9+
"babel:cjs": "nimbus babel --clean --workspaces=\"@superset-ui/!(plugins-demo)\" --config-file=../../babel.config.js",
10+
"babel:esm": "nimbus babel --clean --workspaces=\"@superset-ui/!(plugins-demo)\" --esm --config-file=../../babel.config.js",
1111
"build:assets": "node ./scripts/buildAssets.js",
1212
"clean": "rm -rf ./packages/**/{lib,esm}",
1313
"commit": "superset-commit",
@@ -42,14 +42,14 @@
4242
],
4343
"license": "Apache-2.0",
4444
"devDependencies": {
45-
"@airbnb/config-babel": "^2.1.3",
46-
"@airbnb/config-eslint": "^2.1.3",
47-
"@airbnb/config-jest": "^2.1.3",
48-
"@airbnb/config-prettier": "^2.0.4",
49-
"@airbnb/config-typescript": "^2.1.2",
50-
"@airbnb/nimbus": "^2.1.3",
45+
"@airbnb/config-babel": "^2.2.2",
46+
"@airbnb/config-eslint": "^2.5.1",
47+
"@airbnb/config-jest": "^2.2.2",
48+
"@airbnb/config-prettier": "^2.1.1",
49+
"@airbnb/config-typescript": "^2.2.2",
50+
"@airbnb/nimbus": "^2.2.3",
5151
"@superset-ui/commit-config": "^0.0.9",
52-
"@superset-ui/superset-ui": "^0.12.5",
52+
"@superset-ui/superset-ui": "^0.12.15",
5353
"@types/enzyme": "^3.10.3",
5454
"@types/jest": "^25.1.3",
5555
"@types/jsdom": "^12.2.4",
@@ -86,7 +86,7 @@
8686
],
8787
"nimbus": {
8888
"drivers": [
89-
"babel",
89+
{ "driver": "babel", "strategy": "none" },
9090
"eslint",
9191
"jest",
9292
"prettier",
@@ -106,6 +106,9 @@
106106
"@airbnb/config-jest/enzyme",
107107
"./scripts/setupJest.js"
108108
],
109+
"transformIgnorePatterns": [
110+
"node_modules/(?!(vega-lite|lodash-es))"
111+
],
109112
"coverageThreshold": {
110113
"global": {
111114
"branches": 1,

packages/superset-ui-plugin-chart-word-cloud/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@types/react": "^16.3.0",
3434
"d3-cloud": "^1.2.5",
3535
"d3-scale": "^3.0.1",
36-
"encodable": "^0.2.0"
36+
"encodable": "^0.3.3"
3737
},
3838
"peerDependencies": {
3939
"@superset-ui/chart": "^0.12.0",

packages/superset-ui-plugin-chart-word-cloud/src/chart/Encoder.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { createEncoderFactory } from 'encodable';
2-
import { DeriveEncoding } from 'encodable/lib/types/Encoding';
1+
import { createEncoderFactory, DeriveEncoding } from 'encodable';
32

43
type WordCloudEncodingConfig = {
54
color: ['Color', string];

packages/superset-ui-plugin-chart-word-cloud/src/chart/WordCloud.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import cloudLayout, { Word } from 'd3-cloud';
3-
import { PlainObject } from 'encodable/lib/types/Data';
3+
import { PlainObject } from 'encodable';
44
import { WordCloudEncoding, wordCloudEncoderFactory } from './Encoder';
55

66
export const ROTATION = {

packages/superset-ui-plugins-demo/storybook/stories/preset-chart-xy/BoxPlot/index.js renamed to packages/superset-ui-plugins-demo/storybook/stories/preset-chart-xy/BoxPlot/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { BoxPlotChartPlugin as LegacyBoxPlotChartPlugin } from '../../../../../superset-ui-preset-chart-xy/esm/legacy';
2-
import { BoxPlotChartPlugin } from '../../../../../superset-ui-preset-chart-xy';
1+
import {
2+
BoxPlotChartPlugin,
3+
LegacyBoxPlotChartPlugin,
4+
} from '../../../../../superset-ui-preset-chart-xy';
35
import Stories from './stories/Basic';
46
import LegacyStories from './stories/Legacy';
57
import { BOX_PLOT_PLUGIN_LEGACY_TYPE, BOX_PLOT_PLUGIN_TYPE } from './constants';

packages/superset-ui-plugins-demo/storybook/stories/preset-chart-xy/Line/index.js renamed to packages/superset-ui-plugins-demo/storybook/stories/preset-chart-xy/Line/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { LineChartPlugin as LegacyLineChartPlugin } from '../../../../../superset-ui-preset-chart-xy/esm/legacy';
2-
import { LineChartPlugin } from '../../../../../superset-ui-preset-chart-xy';
1+
import { LineChartPlugin, LegacyLineChartPlugin } from '../../../../../superset-ui-preset-chart-xy';
32
import BasicStories from './stories/basic';
43
import FlushStories from './stories/flush';
54
import QueryStories from './stories/query';

packages/superset-ui-plugins-demo/storybook/stories/preset-chart-xy/ScatterPlot/index.js

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {
2+
ScatterPlotChartPlugin,
3+
LegacyScatterPlotChartPlugin,
4+
} from '../../../../../superset-ui-preset-chart-xy';
5+
import BasicStories from './stories/basic';
6+
import BubbleStories from './stories/bubble';
7+
import LegacyStories from './stories/legacy';
8+
import { SCATTER_PLOT_PLUGIN_TYPE, SCATTER_PLOT_PLUGIN_LEGACY_TYPE } from './constants';
9+
10+
new LegacyScatterPlotChartPlugin().configure({ key: SCATTER_PLOT_PLUGIN_LEGACY_TYPE }).register();
11+
new ScatterPlotChartPlugin().configure({ key: SCATTER_PLOT_PLUGIN_TYPE }).register();
12+
13+
export default {
14+
examples: [...BasicStories, ...BubbleStories, ...LegacyStories],
15+
};

packages/superset-ui-plugins-demo/storybook/stories/preset-chart-xy/ScatterPlot/stories/legacy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default [
2828
vizType: 'bubble',
2929
x: 'sum__SP_RUR_TOTL_ZS',
3030
xAxisFormat: '.3s',
31-
xAxisLabel: 'x-axis label',
31+
xAxisLabel: 'x-axis label test',
3232
xAxisShowminmax: false,
3333
xLogScale: false,
3434
xTicksLayout: 'auto',

packages/superset-ui-preset-chart-xy/package.json

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,23 @@
3131
"dependencies": {
3232
"@data-ui/theme": "^0.0.84",
3333
"@data-ui/xy-chart": "^0.0.84",
34-
"@types/d3-scale": "^2.1.1",
3534
"@vx/axis": "^0.0.195",
36-
"@vx/group": "^0.0.194",
37-
"@vx/legend": "^0.0.194",
38-
"@vx/responsive": "^0.0.195",
35+
"@vx/legend": "^0.0.195",
3936
"@vx/scale": "^0.0.195",
40-
"@vx/shape": "^0.0.194",
4137
"csstype": "^2.6.3",
42-
"d3-array": "^2.1.0",
43-
"d3-scale": "^3.0.0",
38+
"encodable": "^0.3.4",
4439
"lodash": "^4.17.11",
45-
"prop-types": "^15.6.2",
46-
"reselect": "^4.0.0",
47-
"vega": "^5.8.1",
48-
"vega-lite": "~4.1.1"
40+
"reselect": "^4.0.0"
4941
},
5042
"peerDependencies": {
5143
"@superset-ui/chart": "^0.12.0",
5244
"@superset-ui/chart-composition": "^0.12.0",
53-
"@superset-ui/color": "^0.12.0",
45+
"@superset-ui/color": "^0.12.15",
5446
"@superset-ui/core": "^0.12.0",
5547
"@superset-ui/dimension": "^0.12.0",
56-
"@superset-ui/number-format": "^0.12.0",
48+
"@superset-ui/number-format": "^0.12.15",
5749
"@superset-ui/query": "^0.12.0",
58-
"@superset-ui/time-format": "^0.12.0",
50+
"@superset-ui/time-format": "^0.12.15",
5951
"@superset-ui/translation": "^0.12.0",
6052
"react": "^16.2"
6153
}

packages/superset-ui-preset-chart-xy/src/BoxPlot/Encoder.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

packages/superset-ui-preset-chart-xy/src/BoxPlot/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import transformProps from './transformProps';
2323
export default class BoxPlotChartPlugin extends ChartPlugin {
2424
constructor() {
2525
super({
26-
loadChart: () => import('./BoxPlot'),
26+
loadChart: () => import('../components/BoxPlot/BoxPlot'),
2727
metadata: createMetadata(),
2828
transformProps,
2929
});

packages/superset-ui-preset-chart-xy/src/BoxPlot/legacy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import transformProps from './transformProps';
2323
export default class BoxPlotChartPlugin extends ChartPlugin {
2424
constructor() {
2525
super({
26-
loadChart: () => import('../BoxPlot'),
26+
loadChart: () => import('../../components/BoxPlot/BoxPlot'),
2727
metadata: createMetadata(true),
2828
transformProps,
2929
});

packages/superset-ui-preset-chart-xy/src/BoxPlot/legacy/transformProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919
import { ChartProps } from '@superset-ui/chart';
20-
import { RawBoxPlotDataRow, BoxPlotDataRow } from '../types';
20+
import { RawBoxPlotDataRow, BoxPlotDataRow } from '../../components/BoxPlot/types';
2121

2222
export default function transformProps(chartProps: ChartProps) {
2323
const { width, height, datasource = {}, formData, queryData } = chartProps;

packages/superset-ui-preset-chart-xy/src/BoxPlot/transformProps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { pick } from 'lodash';
22
import { ChartProps } from '@superset-ui/chart';
3-
import { BoxPlotDataRow, RawBoxPlotDataRow } from './types';
4-
import { HookProps } from './BoxPlot';
3+
import { BoxPlotDataRow, RawBoxPlotDataRow } from '../components/BoxPlot/types';
4+
import { HookProps } from '../components/BoxPlot/BoxPlot';
55

66
export default function transformProps(chartProps: ChartProps) {
77
const { width, height, formData, queryData } = chartProps;

packages/superset-ui-preset-chart-xy/src/Line/ChartFormData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { QueryFormData } from '@superset-ui/query';
2-
import { FormDataProps } from './Line';
2+
import { FormDataProps } from '../components/Line/Line';
33

44
type CombinedFormData = QueryFormData & FormDataProps;
55

packages/superset-ui-preset-chart-xy/src/Line/Encoder.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

packages/superset-ui-preset-chart-xy/src/Line/buildQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { buildQueryContext } from '@superset-ui/query';
22
import ChartFormData from './ChartFormData';
3-
import Encoder from './Encoder';
3+
import { lineEncoderFactory } from '../components/Line/Encoder';
44

55
export default function buildQuery(formData: ChartFormData) {
66
const queryContext = buildQueryContext(formData);
77
const { encoding } = formData;
8-
const encoder = new Encoder({ encoding });
8+
const encoder = lineEncoderFactory.create(encoding);
99

1010
queryContext.queries.forEach(query => {
1111
const q = query;

packages/superset-ui-preset-chart-xy/src/Line/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class LineChartPlugin extends ChartPlugin<ChartFormData> {
88
constructor() {
99
super({
1010
buildQuery,
11-
loadChart: () => import('./Line'),
11+
loadChart: () => import('../components/Line/Line'),
1212
metadata: createMetadata(),
1313
transformProps,
1414
});

packages/superset-ui-preset-chart-xy/src/Line/legacy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import createMetadata from '../createMetadata';
55
export default class LineChartPlugin extends ChartPlugin {
66
constructor() {
77
super({
8-
loadChart: () => import('../Line'),
8+
loadChart: () => import('../../components/Line/Line'),
99
metadata: createMetadata(true),
1010
transformProps,
1111
});

0 commit comments

Comments
 (0)