Compare commits
46 Commits
dependabot
...
remove-leg
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
864e1b6f49 | ||
|
|
479fa4155a | ||
|
|
51b285c975 | ||
|
|
04fbc85fbf | ||
|
|
1c22b3ea3c | ||
|
|
d09bf67053 | ||
|
|
3b3d50778d | ||
|
|
8573f73910 | ||
|
|
a13ea264b0 | ||
|
|
c7ef2bc78c | ||
|
|
582b0f9cb7 | ||
|
|
ca70730d5d | ||
|
|
8ec0c028ed | ||
|
|
d2ce9f3804 | ||
|
|
9d8a35f588 | ||
|
|
1052359fcb | ||
|
|
24f84afc52 | ||
|
|
33cef0837f | ||
|
|
d13e46712f | ||
|
|
64bae01f63 | ||
|
|
f0cbcdb63b | ||
|
|
9ef3d03548 | ||
|
|
4e1d2ae1e7 | ||
|
|
8aa081eed7 | ||
|
|
840a098b94 | ||
|
|
09a5925aa4 | ||
|
|
8572f1884c | ||
|
|
5ce7db6aa9 | ||
|
|
570b9a19f2 | ||
|
|
a53b18da7f | ||
|
|
f5f106b291 | ||
|
|
f319520c77 | ||
|
|
35870fc38e | ||
|
|
a7f7120b48 | ||
|
|
a098f249c1 | ||
|
|
fdc7f4f728 | ||
|
|
c31543365d | ||
|
|
93b8c404e9 | ||
|
|
a8b4c2137b | ||
|
|
49b361f6b3 | ||
|
|
dfdd041104 | ||
|
|
f760b7576b | ||
|
|
0afe2ebdd3 | ||
|
|
07546dc1f2 | ||
|
|
24dbc8649c | ||
|
|
3c53228c69 |
2
.github/CODEOWNERS
vendored
@@ -34,7 +34,7 @@
|
||||
|
||||
**/*.geojson @villebro @rusackas
|
||||
**/*.ipynb @villebro @rusackas
|
||||
/superset-frontend/plugins/legacy-plugin-chart-country-map/ @villebro @rusackas
|
||||
/superset-frontend/plugins/plugin-chart-country-map/ @villebro @rusackas
|
||||
|
||||
# Notify translation maintainers of changes to translations
|
||||
|
||||
|
||||
1
.gitignore
vendored
@@ -137,6 +137,7 @@ PROJECT.md
|
||||
.aider*
|
||||
.claude_rc*
|
||||
.claude/settings.local.json
|
||||
.claude/worktrees/
|
||||
.env.local
|
||||
oxc-custom-build/
|
||||
*.code-workspace
|
||||
|
||||
@@ -111,6 +111,9 @@ are the intended model going forward; deprecating and removing implicit viewersh
|
||||
in a later major version.
|
||||
|
||||
- [41044](https://github.com/apache/superset/issues/41044): Removes the deprecated `AVOID_COLORS_COLLISION` feature flag (it defaulted to `True`). Color-collision avoidance is now permanently enabled; any config override setting it to `False` is ignored.
|
||||
- [41714](https://github.com/apache/superset/pull/41714): **Breaking — the legacy `explore_json` chart-data pipeline is removed** at its long-declared `5.0.0` EOL. The `/superset/explore_json/` and `/superset/explore_json/data/<cache_key>` endpoints, `superset/viz.py`, the `Slice.viz` property, the `get_viz` factory, the `load_explore_json_into_cache` celery task and the `viz=` overload of `security_manager.raise_for_access` are gone. Anything importing `superset.viz` must migrate to the QueryContext / `pandas_postprocessing` pipeline behind `/api/v1/chart/data`. All 15 remaining legacy charts were migrated first: most keep their `viz_type` and renderer (no action needed for saved charts), while saved nvd3 Bubble charts are auto-migrated to the ECharts Bubble Chart (`bubble_v2`) and saved "Time-series Percent Change" (`compare`) charts to the ECharts Line Chart — the nvd3 renderer's interactive percent re-basing is not preserved. The deck.gl Multiple Layers chart now fetches its layers entirely client-side; its initial autozoom falls back to the saved viewport, and dashboard filter badges no longer aggregate child-layer filter metadata.
|
||||
|
||||
- [41714](https://github.com/apache/superset/pull/41714): **Breaking for third-party viz plugins** — the `useLegacyApi` field of `ChartMetadata` in `@superset-ui/core` is removed. Plugins that set it must provide a `buildQuery` and consume `/api/v1/chart/data`. The migrated first-party packages also drop their `legacy-` prefix: `@superset-ui/legacy-plugin-chart-{calendar,chord,country-map,horizon,paired-t-test,parallel-coordinates,partition,rose,world-map}` → `@superset-ui/plugin-chart-*`, and `@superset-ui/legacy-preset-chart-nvd3` → `@superset-ui/preset-chart-nvd3`. The `can_explore_json` permission is no longer created or granted; custom roles referencing it should switch to the `can_read` permissions on `Chart`.
|
||||
|
||||
- [39925](https://github.com/apache/superset/pull/39925): URL prefixing for `SUPERSET_APP_ROOT` subdirectory deployments is now handled automatically by helpers in `src/utils/navigationUtils` (`openInNewTab`, `redirect`, `getShareableUrl`, `<AppLink>`). Direct imports of `ensureAppRoot` / `makeUrl` from `src/utils/pathUtils` are forbidden outside `navigationUtils.ts` (enforced by a static-invariant test); contributors writing new code should use the focused helpers instead. No runtime behaviour change for existing callers — all 19 prior call sites have been migrated and four pre-existing double-prefix and missing-prefix bugs are fixed as part of the migration.
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ code is less ambiguous and is unique to all regions in the world.
|
||||
## Included Maps
|
||||
|
||||
The current list of countries can be found in the src
|
||||
[legacy-plugin-chart-country-map/src/countries.ts](https://github.com/apache/superset/blob/master/superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries.ts)
|
||||
[plugin-chart-country-map/src/countries.ts](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-country-map/src/countries.ts)
|
||||
|
||||
The Country Maps visualization already ships with the maps for the following countries:
|
||||
|
||||
@@ -31,10 +31,10 @@ The Country Maps visualization already ships with the maps for the following cou
|
||||
## Adding a New Country
|
||||
|
||||
To add a new country to the list, you'd have to edit files in
|
||||
[@superset-ui/legacy-plugin-chart-country-map](https://github.com/apache/superset/tree/master/superset-frontend/plugins/legacy-plugin-chart-country-map).
|
||||
[@superset-ui/plugin-chart-country-map](https://github.com/apache/superset/tree/master/superset-frontend/plugins/plugin-chart-country-map).
|
||||
|
||||
1. Generate a new GeoJSON file for your country following the guide in [this Jupyter notebook](https://github.com/apache/superset/blob/master/superset-frontend/plugins/legacy-plugin-chart-country-map/scripts/Country%20Map%20GeoJSON%20Generator.ipynb).
|
||||
2. Edit the countries list in [legacy-plugin-chart-country-map/src/countries.ts](https://github.com/apache/superset/blob/master/superset-frontend/plugins/legacy-plugin-chart-country-map/src/countries.ts).
|
||||
1. Generate a new GeoJSON file for your country following the guide in [this Jupyter notebook](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-country-map/scripts/Country%20Map%20GeoJSON%20Generator.ipynb).
|
||||
2. Edit the countries list in [plugin-chart-country-map/src/countries.ts](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-country-map/src/countries.ts).
|
||||
3. Install superset-frontend dependencies: `cd superset-frontend && npm install`
|
||||
4. Verify your countries in Superset plugins storybook: `npm run plugins:storybook`.
|
||||
5. Build and install Superset from source code.
|
||||
|
||||
597
superset-frontend/package-lock.json
generated
@@ -51,25 +51,25 @@
|
||||
"@scarf/scarf": "^1.4.0",
|
||||
"@superset-ui/chart-controls": "file:./packages/superset-ui-chart-controls",
|
||||
"@superset-ui/core": "file:./packages/superset-ui-core",
|
||||
"@superset-ui/legacy-plugin-chart-calendar": "file:./plugins/legacy-plugin-chart-calendar",
|
||||
"@superset-ui/legacy-plugin-chart-chord": "file:./plugins/legacy-plugin-chart-chord",
|
||||
"@superset-ui/legacy-plugin-chart-country-map": "file:./plugins/legacy-plugin-chart-country-map",
|
||||
"@superset-ui/legacy-plugin-chart-horizon": "file:./plugins/legacy-plugin-chart-horizon",
|
||||
"@superset-ui/legacy-plugin-chart-paired-t-test": "file:./plugins/legacy-plugin-chart-paired-t-test",
|
||||
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "file:./plugins/legacy-plugin-chart-parallel-coordinates",
|
||||
"@superset-ui/legacy-plugin-chart-partition": "file:./plugins/legacy-plugin-chart-partition",
|
||||
"@superset-ui/legacy-plugin-chart-rose": "file:./plugins/legacy-plugin-chart-rose",
|
||||
"@superset-ui/legacy-plugin-chart-world-map": "file:./plugins/legacy-plugin-chart-world-map",
|
||||
"@superset-ui/legacy-preset-chart-nvd3": "file:./plugins/legacy-preset-chart-nvd3",
|
||||
"@superset-ui/plugin-chart-ag-grid-table": "file:./plugins/plugin-chart-ag-grid-table",
|
||||
"@superset-ui/plugin-chart-calendar": "file:./plugins/plugin-chart-calendar",
|
||||
"@superset-ui/plugin-chart-cartodiagram": "file:./plugins/plugin-chart-cartodiagram",
|
||||
"@superset-ui/plugin-chart-chord": "file:./plugins/plugin-chart-chord",
|
||||
"@superset-ui/plugin-chart-country-map": "file:./plugins/plugin-chart-country-map",
|
||||
"@superset-ui/plugin-chart-echarts": "file:./plugins/plugin-chart-echarts",
|
||||
"@superset-ui/plugin-chart-handlebars": "file:./plugins/plugin-chart-handlebars",
|
||||
"@superset-ui/plugin-chart-horizon": "file:./plugins/plugin-chart-horizon",
|
||||
"@superset-ui/plugin-chart-paired-t-test": "file:./plugins/plugin-chart-paired-t-test",
|
||||
"@superset-ui/plugin-chart-parallel-coordinates": "file:./plugins/plugin-chart-parallel-coordinates",
|
||||
"@superset-ui/plugin-chart-partition": "file:./plugins/plugin-chart-partition",
|
||||
"@superset-ui/plugin-chart-pivot-table": "file:./plugins/plugin-chart-pivot-table",
|
||||
"@superset-ui/plugin-chart-point-cluster-map": "file:./plugins/plugin-chart-point-cluster-map",
|
||||
"@superset-ui/plugin-chart-rose": "file:./plugins/plugin-chart-rose",
|
||||
"@superset-ui/plugin-chart-table": "file:./plugins/plugin-chart-table",
|
||||
"@superset-ui/plugin-chart-word-cloud": "file:./plugins/plugin-chart-word-cloud",
|
||||
"@superset-ui/plugin-chart-world-map": "file:./plugins/plugin-chart-world-map",
|
||||
"@superset-ui/preset-chart-deckgl": "file:./plugins/preset-chart-deckgl",
|
||||
"@superset-ui/preset-chart-nvd3": "file:./plugins/preset-chart-nvd3",
|
||||
"@superset-ui/switchboard": "file:./packages/superset-ui-switchboard",
|
||||
"@types/d3-format": "^3.0.1",
|
||||
"@types/d3-selection": "^3.0.11",
|
||||
@@ -10740,54 +10740,26 @@
|
||||
"resolved": "packages/generator-superset",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-calendar": {
|
||||
"resolved": "plugins/legacy-plugin-chart-calendar",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-chord": {
|
||||
"resolved": "plugins/legacy-plugin-chart-chord",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-country-map": {
|
||||
"resolved": "plugins/legacy-plugin-chart-country-map",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-horizon": {
|
||||
"resolved": "plugins/legacy-plugin-chart-horizon",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-paired-t-test": {
|
||||
"resolved": "plugins/legacy-plugin-chart-paired-t-test",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-parallel-coordinates": {
|
||||
"resolved": "plugins/legacy-plugin-chart-parallel-coordinates",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-partition": {
|
||||
"resolved": "plugins/legacy-plugin-chart-partition",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-rose": {
|
||||
"resolved": "plugins/legacy-plugin-chart-rose",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-plugin-chart-world-map": {
|
||||
"resolved": "plugins/legacy-plugin-chart-world-map",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/legacy-preset-chart-nvd3": {
|
||||
"resolved": "plugins/legacy-preset-chart-nvd3",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-ag-grid-table": {
|
||||
"resolved": "plugins/plugin-chart-ag-grid-table",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-calendar": {
|
||||
"resolved": "plugins/plugin-chart-calendar",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-cartodiagram": {
|
||||
"resolved": "plugins/plugin-chart-cartodiagram",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-chord": {
|
||||
"resolved": "plugins/plugin-chart-chord",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-country-map": {
|
||||
"resolved": "plugins/plugin-chart-country-map",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-echarts": {
|
||||
"resolved": "plugins/plugin-chart-echarts",
|
||||
"link": true
|
||||
@@ -10796,6 +10768,22 @@
|
||||
"resolved": "plugins/plugin-chart-handlebars",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-horizon": {
|
||||
"resolved": "plugins/plugin-chart-horizon",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-paired-t-test": {
|
||||
"resolved": "plugins/plugin-chart-paired-t-test",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-parallel-coordinates": {
|
||||
"resolved": "plugins/plugin-chart-parallel-coordinates",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-partition": {
|
||||
"resolved": "plugins/plugin-chart-partition",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-pivot-table": {
|
||||
"resolved": "plugins/plugin-chart-pivot-table",
|
||||
"link": true
|
||||
@@ -10804,6 +10792,10 @@
|
||||
"resolved": "plugins/plugin-chart-point-cluster-map",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-rose": {
|
||||
"resolved": "plugins/plugin-chart-rose",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-table": {
|
||||
"resolved": "plugins/plugin-chart-table",
|
||||
"link": true
|
||||
@@ -10812,10 +10804,18 @@
|
||||
"resolved": "plugins/plugin-chart-word-cloud",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/plugin-chart-world-map": {
|
||||
"resolved": "plugins/plugin-chart-world-map",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/preset-chart-deckgl": {
|
||||
"resolved": "plugins/preset-chart-deckgl",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/preset-chart-nvd3": {
|
||||
"resolved": "plugins/preset-chart-nvd3",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@superset-ui/switchboard": {
|
||||
"resolved": "packages/superset-ui-switchboard",
|
||||
"link": true
|
||||
@@ -16154,12 +16154,6 @@
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/cephes": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cephes/-/cephes-2.0.0.tgz",
|
||||
"integrity": "sha512-4GMUzkcXHZ0HMZ3gZdBrv8pQs1/zkJh2Q9rQOF8NJZHanM359y3XOSdeqmDBPfxQKYQpJt58R3dUpofrIXJ2mg==",
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/chai": {
|
||||
"version": "5.3.3",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz",
|
||||
@@ -18584,15 +18578,6 @@
|
||||
"readable-stream": "^3.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/distributions": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/distributions/-/distributions-2.2.0.tgz",
|
||||
"integrity": "sha512-n7ybud+CRAOZlpg+ETuA0PTiSBfyVNt8Okns5gSK4NvHwj7RamQoufptOucvVcTn9CV4DZ38p1k6TgwMexUNkQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cephes": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dnd-core": {
|
||||
"version": "11.1.3",
|
||||
"resolved": "https://registry.npmjs.org/dnd-core/-/dnd-core-11.1.3.tgz",
|
||||
@@ -35727,15 +35712,6 @@
|
||||
"integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/reactable": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/reactable/-/reactable-1.1.0.tgz",
|
||||
"integrity": "sha512-SnvZ3CXyFFxGotw9cqNiVUGb2oW16UlIypGQZRJGgPiJuFqW22jO7A+Y/Tvv8no8F/bZoLdZ+QJP7eZfcc9kCw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "* || ^0.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/read": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/read/-/read-4.1.0.tgz",
|
||||
@@ -43816,245 +43792,6 @@
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"plugins/legacy-plugin-chart-calendar": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-calendar",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3-array": "^3.2.4",
|
||||
"d3-selection": "^3.0.0",
|
||||
"d3-tip": "^0.9.1",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@emotion/react": "^11.4.1",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-calendar/node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-calendar/node_modules/d3-selection": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
|
||||
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-chord": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-chord",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"prop-types": "^15.8.1",
|
||||
"react": "^19.2.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-chord/node_modules/react": {
|
||||
"version": "19.2.7",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz",
|
||||
"integrity": "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-country-map": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-country-map",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-array": "^3.2.4",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-country-map/node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-horizon": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-horizon",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3-array": "^3.2.4",
|
||||
"d3-scale": "^4.0.2",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-horizon/node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-paired-t-test": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-paired-t-test",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"distributions": "^2.2.0",
|
||||
"prop-types": "^15.8.1",
|
||||
"reactable": "^1.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-parallel-coordinates": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-parallel-coordinates",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3v3": "npm:d3@3.5.17",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-partition": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-partition",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-hierarchy": "^3.1.2",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"@testing-library/jest-dom": "*",
|
||||
"@testing-library/react": "^14.0.0",
|
||||
"react": "^18.3.0",
|
||||
"react-dom": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-rose": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-rose",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"nvd3-fork": "^2.0.5",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@emotion/react": "^11.4.1",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-world-map": {
|
||||
"name": "@superset-ui/legacy-plugin-chart-world-map",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-array": "^3.2.4",
|
||||
"datamaps": "^0.5.10",
|
||||
"prop-types": "^15.8.1",
|
||||
"tinycolor2": "^1.6.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-plugin-chart-world-map/node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/legacy-preset-chart-nvd3": {
|
||||
"name": "@superset-ui/legacy-preset-chart-nvd3",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-tip": "^0.9.1",
|
||||
"dompurify": "^3.4.11",
|
||||
"fast-safe-stringify": "^2.1.1",
|
||||
"lodash": "^4.18.1",
|
||||
"lodash-es": "^4.18.1",
|
||||
"nvd3-fork": "^2.0.5",
|
||||
"prop-types": "^15.8.1",
|
||||
"urijs": "^1.19.11"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"dayjs": "^1.11.21",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-ag-grid-table": {
|
||||
"name": "@superset-ui/plugin-chart-ag-grid-table",
|
||||
"version": "0.20.3",
|
||||
@@ -44097,6 +43834,45 @@
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-calendar": {
|
||||
"name": "@superset-ui/plugin-chart-calendar",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3-array": "^3.2.4",
|
||||
"d3-selection": "^3.0.0",
|
||||
"d3-tip": "^0.9.1",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@emotion/react": "^11.4.1",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-calendar/node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-calendar/node_modules/d3-selection": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
|
||||
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-cartodiagram": {
|
||||
"name": "@superset-ui/plugin-chart-cartodiagram",
|
||||
"version": "0.0.1",
|
||||
@@ -44125,6 +43901,58 @@
|
||||
"react-dom": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-chord": {
|
||||
"name": "@superset-ui/plugin-chart-chord",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"prop-types": "^15.8.1",
|
||||
"react": "^19.2.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-chord/node_modules/react": {
|
||||
"version": "19.2.7",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz",
|
||||
"integrity": "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-country-map": {
|
||||
"name": "@superset-ui/plugin-chart-country-map",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-array": "^3.2.4",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-country-map/node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-echarts": {
|
||||
"name": "@superset-ui/plugin-chart-echarts",
|
||||
"version": "0.20.3",
|
||||
@@ -44212,6 +44040,79 @@
|
||||
"sprintf-js": ">= 1.1.1 < 2"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-horizon": {
|
||||
"name": "@superset-ui/plugin-chart-horizon",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3-array": "^3.2.4",
|
||||
"d3-scale": "^4.0.2",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-horizon/node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-paired-t-test": {
|
||||
"name": "@superset-ui/plugin-chart-paired-t-test",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-parallel-coordinates": {
|
||||
"name": "@superset-ui/plugin-chart-parallel-coordinates",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3v3": "npm:d3@3.5.17",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-partition": {
|
||||
"name": "@superset-ui/plugin-chart-partition",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-hierarchy": "^3.1.2",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"@testing-library/jest-dom": "*",
|
||||
"@testing-library/react": "^14.0.0",
|
||||
"react": "^18.3.0",
|
||||
"react-dom": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-pivot-table": {
|
||||
"name": "@superset-ui/plugin-chart-pivot-table",
|
||||
"version": "0.20.3",
|
||||
@@ -44251,6 +44152,23 @@
|
||||
"react-dom": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-rose": {
|
||||
"name": "@superset-ui/plugin-chart-rose",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"nvd3-fork": "^2.0.5",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@emotion/react": "^11.4.1",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-table": {
|
||||
"name": "@superset-ui/plugin-chart-table",
|
||||
"version": "0.20.3",
|
||||
@@ -44316,6 +44234,36 @@
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-world-map": {
|
||||
"name": "@superset-ui/plugin-chart-world-map",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-array": "^3.2.4",
|
||||
"datamaps": "^0.5.10",
|
||||
"prop-types": "^15.8.1",
|
||||
"tinycolor2": "^1.6.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
},
|
||||
"plugins/plugin-chart-world-map/node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/preset-chart-deckgl": {
|
||||
"name": "@superset-ui/preset-chart-deckgl",
|
||||
"version": "1.0.0",
|
||||
@@ -44399,6 +44347,29 @@
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"plugins/preset-chart-nvd3": {
|
||||
"name": "@superset-ui/preset-chart-nvd3",
|
||||
"version": "0.20.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-tip": "^0.9.1",
|
||||
"dompurify": "^3.4.11",
|
||||
"fast-safe-stringify": "^2.1.1",
|
||||
"lodash": "^4.18.1",
|
||||
"lodash-es": "^4.18.1",
|
||||
"nvd3-fork": "^2.0.5",
|
||||
"prop-types": "^15.8.1",
|
||||
"urijs": "^1.19.11"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@apache-superset/core": "*",
|
||||
"@superset-ui/chart-controls": "*",
|
||||
"@superset-ui/core": "*",
|
||||
"dayjs": "^1.11.21",
|
||||
"react": "^18.3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
"test": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" jest --max-workers=80% --silent",
|
||||
"test-loud": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" jest --max-workers=80%",
|
||||
"type": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" tsc --noEmit",
|
||||
"update-maps": "cd plugins/legacy-plugin-chart-country-map/scripts && jupyter nbconvert --to notebook --execute --inplace --allow-errors --ExecutePreprocessor.timeout=1200 'Country Map GeoJSON Generator.ipynb'",
|
||||
"update-maps": "cd plugins/plugin-chart-country-map/scripts && jupyter nbconvert --to notebook --execute --inplace --allow-errors --ExecutePreprocessor.timeout=1200 'Country Map GeoJSON Generator.ipynb'",
|
||||
"validate-release": "../RELEASING/validate_this_release.sh"
|
||||
},
|
||||
"browserslist": [
|
||||
@@ -136,16 +136,16 @@
|
||||
"@scarf/scarf": "^1.4.0",
|
||||
"@superset-ui/chart-controls": "file:./packages/superset-ui-chart-controls",
|
||||
"@superset-ui/core": "file:./packages/superset-ui-core",
|
||||
"@superset-ui/legacy-plugin-chart-calendar": "file:./plugins/legacy-plugin-chart-calendar",
|
||||
"@superset-ui/legacy-plugin-chart-chord": "file:./plugins/legacy-plugin-chart-chord",
|
||||
"@superset-ui/legacy-plugin-chart-country-map": "file:./plugins/legacy-plugin-chart-country-map",
|
||||
"@superset-ui/legacy-plugin-chart-horizon": "file:./plugins/legacy-plugin-chart-horizon",
|
||||
"@superset-ui/legacy-plugin-chart-paired-t-test": "file:./plugins/legacy-plugin-chart-paired-t-test",
|
||||
"@superset-ui/legacy-plugin-chart-parallel-coordinates": "file:./plugins/legacy-plugin-chart-parallel-coordinates",
|
||||
"@superset-ui/legacy-plugin-chart-partition": "file:./plugins/legacy-plugin-chart-partition",
|
||||
"@superset-ui/legacy-plugin-chart-rose": "file:./plugins/legacy-plugin-chart-rose",
|
||||
"@superset-ui/legacy-plugin-chart-world-map": "file:./plugins/legacy-plugin-chart-world-map",
|
||||
"@superset-ui/legacy-preset-chart-nvd3": "file:./plugins/legacy-preset-chart-nvd3",
|
||||
"@superset-ui/plugin-chart-calendar": "file:./plugins/plugin-chart-calendar",
|
||||
"@superset-ui/plugin-chart-chord": "file:./plugins/plugin-chart-chord",
|
||||
"@superset-ui/plugin-chart-country-map": "file:./plugins/plugin-chart-country-map",
|
||||
"@superset-ui/plugin-chart-horizon": "file:./plugins/plugin-chart-horizon",
|
||||
"@superset-ui/plugin-chart-paired-t-test": "file:./plugins/plugin-chart-paired-t-test",
|
||||
"@superset-ui/plugin-chart-parallel-coordinates": "file:./plugins/plugin-chart-parallel-coordinates",
|
||||
"@superset-ui/plugin-chart-partition": "file:./plugins/plugin-chart-partition",
|
||||
"@superset-ui/plugin-chart-rose": "file:./plugins/plugin-chart-rose",
|
||||
"@superset-ui/plugin-chart-world-map": "file:./plugins/plugin-chart-world-map",
|
||||
"@superset-ui/preset-chart-nvd3": "file:./plugins/preset-chart-nvd3",
|
||||
"@superset-ui/plugin-chart-ag-grid-table": "file:./plugins/plugin-chart-ag-grid-table",
|
||||
"@superset-ui/plugin-chart-cartodiagram": "file:./plugins/plugin-chart-cartodiagram",
|
||||
"@superset-ui/plugin-chart-echarts": "file:./plugins/plugin-chart-echarts",
|
||||
|
||||
@@ -104,24 +104,15 @@ export default class ChartClient {
|
||||
const buildQueryRegistry = getChartBuildQueryRegistry();
|
||||
|
||||
if (metaDataRegistry.has(visType)) {
|
||||
const { useLegacyApi } = metaDataRegistry.get(visType)!;
|
||||
const buildQuery =
|
||||
(await buildQueryRegistry.get(visType)) ?? (() => formData);
|
||||
const requestConfig: RequestConfig = useLegacyApi
|
||||
? {
|
||||
endpoint: '/explore_json/',
|
||||
postPayload: {
|
||||
form_data: buildQuery(formData),
|
||||
},
|
||||
...options,
|
||||
}
|
||||
: {
|
||||
endpoint: '/api/v1/chart/data',
|
||||
jsonPayload: {
|
||||
query_context: buildQuery(formData),
|
||||
},
|
||||
...options,
|
||||
};
|
||||
const requestConfig: RequestConfig = {
|
||||
endpoint: '/api/v1/chart/data',
|
||||
jsonPayload: {
|
||||
query_context: buildQuery(formData),
|
||||
},
|
||||
...options,
|
||||
};
|
||||
|
||||
return this.client
|
||||
.post(requestConfig)
|
||||
|
||||
@@ -68,9 +68,7 @@ beforeEach(() => {
|
||||
|
||||
// Setup default registry mocks
|
||||
(getChartMetadataRegistry as any).mockReturnValue({
|
||||
get: jest.fn().mockReturnValue({
|
||||
useLegacyApi: false,
|
||||
}),
|
||||
get: jest.fn().mockReturnValue({}),
|
||||
});
|
||||
|
||||
(getChartBuildQueryRegistry as any).mockReturnValue({
|
||||
|
||||
@@ -32,7 +32,6 @@ import type { HandlerFunction } from '../types/Base';
|
||||
import { Loading } from '../../components/Loading';
|
||||
import ChartClient from '../clients/ChartClient';
|
||||
import getChartBuildQueryRegistry from '../registries/ChartBuildQueryRegistrySingleton';
|
||||
import getChartMetadataRegistry from '../registries/ChartMetadataRegistrySingleton';
|
||||
import getChartControlPanelRegistry from '../registries/ChartControlPanelRegistrySingleton';
|
||||
import SuperChart from './SuperChart';
|
||||
|
||||
@@ -245,9 +244,6 @@ export default function StatefulChart(props: StatefulChartProps) {
|
||||
}
|
||||
finalFormData.viz_type = vizType;
|
||||
|
||||
// Get chart metadata
|
||||
const { useLegacyApi } = getChartMetadataRegistry().get(vizType) || {};
|
||||
|
||||
// Build query using the chart's buildQuery function
|
||||
const buildQuery = await getChartBuildQueryRegistry().get(vizType);
|
||||
let queryContext;
|
||||
@@ -259,39 +255,28 @@ export default function StatefulChart(props: StatefulChartProps) {
|
||||
queryContext = buildQueryContext(finalFormData);
|
||||
}
|
||||
|
||||
// Ensure query_context is properly formatted for new API
|
||||
if (!useLegacyApi && !queryContext.queries) {
|
||||
// Ensure query_context is properly formatted for the API
|
||||
if (!queryContext.queries) {
|
||||
queryContext = { queries: [queryContext] };
|
||||
}
|
||||
const endpoint = useLegacyApi ? '/explore_json/' : '/api/v1/chart/data';
|
||||
|
||||
const requestConfig: RequestConfig = {
|
||||
endpoint,
|
||||
endpoint: '/api/v1/chart/data',
|
||||
signal: abortControllerRef.current.signal,
|
||||
...(timeout && { timeout: timeout * 1000 }),
|
||||
};
|
||||
|
||||
if (useLegacyApi) {
|
||||
requestConfig.postPayload = {
|
||||
form_data: {
|
||||
...finalFormData,
|
||||
...(force && { force: true }),
|
||||
},
|
||||
};
|
||||
} else {
|
||||
requestConfig.jsonPayload = {
|
||||
jsonPayload: {
|
||||
...queryContext,
|
||||
...(force && { force: true }),
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const response = await chartClientRef.current!.client.post(requestConfig);
|
||||
let responseData = Array.isArray(response.json)
|
||||
? response.json
|
||||
: [response.json];
|
||||
|
||||
// Handle the nested result structure from the new API
|
||||
if (!useLegacyApi && responseData[0]?.result) {
|
||||
// Handle the nested result structure from the API
|
||||
if (responseData[0]?.result) {
|
||||
responseData = responseData[0].result;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ export interface ChartMetadataConfig {
|
||||
supportedAnnotationTypes?: string[];
|
||||
thumbnail: string;
|
||||
thumbnailDark?: string;
|
||||
useLegacyApi?: boolean;
|
||||
behaviors?: Behavior[];
|
||||
exampleGallery?: ExampleImage[];
|
||||
tags?: string[];
|
||||
@@ -75,8 +74,6 @@ export default class ChartMetadata {
|
||||
|
||||
thumbnailDark?: string;
|
||||
|
||||
useLegacyApi: boolean;
|
||||
|
||||
behaviors: Behavior[];
|
||||
|
||||
datasourceCount: number;
|
||||
@@ -112,7 +109,6 @@ export default class ChartMetadata {
|
||||
supportedAnnotationTypes = [],
|
||||
thumbnail,
|
||||
thumbnailDark,
|
||||
useLegacyApi = false,
|
||||
behaviors = [],
|
||||
datasourceCount = 1,
|
||||
enableNoResults = true,
|
||||
@@ -144,7 +140,6 @@ export default class ChartMetadata {
|
||||
this.supportedAnnotationTypes = supportedAnnotationTypes;
|
||||
this.thumbnail = thumbnail;
|
||||
this.thumbnailDark = thumbnailDark;
|
||||
this.useLegacyApi = useLegacyApi;
|
||||
this.behaviors = behaviors;
|
||||
this.datasourceCount = datasourceCount;
|
||||
this.enableNoResults = enableNoResults;
|
||||
|
||||
@@ -160,42 +160,6 @@ describe('ChartClient', () => {
|
||||
datasource: '1__table',
|
||||
}),
|
||||
).rejects.toEqual(new Error('Unknown chart type: rainbow_3d_pie')));
|
||||
|
||||
test('fetches data from the legacy API if ChartMetadata has useLegacyApi=true,', () => {
|
||||
// note legacy charts do not register a buildQuery function in the registry
|
||||
getChartMetadataRegistry().registerValue(
|
||||
'word_cloud_legacy',
|
||||
new ChartMetadata({
|
||||
name: 'Legacy Word Cloud',
|
||||
thumbnail: '.png',
|
||||
useLegacyApi: true,
|
||||
}),
|
||||
);
|
||||
|
||||
fetchMock.post('glob:*/api/v1/chart/data', () =>
|
||||
Promise.reject(new Error('Unexpected all to v1 API')),
|
||||
);
|
||||
|
||||
// post `Superset.route_base = ""`, the legacy endpoint
|
||||
// collapsed from `/superset/explore_json/` to `/explore_json/`.
|
||||
fetchMock.post('glob:*/explore_json/', {
|
||||
field1: 'abc',
|
||||
field2: 'def',
|
||||
});
|
||||
|
||||
return expect(
|
||||
chartClient.loadQueryData({
|
||||
granularity: 'minute',
|
||||
viz_type: 'word_cloud_legacy',
|
||||
datasource: '1__table',
|
||||
}),
|
||||
).resolves.toEqual([
|
||||
{
|
||||
field1: 'abc',
|
||||
field2: 'def',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.loadDatasource(datasourceKey, options)', () => {
|
||||
|
||||
@@ -1,143 +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 react/no-array-index-key */
|
||||
import { memo } from 'react';
|
||||
import { styled } from '@apache-superset/core/theme';
|
||||
import TTestTable, { DataEntry } from './TTestTable';
|
||||
|
||||
interface PairedTTestProps {
|
||||
alpha?: number;
|
||||
className?: string;
|
||||
data: Record<string, DataEntry[]>;
|
||||
groups: string[];
|
||||
liftValPrec?: number;
|
||||
metrics: string[];
|
||||
pValPrec?: number;
|
||||
}
|
||||
|
||||
const StyledDiv = styled.div`
|
||||
${({ theme }) => `
|
||||
.superset-legacy-chart-paired-t-test .scrollbar-container {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.paired-ttest-table .scrollbar-content {
|
||||
padding-left: ${theme.sizeUnit}px;
|
||||
padding-right: ${theme.sizeUnit}px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.paired-ttest-table table {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.paired-ttest-table h1 {
|
||||
margin-left: ${theme.sizeUnit}px;
|
||||
}
|
||||
|
||||
.reactable-data tr {
|
||||
font-feature-settings: 'tnum' 1;
|
||||
}
|
||||
|
||||
.reactable-data tr,
|
||||
.reactable-header-sortable {
|
||||
-webkit-transition: ease-in-out 0.1s;
|
||||
transition: ease-in-out 0.1s;
|
||||
}
|
||||
|
||||
.reactable-data tr:hover {
|
||||
background-color: ${theme.colorFillTertiary};
|
||||
}
|
||||
|
||||
.reactable-data tr .false {
|
||||
color: ${theme.colorError};
|
||||
}
|
||||
|
||||
.reactable-data tr .true {
|
||||
color: ${theme.colorSuccess};
|
||||
}
|
||||
|
||||
.reactable-data tr .control {
|
||||
color: ${theme.colorPrimary};
|
||||
}
|
||||
|
||||
.reactable-data tr .invalid {
|
||||
color: ${theme.colorWarning};
|
||||
}
|
||||
|
||||
.reactable-data .control td {
|
||||
background-color: ${theme.colorFillTertiary};
|
||||
}
|
||||
|
||||
.reactable-header-sortable:hover,
|
||||
.reactable-header-sortable:focus,
|
||||
.reactable-header-sort-asc,
|
||||
.reactable-header-sort-desc {
|
||||
background-color: ${theme.colorFillTertiary};
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.reactable-header-sort-asc:after {
|
||||
content: '\\25bc';
|
||||
position: absolute;
|
||||
right: ${theme.sizeUnit * 3}px;
|
||||
}
|
||||
|
||||
.reactable-header-sort-desc:after {
|
||||
content: '\\25b2';
|
||||
position: absolute;
|
||||
right: ${theme.sizeUnit * 3}px;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
function PairedTTest({
|
||||
alpha = 0.05,
|
||||
className = '',
|
||||
data,
|
||||
groups,
|
||||
liftValPrec = 4,
|
||||
metrics,
|
||||
pValPrec = 6,
|
||||
}: PairedTTestProps) {
|
||||
return (
|
||||
<StyledDiv>
|
||||
<div className={`superset-legacy-chart-paired-t-test ${className}`}>
|
||||
<div className="paired-ttest-table">
|
||||
<div className="scrollbar-content">
|
||||
{metrics.map((metric, i) => (
|
||||
<TTestTable
|
||||
key={i}
|
||||
metric={metric}
|
||||
groups={groups}
|
||||
data={data[metric]}
|
||||
alpha={alpha}
|
||||
pValPrec={Math.min(pValPrec, 32)}
|
||||
liftValPrec={Math.min(liftValPrec, 32)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</StyledDiv>
|
||||
);
|
||||
}
|
||||
|
||||
// memo preserves the shallow-prop render bailout of the PureComponent original
|
||||
export default memo(PairedTTest);
|
||||
@@ -1,81 +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 { SuperChart, VizType } from '@superset-ui/core';
|
||||
import { EchartsBoxPlotChartPlugin } from '@superset-ui/plugin-chart-echarts';
|
||||
import { dummyDatasource, withResizableChartDemo } from '@storybook-shared';
|
||||
import data from './data';
|
||||
|
||||
new EchartsBoxPlotChartPlugin().configure({ key: 'box-plot' }).register();
|
||||
|
||||
export default {
|
||||
title: 'Legacy Chart Plugins/legacy-preset-chart-nvd3/BoxPlot',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
colorScheme: 'd3Category10',
|
||||
whiskerOptions: 'Min/max (no outliers)',
|
||||
},
|
||||
argTypes: {
|
||||
colorScheme: {
|
||||
control: 'select',
|
||||
options: [
|
||||
'supersetColors',
|
||||
'd3Category10',
|
||||
'bnbColors',
|
||||
'googleCategory20c',
|
||||
],
|
||||
},
|
||||
whiskerOptions: {
|
||||
control: 'select',
|
||||
options: [
|
||||
'Tukey',
|
||||
'Min/max (no outliers)',
|
||||
'2/98 percentiles',
|
||||
'9/91 percentiles',
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Basic = ({
|
||||
colorScheme,
|
||||
whiskerOptions,
|
||||
width,
|
||||
height,
|
||||
}: {
|
||||
colorScheme: string;
|
||||
whiskerOptions: string;
|
||||
width: number;
|
||||
height: number;
|
||||
}) => (
|
||||
<SuperChart
|
||||
chartType="box-plot"
|
||||
width={width}
|
||||
height={height}
|
||||
datasource={dummyDatasource}
|
||||
queriesData={[{ data }]}
|
||||
formData={{
|
||||
color_scheme: colorScheme,
|
||||
viz_type: VizType.BoxPlot,
|
||||
whisker_options: whiskerOptions,
|
||||
groupby: ['region'],
|
||||
metrics: ['sum__SP_POP_TOTL'],
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -1,78 +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 sort-keys, no-magic-numbers */
|
||||
// Data format for ECharts BoxPlot - requires metric__min, metric__q1, metric__median, etc.
|
||||
export default [
|
||||
{
|
||||
region: 'East Asia & Pacific',
|
||||
sum__SP_POP_TOTL__min: 1031863394.0,
|
||||
sum__SP_POP_TOTL__q1: 1384725172.5,
|
||||
sum__SP_POP_TOTL__median: 1717904169.0,
|
||||
sum__SP_POP_TOTL__q3: 2032724922.5,
|
||||
sum__SP_POP_TOTL__max: 2240687901.0,
|
||||
sum__SP_POP_TOTL__mean: 1681000000.0,
|
||||
sum__SP_POP_TOTL__count: 50,
|
||||
sum__SP_POP_TOTL__outliers: [],
|
||||
},
|
||||
{
|
||||
region: 'Europe & Central Asia',
|
||||
sum__SP_POP_TOTL__min: 660881033.0,
|
||||
sum__SP_POP_TOTL__q1: 751386460.5,
|
||||
sum__SP_POP_TOTL__median: 820716895.0,
|
||||
sum__SP_POP_TOTL__q3: 862814192.5,
|
||||
sum__SP_POP_TOTL__max: 903095786.0,
|
||||
sum__SP_POP_TOTL__mean: 799778873.0,
|
||||
sum__SP_POP_TOTL__count: 50,
|
||||
sum__SP_POP_TOTL__outliers: [],
|
||||
},
|
||||
{
|
||||
region: 'Latin America & Caribbean',
|
||||
sum__SP_POP_TOTL__min: 220564224.0,
|
||||
sum__SP_POP_TOTL__q1: 313690832.5,
|
||||
sum__SP_POP_TOTL__median: 421490233.0,
|
||||
sum__SP_POP_TOTL__q3: 529668114.5,
|
||||
sum__SP_POP_TOTL__max: 626270167.0,
|
||||
sum__SP_POP_TOTL__mean: 422336714.0,
|
||||
sum__SP_POP_TOTL__count: 50,
|
||||
sum__SP_POP_TOTL__outliers: [],
|
||||
},
|
||||
{
|
||||
region: 'South Asia',
|
||||
sum__SP_POP_TOTL__min: 572036107.0,
|
||||
sum__SP_POP_TOTL__q1: 772373036.5,
|
||||
sum__SP_POP_TOTL__median: 1059570231.0,
|
||||
sum__SP_POP_TOTL__q3: 1398841234.0,
|
||||
sum__SP_POP_TOTL__max: 1720976995.0,
|
||||
sum__SP_POP_TOTL__mean: 1104759521.0,
|
||||
sum__SP_POP_TOTL__count: 50,
|
||||
sum__SP_POP_TOTL__outliers: [],
|
||||
},
|
||||
{
|
||||
region: 'Sub-Saharan Africa',
|
||||
sum__SP_POP_TOTL__min: 228268752.0,
|
||||
sum__SP_POP_TOTL__q1: 320037758.0,
|
||||
sum__SP_POP_TOTL__median: 467337821.0,
|
||||
sum__SP_POP_TOTL__q3: 676768689.0,
|
||||
sum__SP_POP_TOTL__max: 974315323.0,
|
||||
sum__SP_POP_TOTL__mean: 533345669.0,
|
||||
sum__SP_POP_TOTL__count: 50,
|
||||
sum__SP_POP_TOTL__outliers: [1100000000, 1200000000],
|
||||
},
|
||||
];
|
||||
@@ -1,140 +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 '@apache-superset/core/translation';
|
||||
import {
|
||||
ControlPanelConfig,
|
||||
formatSelectOptions,
|
||||
D3_FORMAT_OPTIONS,
|
||||
getStandardizedControls,
|
||||
} from '@superset-ui/chart-controls';
|
||||
import {
|
||||
showLegend,
|
||||
xAxisLabel,
|
||||
yAxisLabel,
|
||||
bottomMargin,
|
||||
xTicksLayout,
|
||||
xAxisFormat,
|
||||
yLogScale,
|
||||
xAxisShowMinmax,
|
||||
yAxisShowMinmax,
|
||||
leftMargin,
|
||||
yAxisBounds,
|
||||
} from '../NVD3Controls';
|
||||
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
['series'],
|
||||
['entity'],
|
||||
['x'],
|
||||
['y'],
|
||||
['adhoc_filters'],
|
||||
['size'],
|
||||
[
|
||||
{
|
||||
name: 'max_bubble_size',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('Max Bubble Size'),
|
||||
default: '25',
|
||||
choices: formatSelectOptions([
|
||||
'5',
|
||||
'10',
|
||||
'15',
|
||||
'25',
|
||||
'50',
|
||||
'75',
|
||||
'100',
|
||||
]),
|
||||
},
|
||||
},
|
||||
],
|
||||
['limit', null],
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('Chart Options'),
|
||||
expanded: true,
|
||||
tabOverride: 'customize',
|
||||
controlSetRows: [['color_scheme'], [showLegend, null]],
|
||||
},
|
||||
{
|
||||
label: t('X Axis'),
|
||||
expanded: true,
|
||||
tabOverride: 'customize',
|
||||
controlSetRows: [
|
||||
[xAxisLabel, leftMargin],
|
||||
[
|
||||
{
|
||||
name: xAxisFormat.name,
|
||||
config: {
|
||||
...xAxisFormat.config,
|
||||
default: 'SMART_NUMBER',
|
||||
choices: D3_FORMAT_OPTIONS,
|
||||
},
|
||||
},
|
||||
xTicksLayout,
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'x_log_scale',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('X Log Scale'),
|
||||
default: false,
|
||||
renderTrigger: true,
|
||||
description: t('Use a log scale for the X-axis'),
|
||||
},
|
||||
},
|
||||
xAxisShowMinmax,
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('Y Axis'),
|
||||
expanded: true,
|
||||
tabOverride: 'customize',
|
||||
controlSetRows: [
|
||||
[yAxisLabel, bottomMargin],
|
||||
['y_axis_format', null],
|
||||
[yLogScale, yAxisShowMinmax],
|
||||
[yAxisBounds],
|
||||
],
|
||||
},
|
||||
],
|
||||
controlOverrides: {
|
||||
color_scheme: {
|
||||
renderTrigger: false,
|
||||
},
|
||||
},
|
||||
formDataOverrides: formData => ({
|
||||
...formData,
|
||||
series: getStandardizedControls().shiftColumn(),
|
||||
entity: getStandardizedControls().shiftColumn(),
|
||||
x: getStandardizedControls().shiftMetric(),
|
||||
y: getStandardizedControls().shiftMetric(),
|
||||
size: getStandardizedControls().shiftMetric(),
|
||||
}),
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 44 KiB |
@@ -1,63 +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 '@apache-superset/core/translation';
|
||||
import { ChartMetadata, ChartPlugin, ChartLabel } from '@superset-ui/core';
|
||||
import transformProps from '../transformProps';
|
||||
import example from './images/example.jpg';
|
||||
import exampleDark from './images/example-dark.jpg';
|
||||
import thumbnail from './images/thumbnail.png';
|
||||
import thumbnailDark from './images/thumbnail-dark.png';
|
||||
import controlPanel from './controlPanel';
|
||||
|
||||
const metadata = new ChartMetadata({
|
||||
category: t('Correlation'),
|
||||
credits: ['http://nvd3.org'],
|
||||
description: t(
|
||||
'Visualizes a metric across three dimensions of data in a single chart (X axis, Y axis, and bubble size). Bubbles from the same group can be showcased using bubble color.',
|
||||
),
|
||||
exampleGallery: [{ url: example, urlDark: exampleDark }],
|
||||
label: ChartLabel.Deprecated,
|
||||
name: t('Bubble Chart (legacy)'),
|
||||
tags: [
|
||||
t('Multi-Dimensions'),
|
||||
t('Comparison'),
|
||||
t('Legacy'),
|
||||
t('Scatter'),
|
||||
t('Time'),
|
||||
t('Trend'),
|
||||
t('nvd3'),
|
||||
],
|
||||
thumbnail,
|
||||
thumbnailDark,
|
||||
useLegacyApi: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* @deprecated in version 4.0.
|
||||
*/
|
||||
export default class BubbleChartPlugin extends ChartPlugin {
|
||||
constructor() {
|
||||
super({
|
||||
loadChart: () => import('../ReactNVD3'),
|
||||
metadata,
|
||||
transformProps,
|
||||
controlPanel,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,103 +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 { SuperChart, VizType } from '@superset-ui/core';
|
||||
import { BubbleChartPlugin } from '@superset-ui/legacy-preset-chart-nvd3';
|
||||
import { dummyDatasource, withResizableChartDemo } from '@storybook-shared';
|
||||
import data from './data';
|
||||
|
||||
new BubbleChartPlugin().configure({ key: VizType.LegacyBubble }).register();
|
||||
|
||||
export default {
|
||||
title: 'Legacy Chart Plugins/legacy-preset-chart-nvd3/Bubble',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
colorScheme: 'd3Category10',
|
||||
maxBubbleSize: 50,
|
||||
showLegend: true,
|
||||
xLogScale: false,
|
||||
yLogScale: false,
|
||||
},
|
||||
argTypes: {
|
||||
colorScheme: {
|
||||
control: 'select',
|
||||
options: [
|
||||
'supersetColors',
|
||||
'd3Category10',
|
||||
'bnbColors',
|
||||
'googleCategory20c',
|
||||
],
|
||||
},
|
||||
maxBubbleSize: {
|
||||
control: { type: 'range', min: 10, max: 100, step: 5 },
|
||||
},
|
||||
showLegend: { control: 'boolean' },
|
||||
xLogScale: { control: 'boolean' },
|
||||
yLogScale: { control: 'boolean' },
|
||||
},
|
||||
};
|
||||
|
||||
export const Basic = ({
|
||||
colorScheme,
|
||||
maxBubbleSize,
|
||||
showLegend,
|
||||
xLogScale,
|
||||
yLogScale,
|
||||
width,
|
||||
height,
|
||||
}: {
|
||||
colorScheme: string;
|
||||
maxBubbleSize: number;
|
||||
showLegend: boolean;
|
||||
xLogScale: boolean;
|
||||
yLogScale: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
}) => (
|
||||
<SuperChart
|
||||
chartType={VizType.LegacyBubble}
|
||||
width={width}
|
||||
height={height}
|
||||
datasource={dummyDatasource}
|
||||
queriesData={[{ data }]}
|
||||
formData={{
|
||||
annotation_data: {},
|
||||
bottom_margin: 'auto',
|
||||
color_scheme: colorScheme,
|
||||
entity: 'country_name',
|
||||
left_margin: 'auto',
|
||||
max_bubble_size: String(maxBubbleSize),
|
||||
series: 'region',
|
||||
show_legend: showLegend,
|
||||
size: 'sum__SP_POP_TOTL',
|
||||
viz_type: VizType.LegacyBubble,
|
||||
x: 'sum__SP_RUR_TOTL_ZS',
|
||||
x_axis_format: '.3s',
|
||||
x_axis_label: 'Rural Population %',
|
||||
x_axis_showminmax: false,
|
||||
x_log_scale: xLogScale,
|
||||
x_ticks_layout: 'auto',
|
||||
y: 'sum__SP_DYN_LE00_IN',
|
||||
y_axis_format: '.3s',
|
||||
y_axis_label: 'Life Expectancy',
|
||||
y_axis_showminmax: false,
|
||||
y_log_scale: yLogScale,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -1,357 +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 sort-keys, no-magic-numbers */
|
||||
export default [
|
||||
{
|
||||
key: 'East Asia & Pacific',
|
||||
values: [
|
||||
{
|
||||
country_name: 'China',
|
||||
region: 'East Asia & Pacific',
|
||||
sum__SP_POP_TOTL: 1344130000.0,
|
||||
sum__SP_RUR_TOTL_ZS: 49.427,
|
||||
sum__SP_DYN_LE00_IN: 75.042,
|
||||
x: 49.427,
|
||||
y: 75.042,
|
||||
size: 1344130000.0,
|
||||
shape: 'circle',
|
||||
group: 'East Asia & Pacific',
|
||||
},
|
||||
{
|
||||
country_name: 'Indonesia',
|
||||
region: 'East Asia & Pacific',
|
||||
sum__SP_POP_TOTL: 244808254.0,
|
||||
sum__SP_RUR_TOTL_ZS: 49.288,
|
||||
sum__SP_DYN_LE00_IN: 70.3915609756,
|
||||
x: 49.288,
|
||||
y: 70.3915609756,
|
||||
size: 244808254.0,
|
||||
shape: 'circle',
|
||||
group: 'East Asia & Pacific',
|
||||
},
|
||||
{
|
||||
country_name: 'Japan',
|
||||
region: 'East Asia & Pacific',
|
||||
sum__SP_POP_TOTL: 127817277.0,
|
||||
sum__SP_RUR_TOTL_ZS: 8.752,
|
||||
sum__SP_DYN_LE00_IN: 82.5912195122,
|
||||
x: 8.752,
|
||||
y: 82.5912195122,
|
||||
size: 127817277.0,
|
||||
shape: 'circle',
|
||||
group: 'East Asia & Pacific',
|
||||
},
|
||||
{
|
||||
country_name: 'Philippines',
|
||||
region: 'East Asia & Pacific',
|
||||
sum__SP_POP_TOTL: 94501233.0,
|
||||
sum__SP_RUR_TOTL_ZS: 54.983,
|
||||
sum__SP_DYN_LE00_IN: 68.3914878049,
|
||||
x: 54.983,
|
||||
y: 68.3914878049,
|
||||
size: 94501233.0,
|
||||
shape: 'circle',
|
||||
group: 'East Asia & Pacific',
|
||||
},
|
||||
{
|
||||
country_name: 'Vietnam',
|
||||
region: 'East Asia & Pacific',
|
||||
sum__SP_POP_TOTL: 87840000.0,
|
||||
sum__SP_RUR_TOTL_ZS: 68.971,
|
||||
sum__SP_DYN_LE00_IN: 75.457902439,
|
||||
x: 68.971,
|
||||
y: 75.457902439,
|
||||
size: 87840000.0,
|
||||
shape: 'circle',
|
||||
group: 'East Asia & Pacific',
|
||||
},
|
||||
{
|
||||
country_name: 'Thailand',
|
||||
region: 'East Asia & Pacific',
|
||||
sum__SP_POP_TOTL: 66902958.0,
|
||||
sum__SP_RUR_TOTL_ZS: 54.606,
|
||||
sum__SP_DYN_LE00_IN: 74.008902439,
|
||||
x: 54.606,
|
||||
y: 74.008902439,
|
||||
size: 66902958.0,
|
||||
shape: 'circle',
|
||||
group: 'East Asia & Pacific',
|
||||
},
|
||||
{
|
||||
country_name: 'Myanmar',
|
||||
region: 'East Asia & Pacific',
|
||||
sum__SP_POP_TOTL: 52125411.0,
|
||||
sum__SP_RUR_TOTL_ZS: 68.065,
|
||||
sum__SP_DYN_LE00_IN: 64.7612439024,
|
||||
x: 68.065,
|
||||
y: 64.7612439024,
|
||||
size: 52125411.0,
|
||||
shape: 'circle',
|
||||
group: 'East Asia & Pacific',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'South Asia',
|
||||
values: [
|
||||
{
|
||||
country_name: 'India',
|
||||
region: 'South Asia',
|
||||
sum__SP_POP_TOTL: 1247446011.0,
|
||||
sum__SP_RUR_TOTL_ZS: 68.724,
|
||||
sum__SP_DYN_LE00_IN: 65.9584878049,
|
||||
x: 68.724,
|
||||
y: 65.9584878049,
|
||||
size: 1247446011.0,
|
||||
shape: 'circle',
|
||||
group: 'South Asia',
|
||||
},
|
||||
{
|
||||
country_name: 'Pakistan',
|
||||
region: 'South Asia',
|
||||
sum__SP_POP_TOTL: 173669648.0,
|
||||
sum__SP_RUR_TOTL_ZS: 62.993,
|
||||
sum__SP_DYN_LE00_IN: 66.2838780488,
|
||||
x: 62.993,
|
||||
y: 66.2838780488,
|
||||
size: 173669648.0,
|
||||
shape: 'circle',
|
||||
group: 'South Asia',
|
||||
},
|
||||
{
|
||||
country_name: 'Bangladesh',
|
||||
region: 'South Asia',
|
||||
sum__SP_POP_TOTL: 153405612.0,
|
||||
sum__SP_RUR_TOTL_ZS: 68.775,
|
||||
sum__SP_DYN_LE00_IN: 69.891804878,
|
||||
x: 68.775,
|
||||
y: 69.891804878,
|
||||
size: 153405612.0,
|
||||
shape: 'circle',
|
||||
group: 'South Asia',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'North America',
|
||||
values: [
|
||||
{
|
||||
country_name: 'United States',
|
||||
region: 'North America',
|
||||
sum__SP_POP_TOTL: 311721632.0,
|
||||
sum__SP_RUR_TOTL_ZS: 19.06,
|
||||
sum__SP_DYN_LE00_IN: 78.6414634146,
|
||||
x: 19.06,
|
||||
y: 78.6414634146,
|
||||
size: 311721632.0,
|
||||
shape: 'circle',
|
||||
group: 'North America',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'Latin America & Caribbean',
|
||||
values: [
|
||||
{
|
||||
country_name: 'Brazil',
|
||||
region: 'Latin America & Caribbean',
|
||||
sum__SP_POP_TOTL: 200517584.0,
|
||||
sum__SP_RUR_TOTL_ZS: 15.377,
|
||||
sum__SP_DYN_LE00_IN: 73.3473658537,
|
||||
x: 15.377,
|
||||
y: 73.3473658537,
|
||||
size: 200517584.0,
|
||||
shape: 'circle',
|
||||
group: 'Latin America & Caribbean',
|
||||
},
|
||||
{
|
||||
country_name: 'Mexico',
|
||||
region: 'Latin America & Caribbean',
|
||||
sum__SP_POP_TOTL: 120365271.0,
|
||||
sum__SP_RUR_TOTL_ZS: 21.882,
|
||||
sum__SP_DYN_LE00_IN: 76.9141707317,
|
||||
x: 21.882,
|
||||
y: 76.9141707317,
|
||||
size: 120365271.0,
|
||||
shape: 'circle',
|
||||
group: 'Latin America & Caribbean',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'Sub-Saharan Africa',
|
||||
values: [
|
||||
{
|
||||
country_name: 'Nigeria',
|
||||
region: 'Sub-Saharan Africa',
|
||||
sum__SP_POP_TOTL: 163770669.0,
|
||||
sum__SP_RUR_TOTL_ZS: 55.638,
|
||||
sum__SP_DYN_LE00_IN: 51.7102439024,
|
||||
x: 55.638,
|
||||
y: 51.7102439024,
|
||||
size: 163770669.0,
|
||||
shape: 'circle',
|
||||
group: 'Sub-Saharan Africa',
|
||||
},
|
||||
{
|
||||
country_name: 'Ethiopia',
|
||||
region: 'Sub-Saharan Africa',
|
||||
sum__SP_POP_TOTL: 89858696.0,
|
||||
sum__SP_RUR_TOTL_ZS: 82.265,
|
||||
sum__SP_DYN_LE00_IN: 62.2528536585,
|
||||
x: 82.265,
|
||||
y: 62.2528536585,
|
||||
size: 89858696.0,
|
||||
shape: 'circle',
|
||||
group: 'Sub-Saharan Africa',
|
||||
},
|
||||
{
|
||||
country_name: 'Congo, Dem. Rep.',
|
||||
region: 'Sub-Saharan Africa',
|
||||
sum__SP_POP_TOTL: 68087376.0,
|
||||
sum__SP_RUR_TOTL_ZS: 59.558,
|
||||
sum__SP_DYN_LE00_IN: 49.3007073171,
|
||||
x: 59.558,
|
||||
y: 49.3007073171,
|
||||
size: 68087376.0,
|
||||
shape: 'circle',
|
||||
group: 'Sub-Saharan Africa',
|
||||
},
|
||||
{
|
||||
country_name: 'South Africa',
|
||||
region: 'Sub-Saharan Africa',
|
||||
sum__SP_POP_TOTL: 51553479.0,
|
||||
sum__SP_RUR_TOTL_ZS: 37.254,
|
||||
sum__SP_DYN_LE00_IN: 55.2956585366,
|
||||
x: 37.254,
|
||||
y: 55.2956585366,
|
||||
size: 51553479.0,
|
||||
shape: 'circle',
|
||||
group: 'Sub-Saharan Africa',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'Europe & Central Asia',
|
||||
values: [
|
||||
{
|
||||
country_name: 'Russian Federation',
|
||||
region: 'Europe & Central Asia',
|
||||
sum__SP_POP_TOTL: 142960868.0,
|
||||
sum__SP_RUR_TOTL_ZS: 26.268,
|
||||
sum__SP_DYN_LE00_IN: 69.6585365854,
|
||||
x: 26.268,
|
||||
y: 69.6585365854,
|
||||
size: 142960868.0,
|
||||
shape: 'circle',
|
||||
group: 'Europe & Central Asia',
|
||||
},
|
||||
{
|
||||
country_name: 'Germany',
|
||||
region: 'Europe & Central Asia',
|
||||
sum__SP_POP_TOTL: 81797673.0,
|
||||
sum__SP_RUR_TOTL_ZS: 25.512,
|
||||
sum__SP_DYN_LE00_IN: 80.7414634146,
|
||||
x: 25.512,
|
||||
y: 80.7414634146,
|
||||
size: 81797673.0,
|
||||
shape: 'circle',
|
||||
group: 'Europe & Central Asia',
|
||||
},
|
||||
{
|
||||
country_name: 'Turkey',
|
||||
region: 'Europe & Central Asia',
|
||||
sum__SP_POP_TOTL: 73199372.0,
|
||||
sum__SP_RUR_TOTL_ZS: 28.718,
|
||||
sum__SP_DYN_LE00_IN: 74.5404878049,
|
||||
x: 28.718,
|
||||
y: 74.5404878049,
|
||||
size: 73199372.0,
|
||||
shape: 'circle',
|
||||
group: 'Europe & Central Asia',
|
||||
},
|
||||
{
|
||||
country_name: 'France',
|
||||
region: 'Europe & Central Asia',
|
||||
sum__SP_POP_TOTL: 65342776.0,
|
||||
sum__SP_RUR_TOTL_ZS: 21.416,
|
||||
sum__SP_DYN_LE00_IN: 82.1146341463,
|
||||
x: 21.416,
|
||||
y: 82.1146341463,
|
||||
size: 65342776.0,
|
||||
shape: 'circle',
|
||||
group: 'Europe & Central Asia',
|
||||
},
|
||||
{
|
||||
country_name: 'United Kingdom',
|
||||
region: 'Europe & Central Asia',
|
||||
sum__SP_POP_TOTL: 63258918.0,
|
||||
sum__SP_RUR_TOTL_ZS: 18.43,
|
||||
sum__SP_DYN_LE00_IN: 80.9512195122,
|
||||
x: 18.43,
|
||||
y: 80.9512195122,
|
||||
size: 63258918.0,
|
||||
shape: 'circle',
|
||||
group: 'Europe & Central Asia',
|
||||
},
|
||||
{
|
||||
country_name: 'Italy',
|
||||
region: 'Europe & Central Asia',
|
||||
sum__SP_POP_TOTL: 59379449.0,
|
||||
sum__SP_RUR_TOTL_ZS: 31.556,
|
||||
sum__SP_DYN_LE00_IN: 82.187804878,
|
||||
x: 31.556,
|
||||
y: 82.187804878,
|
||||
size: 59379449.0,
|
||||
shape: 'circle',
|
||||
group: 'Europe & Central Asia',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'Middle East & North Africa',
|
||||
values: [
|
||||
{
|
||||
country_name: 'Egypt, Arab Rep.',
|
||||
region: 'Middle East & North Africa',
|
||||
sum__SP_POP_TOTL: 83787634.0,
|
||||
sum__SP_RUR_TOTL_ZS: 57.0,
|
||||
sum__SP_DYN_LE00_IN: 70.6785609756,
|
||||
x: 57.0,
|
||||
y: 70.6785609756,
|
||||
size: 83787634.0,
|
||||
shape: 'circle',
|
||||
group: 'Middle East & North Africa',
|
||||
},
|
||||
{
|
||||
country_name: 'Iran, Islamic Rep.',
|
||||
region: 'Middle East & North Africa',
|
||||
sum__SP_POP_TOTL: 75184322.0,
|
||||
sum__SP_RUR_TOTL_ZS: 28.8,
|
||||
sum__SP_DYN_LE00_IN: 73.4493170732,
|
||||
x: 28.8,
|
||||
y: 73.4493170732,
|
||||
size: 75184322.0,
|
||||
shape: 'circle',
|
||||
group: 'Middle East & North Africa',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -1,76 +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 '@apache-superset/core/translation';
|
||||
import {
|
||||
ControlPanelConfig,
|
||||
getStandardizedControls,
|
||||
sections,
|
||||
} from '@superset-ui/chart-controls';
|
||||
import {
|
||||
xAxisLabel,
|
||||
yAxisLabel,
|
||||
bottomMargin,
|
||||
xTicksLayout,
|
||||
xAxisFormat,
|
||||
yLogScale,
|
||||
yAxisBounds,
|
||||
xAxisShowMinmax,
|
||||
yAxisShowMinmax,
|
||||
leftMargin,
|
||||
timeSeriesSection,
|
||||
} from '../NVD3Controls';
|
||||
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
timeSeriesSection[0],
|
||||
{
|
||||
label: t('Chart Options'),
|
||||
expanded: true,
|
||||
controlSetRows: [['color_scheme']],
|
||||
},
|
||||
{
|
||||
label: t('X Axis'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[xAxisLabel, bottomMargin],
|
||||
[xTicksLayout, xAxisFormat],
|
||||
[xAxisShowMinmax, null],
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('Y Axis'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[yAxisLabel, leftMargin],
|
||||
[yAxisShowMinmax, yLogScale],
|
||||
['y_axis_format', yAxisBounds],
|
||||
],
|
||||
},
|
||||
timeSeriesSection[1],
|
||||
sections.annotations,
|
||||
],
|
||||
formDataOverrides: formData => ({
|
||||
...formData,
|
||||
groupby: getStandardizedControls().popAllColumns(),
|
||||
metrics: getStandardizedControls().popAllMetrics(),
|
||||
}),
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 88 KiB |
@@ -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.
|
||||
*/
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
import { ChartMetadata, ChartPlugin, ChartLabel } from '@superset-ui/core';
|
||||
import transformProps from '../transformProps';
|
||||
import thumbnail from './images/thumbnail.png';
|
||||
import thumbnailDark from './images/thumbnail-dark.png';
|
||||
import example from './images/example.jpg';
|
||||
import exampleDark from './images/example-dark.jpg';
|
||||
import controlPanel from './controlPanel';
|
||||
|
||||
const metadata = new ChartMetadata({
|
||||
category: t('Evolution'),
|
||||
credits: ['http://nvd3.org'],
|
||||
description: t(
|
||||
'Visualizes many different time-series objects in a single chart. This chart is being deprecated and we recommend using the Time-series Chart instead.',
|
||||
),
|
||||
exampleGallery: [{ url: example, urlDark: exampleDark }],
|
||||
label: ChartLabel.Deprecated,
|
||||
name: t('Time-series Percent Change'),
|
||||
tags: [
|
||||
t('Legacy'),
|
||||
t('Time'),
|
||||
t('nvd3'),
|
||||
t('Advanced-Analytics'),
|
||||
t('Comparison'),
|
||||
t('Line'),
|
||||
t('Percentages'),
|
||||
t('Predictive'),
|
||||
t('Trend'),
|
||||
],
|
||||
thumbnail,
|
||||
thumbnailDark,
|
||||
useLegacyApi: true,
|
||||
});
|
||||
|
||||
export default class CompareChartPlugin extends ChartPlugin {
|
||||
constructor() {
|
||||
super({
|
||||
loadChart: () => import('../ReactNVD3'),
|
||||
metadata,
|
||||
transformProps,
|
||||
controlPanel,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,208 +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 { SuperChart, VizType } from '@superset-ui/core';
|
||||
import { CompareChartPlugin } from '@superset-ui/legacy-preset-chart-nvd3';
|
||||
import { dummyDatasource, withResizableChartDemo } from '@storybook-shared';
|
||||
import data from './data';
|
||||
|
||||
new CompareChartPlugin().configure({ key: VizType.Compare }).register();
|
||||
|
||||
export default {
|
||||
title: 'Legacy Chart Plugins/legacy-preset-chart-nvd3/Compare',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
colorScheme: 'd3Category10',
|
||||
contribution: false,
|
||||
yLogScale: false,
|
||||
},
|
||||
argTypes: {
|
||||
colorScheme: {
|
||||
control: 'select',
|
||||
options: [
|
||||
'supersetColors',
|
||||
'd3Category10',
|
||||
'bnbColors',
|
||||
'googleCategory20c',
|
||||
],
|
||||
},
|
||||
contribution: {
|
||||
control: 'boolean',
|
||||
description: 'Compute contribution to total',
|
||||
},
|
||||
yLogScale: { control: 'boolean' },
|
||||
},
|
||||
};
|
||||
|
||||
export const Basic = ({
|
||||
colorScheme,
|
||||
contribution,
|
||||
yLogScale,
|
||||
width,
|
||||
height,
|
||||
}: {
|
||||
colorScheme: string;
|
||||
contribution: boolean;
|
||||
yLogScale: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
}) => (
|
||||
<SuperChart
|
||||
chartType="compare"
|
||||
width={width}
|
||||
height={height}
|
||||
datasource={dummyDatasource}
|
||||
queriesData={[{ data }]}
|
||||
formData={{
|
||||
bottom_margin: 'auto',
|
||||
color_scheme: colorScheme,
|
||||
contribution,
|
||||
left_margin: 'auto',
|
||||
viz_type: VizType.Compare,
|
||||
x_axis_format: 'smart_date',
|
||||
x_axis_label: '',
|
||||
x_axis_showminmax: false,
|
||||
x_ticks_layout: 'auto',
|
||||
y_axis_bounds: [null, null],
|
||||
y_axis_format: '.3s',
|
||||
y_axis_label: '',
|
||||
y_axis_showminmax: false,
|
||||
y_log_scale: yLogScale,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
/* eslint-disable no-magic-numbers */
|
||||
const timeFormatData = [
|
||||
{
|
||||
key: ['Africa and Middle East'],
|
||||
values: [
|
||||
{ x: 1606348800000, y: 3985 },
|
||||
{ x: 1606435200000, y: 5882 },
|
||||
{ x: 1606521600000, y: 7983 },
|
||||
{ x: 1606608000000, y: 16462 },
|
||||
{ x: 1606694400000, y: 5542 },
|
||||
{ x: 1606780800000, y: 2825 },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['Asia'],
|
||||
values: [
|
||||
{ x: 1606348800000, y: 34837 },
|
||||
{ x: 1606435200000, y: 40718 },
|
||||
{ x: 1606521600000, y: 58507 },
|
||||
{ x: 1606608000000, y: 110120 },
|
||||
{ x: 1606694400000, y: 43443 },
|
||||
{ x: 1606780800000, y: 33538 },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['Australia'],
|
||||
values: [
|
||||
{ x: 1606348800000, y: 12975 },
|
||||
{ x: 1606435200000, y: 18471 },
|
||||
{ x: 1606521600000, y: 17880 },
|
||||
{ x: 1606608000000, y: 52204 },
|
||||
{ x: 1606694400000, y: 26690 },
|
||||
{ x: 1606780800000, y: 16423 },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['Europe'],
|
||||
values: [
|
||||
{ x: 1606348800000, y: 127029 },
|
||||
{ x: 1606435200000, y: 177637 },
|
||||
{ x: 1606521600000, y: 172653 },
|
||||
{ x: 1606608000000, y: 203654 },
|
||||
{ x: 1606694400000, y: 79200 },
|
||||
{ x: 1606780800000, y: 45238 },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['LatAm'],
|
||||
values: [
|
||||
{ x: 1606348800000, y: 22513 },
|
||||
{ x: 1606435200000, y: 24594 },
|
||||
{ x: 1606521600000, y: 32578 },
|
||||
{ x: 1606608000000, y: 34733 },
|
||||
{ x: 1606694400000, y: 71696 },
|
||||
{ x: 1606780800000, y: 166611 },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['North America'],
|
||||
values: [
|
||||
{ x: 1606348800000, y: 104596 },
|
||||
{ x: 1606435200000, y: 109850 },
|
||||
{ x: 1606521600000, y: 136873 },
|
||||
{ x: 1606608000000, y: 133243 },
|
||||
{ x: 1606694400000, y: 327739 },
|
||||
{ x: 1606780800000, y: 162711 },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const timeFormat = () => (
|
||||
<SuperChart
|
||||
chartType="compare"
|
||||
width={400}
|
||||
height={400}
|
||||
datasource={dummyDatasource}
|
||||
queriesData={[{ data: timeFormatData }]}
|
||||
formData={{
|
||||
datasource: '24771__table',
|
||||
vizType: VizType.Compare,
|
||||
urlParams: {},
|
||||
timeRangeEndpoints: ['inclusive', 'exclusive'],
|
||||
granularitySqla: '__time',
|
||||
timeGrainSqla: 'P1D',
|
||||
timeRange: 'Last week',
|
||||
metrics: ['random_metric'],
|
||||
adhocFilters: [],
|
||||
groupby: ['dim_origin_region'],
|
||||
timeseriesLimitMetric: null,
|
||||
orderDesc: true,
|
||||
contribution: false,
|
||||
rowLimit: 10000,
|
||||
colorScheme: 'd3Category10',
|
||||
labelColors: {},
|
||||
xAxisLabel: '',
|
||||
bottomMargin: 'auto',
|
||||
xTicksLayout: 'auto',
|
||||
xAxisFormat: 'smart_date',
|
||||
xAxisShowminmax: false,
|
||||
yAxisLabel: '',
|
||||
leftMargin: 'auto',
|
||||
yAxisShowminmax: false,
|
||||
yLogScale: false,
|
||||
yAxisFormat: 'SMART_NUMBER',
|
||||
yAxisBounds: [null, null],
|
||||
rollingType: 'None',
|
||||
comparisonType: 'values',
|
||||
resampleRule: null,
|
||||
resampleMethod: null,
|
||||
annotationLayers: [],
|
||||
appliedTimeExtras: {},
|
||||
where: '',
|
||||
having: '',
|
||||
havingFilters: [],
|
||||
filters: [],
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -1,927 +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 sort-keys, no-magic-numbers */
|
||||
export default [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
values: [
|
||||
{
|
||||
x: -157766400000.0,
|
||||
y: 24703,
|
||||
},
|
||||
{
|
||||
x: -126230400000.0,
|
||||
y: 27861,
|
||||
},
|
||||
{
|
||||
x: -94694400000.0,
|
||||
y: 29436,
|
||||
},
|
||||
{
|
||||
x: -63158400000.0,
|
||||
y: 31463,
|
||||
},
|
||||
{
|
||||
x: -31536000000.0,
|
||||
y: 35718,
|
||||
},
|
||||
{
|
||||
x: 0.0,
|
||||
y: 41758,
|
||||
},
|
||||
{
|
||||
x: 31536000000.0,
|
||||
y: 48172,
|
||||
},
|
||||
{
|
||||
x: 63072000000.0,
|
||||
y: 52092,
|
||||
},
|
||||
{
|
||||
x: 94694400000.0,
|
||||
y: 48217,
|
||||
},
|
||||
{
|
||||
x: 126230400000.0,
|
||||
y: 48476,
|
||||
},
|
||||
{
|
||||
x: 157766400000.0,
|
||||
y: 46438,
|
||||
},
|
||||
{
|
||||
x: 189302400000.0,
|
||||
y: 45086,
|
||||
},
|
||||
{
|
||||
x: 220924800000.0,
|
||||
y: 46610,
|
||||
},
|
||||
{
|
||||
x: 252460800000.0,
|
||||
y: 47107,
|
||||
},
|
||||
{
|
||||
x: 283996800000.0,
|
||||
y: 50514,
|
||||
},
|
||||
{
|
||||
x: 315532800000.0,
|
||||
y: 48969,
|
||||
},
|
||||
{
|
||||
x: 347155200000.0,
|
||||
y: 50108,
|
||||
},
|
||||
{
|
||||
x: 378691200000.0,
|
||||
y: 59055,
|
||||
},
|
||||
{
|
||||
x: 410227200000.0,
|
||||
y: 59188,
|
||||
},
|
||||
{
|
||||
x: 441763200000.0,
|
||||
y: 59859,
|
||||
},
|
||||
{
|
||||
x: 473385600000.0,
|
||||
y: 59516,
|
||||
},
|
||||
{
|
||||
x: 504921600000.0,
|
||||
y: 56633,
|
||||
},
|
||||
{
|
||||
x: 536457600000.0,
|
||||
y: 54466,
|
||||
},
|
||||
{
|
||||
x: 567993600000.0,
|
||||
y: 52996,
|
||||
},
|
||||
{
|
||||
x: 599616000000.0,
|
||||
y: 53205,
|
||||
},
|
||||
{
|
||||
x: 631152000000.0,
|
||||
y: 52322,
|
||||
},
|
||||
{
|
||||
x: 662688000000.0,
|
||||
y: 47109,
|
||||
},
|
||||
{
|
||||
x: 694224000000.0,
|
||||
y: 42470,
|
||||
},
|
||||
{
|
||||
x: 725846400000.0,
|
||||
y: 38257,
|
||||
},
|
||||
{
|
||||
x: 757382400000.0,
|
||||
y: 34823,
|
||||
},
|
||||
{
|
||||
x: 788918400000.0,
|
||||
y: 32728,
|
||||
},
|
||||
{
|
||||
x: 820454400000.0,
|
||||
y: 30988,
|
||||
},
|
||||
{
|
||||
x: 852076800000.0,
|
||||
y: 29179,
|
||||
},
|
||||
{
|
||||
x: 883612800000.0,
|
||||
y: 27083,
|
||||
},
|
||||
{
|
||||
x: 915148800000.0,
|
||||
y: 25700,
|
||||
},
|
||||
{
|
||||
x: 946684800000.0,
|
||||
y: 24959,
|
||||
},
|
||||
{
|
||||
x: 978307200000.0,
|
||||
y: 23180,
|
||||
},
|
||||
{
|
||||
x: 1009843200000.0,
|
||||
y: 21731,
|
||||
},
|
||||
{
|
||||
x: 1041379200000.0,
|
||||
y: 20793,
|
||||
},
|
||||
{
|
||||
x: 1072915200000.0,
|
||||
y: 19739,
|
||||
},
|
||||
{
|
||||
x: 1104537600000.0,
|
||||
y: 19190,
|
||||
},
|
||||
{
|
||||
x: 1136073600000.0,
|
||||
y: 19674,
|
||||
},
|
||||
{
|
||||
x: 1167609600000.0,
|
||||
y: 19986,
|
||||
},
|
||||
{
|
||||
x: 1199145600000.0,
|
||||
y: 17771,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
values: [
|
||||
{
|
||||
x: -157766400000.0,
|
||||
y: 67646,
|
||||
},
|
||||
{
|
||||
x: -126230400000.0,
|
||||
y: 66207,
|
||||
},
|
||||
{
|
||||
x: -94694400000.0,
|
||||
y: 66581,
|
||||
},
|
||||
{
|
||||
x: -63158400000.0,
|
||||
y: 63531,
|
||||
},
|
||||
{
|
||||
x: -31536000000.0,
|
||||
y: 63502,
|
||||
},
|
||||
{
|
||||
x: 0.0,
|
||||
y: 61570,
|
||||
},
|
||||
{
|
||||
x: 31536000000.0,
|
||||
y: 52948,
|
||||
},
|
||||
{
|
||||
x: 63072000000.0,
|
||||
y: 46218,
|
||||
},
|
||||
{
|
||||
x: 94694400000.0,
|
||||
y: 40968,
|
||||
},
|
||||
{
|
||||
x: 126230400000.0,
|
||||
y: 41654,
|
||||
},
|
||||
{
|
||||
x: 157766400000.0,
|
||||
y: 39019,
|
||||
},
|
||||
{
|
||||
x: 189302400000.0,
|
||||
y: 39165,
|
||||
},
|
||||
{
|
||||
x: 220924800000.0,
|
||||
y: 40407,
|
||||
},
|
||||
{
|
||||
x: 252460800000.0,
|
||||
y: 40533,
|
||||
},
|
||||
{
|
||||
x: 283996800000.0,
|
||||
y: 41898,
|
||||
},
|
||||
{
|
||||
x: 315532800000.0,
|
||||
y: 41743,
|
||||
},
|
||||
{
|
||||
x: 347155200000.0,
|
||||
y: 40486,
|
||||
},
|
||||
{
|
||||
x: 378691200000.0,
|
||||
y: 40283,
|
||||
},
|
||||
{
|
||||
x: 410227200000.0,
|
||||
y: 39048,
|
||||
},
|
||||
{
|
||||
x: 441763200000.0,
|
||||
y: 38346,
|
||||
},
|
||||
{
|
||||
x: 473385600000.0,
|
||||
y: 38395,
|
||||
},
|
||||
{
|
||||
x: 504921600000.0,
|
||||
y: 37021,
|
||||
},
|
||||
{
|
||||
x: 536457600000.0,
|
||||
y: 36672,
|
||||
},
|
||||
{
|
||||
x: 567993600000.0,
|
||||
y: 35214,
|
||||
},
|
||||
{
|
||||
x: 599616000000.0,
|
||||
y: 35139,
|
||||
},
|
||||
{
|
||||
x: 631152000000.0,
|
||||
y: 33661,
|
||||
},
|
||||
{
|
||||
x: 662688000000.0,
|
||||
y: 30347,
|
||||
},
|
||||
{
|
||||
x: 694224000000.0,
|
||||
y: 28344,
|
||||
},
|
||||
{
|
||||
x: 725846400000.0,
|
||||
y: 26947,
|
||||
},
|
||||
{
|
||||
x: 757382400000.0,
|
||||
y: 24784,
|
||||
},
|
||||
{
|
||||
x: 788918400000.0,
|
||||
y: 22967,
|
||||
},
|
||||
{
|
||||
x: 820454400000.0,
|
||||
y: 22941,
|
||||
},
|
||||
{
|
||||
x: 852076800000.0,
|
||||
y: 21824,
|
||||
},
|
||||
{
|
||||
x: 883612800000.0,
|
||||
y: 20816,
|
||||
},
|
||||
{
|
||||
x: 915148800000.0,
|
||||
y: 20267,
|
||||
},
|
||||
{
|
||||
x: 946684800000.0,
|
||||
y: 19695,
|
||||
},
|
||||
{
|
||||
x: 978307200000.0,
|
||||
y: 19281,
|
||||
},
|
||||
{
|
||||
x: 1009843200000.0,
|
||||
y: 18600,
|
||||
},
|
||||
{
|
||||
x: 1041379200000.0,
|
||||
y: 18557,
|
||||
},
|
||||
{
|
||||
x: 1072915200000.0,
|
||||
y: 18315,
|
||||
},
|
||||
{
|
||||
x: 1104537600000.0,
|
||||
y: 18017,
|
||||
},
|
||||
{
|
||||
x: 1136073600000.0,
|
||||
y: 17510,
|
||||
},
|
||||
{
|
||||
x: 1167609600000.0,
|
||||
y: 17400,
|
||||
},
|
||||
{
|
||||
x: 1199145600000.0,
|
||||
y: 16049,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['James'],
|
||||
values: [
|
||||
{
|
||||
x: -157766400000.0,
|
||||
y: 67506,
|
||||
},
|
||||
{
|
||||
x: -126230400000.0,
|
||||
y: 65036,
|
||||
},
|
||||
{
|
||||
x: -94694400000.0,
|
||||
y: 61554,
|
||||
},
|
||||
{
|
||||
x: -63158400000.0,
|
||||
y: 60584,
|
||||
},
|
||||
{
|
||||
x: -31536000000.0,
|
||||
y: 59824,
|
||||
},
|
||||
{
|
||||
x: 0.0,
|
||||
y: 61597,
|
||||
},
|
||||
{
|
||||
x: 31536000000.0,
|
||||
y: 54463,
|
||||
},
|
||||
{
|
||||
x: 63072000000.0,
|
||||
y: 46960,
|
||||
},
|
||||
{
|
||||
x: 94694400000.0,
|
||||
y: 42782,
|
||||
},
|
||||
{
|
||||
x: 126230400000.0,
|
||||
y: 41258,
|
||||
},
|
||||
{
|
||||
x: 157766400000.0,
|
||||
y: 39471,
|
||||
},
|
||||
{
|
||||
x: 189302400000.0,
|
||||
y: 38203,
|
||||
},
|
||||
{
|
||||
x: 220924800000.0,
|
||||
y: 39916,
|
||||
},
|
||||
{
|
||||
x: 252460800000.0,
|
||||
y: 39783,
|
||||
},
|
||||
{
|
||||
x: 283996800000.0,
|
||||
y: 39237,
|
||||
},
|
||||
{
|
||||
x: 315532800000.0,
|
||||
y: 39185,
|
||||
},
|
||||
{
|
||||
x: 347155200000.0,
|
||||
y: 38176,
|
||||
},
|
||||
{
|
||||
x: 378691200000.0,
|
||||
y: 38750,
|
||||
},
|
||||
{
|
||||
x: 410227200000.0,
|
||||
y: 36228,
|
||||
},
|
||||
{
|
||||
x: 441763200000.0,
|
||||
y: 35728,
|
||||
},
|
||||
{
|
||||
x: 473385600000.0,
|
||||
y: 35750,
|
||||
},
|
||||
{
|
||||
x: 504921600000.0,
|
||||
y: 33955,
|
||||
},
|
||||
{
|
||||
x: 536457600000.0,
|
||||
y: 32552,
|
||||
},
|
||||
{
|
||||
x: 567993600000.0,
|
||||
y: 32418,
|
||||
},
|
||||
{
|
||||
x: 599616000000.0,
|
||||
y: 32658,
|
||||
},
|
||||
{
|
||||
x: 631152000000.0,
|
||||
y: 32288,
|
||||
},
|
||||
{
|
||||
x: 662688000000.0,
|
||||
y: 30460,
|
||||
},
|
||||
{
|
||||
x: 694224000000.0,
|
||||
y: 28450,
|
||||
},
|
||||
{
|
||||
x: 725846400000.0,
|
||||
y: 26193,
|
||||
},
|
||||
{
|
||||
x: 757382400000.0,
|
||||
y: 24706,
|
||||
},
|
||||
{
|
||||
x: 788918400000.0,
|
||||
y: 22691,
|
||||
},
|
||||
{
|
||||
x: 820454400000.0,
|
||||
y: 21122,
|
||||
},
|
||||
{
|
||||
x: 852076800000.0,
|
||||
y: 20368,
|
||||
},
|
||||
{
|
||||
x: 883612800000.0,
|
||||
y: 19651,
|
||||
},
|
||||
{
|
||||
x: 915148800000.0,
|
||||
y: 18508,
|
||||
},
|
||||
{
|
||||
x: 946684800000.0,
|
||||
y: 17939,
|
||||
},
|
||||
{
|
||||
x: 978307200000.0,
|
||||
y: 17023,
|
||||
},
|
||||
{
|
||||
x: 1009843200000.0,
|
||||
y: 16905,
|
||||
},
|
||||
{
|
||||
x: 1041379200000.0,
|
||||
y: 16832,
|
||||
},
|
||||
{
|
||||
x: 1072915200000.0,
|
||||
y: 16459,
|
||||
},
|
||||
{
|
||||
x: 1104537600000.0,
|
||||
y: 16046,
|
||||
},
|
||||
{
|
||||
x: 1136073600000.0,
|
||||
y: 16139,
|
||||
},
|
||||
{
|
||||
x: 1167609600000.0,
|
||||
y: 15821,
|
||||
},
|
||||
{
|
||||
x: 1199145600000.0,
|
||||
y: 14920,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['John'],
|
||||
values: [
|
||||
{
|
||||
x: -157766400000.0,
|
||||
y: 71390,
|
||||
},
|
||||
{
|
||||
x: -126230400000.0,
|
||||
y: 64858,
|
||||
},
|
||||
{
|
||||
x: -94694400000.0,
|
||||
y: 61480,
|
||||
},
|
||||
{
|
||||
x: -63158400000.0,
|
||||
y: 60754,
|
||||
},
|
||||
{
|
||||
x: -31536000000.0,
|
||||
y: 58644,
|
||||
},
|
||||
{
|
||||
x: 0.0,
|
||||
y: 58348,
|
||||
},
|
||||
{
|
||||
x: 31536000000.0,
|
||||
y: 51382,
|
||||
},
|
||||
{
|
||||
x: 63072000000.0,
|
||||
y: 43028,
|
||||
},
|
||||
{
|
||||
x: 94694400000.0,
|
||||
y: 39061,
|
||||
},
|
||||
{
|
||||
x: 126230400000.0,
|
||||
y: 37553,
|
||||
},
|
||||
{
|
||||
x: 157766400000.0,
|
||||
y: 34970,
|
||||
},
|
||||
{
|
||||
x: 189302400000.0,
|
||||
y: 33876,
|
||||
},
|
||||
{
|
||||
x: 220924800000.0,
|
||||
y: 34103,
|
||||
},
|
||||
{
|
||||
x: 252460800000.0,
|
||||
y: 33895,
|
||||
},
|
||||
{
|
||||
x: 283996800000.0,
|
||||
y: 35305,
|
||||
},
|
||||
{
|
||||
x: 315532800000.0,
|
||||
y: 35131,
|
||||
},
|
||||
{
|
||||
x: 347155200000.0,
|
||||
y: 34761,
|
||||
},
|
||||
{
|
||||
x: 378691200000.0,
|
||||
y: 34560,
|
||||
},
|
||||
{
|
||||
x: 410227200000.0,
|
||||
y: 33047,
|
||||
},
|
||||
{
|
||||
x: 441763200000.0,
|
||||
y: 32484,
|
||||
},
|
||||
{
|
||||
x: 473385600000.0,
|
||||
y: 31397,
|
||||
},
|
||||
{
|
||||
x: 504921600000.0,
|
||||
y: 30103,
|
||||
},
|
||||
{
|
||||
x: 536457600000.0,
|
||||
y: 29462,
|
||||
},
|
||||
{
|
||||
x: 567993600000.0,
|
||||
y: 29301,
|
||||
},
|
||||
{
|
||||
x: 599616000000.0,
|
||||
y: 29751,
|
||||
},
|
||||
{
|
||||
x: 631152000000.0,
|
||||
y: 29011,
|
||||
},
|
||||
{
|
||||
x: 662688000000.0,
|
||||
y: 27727,
|
||||
},
|
||||
{
|
||||
x: 694224000000.0,
|
||||
y: 26156,
|
||||
},
|
||||
{
|
||||
x: 725846400000.0,
|
||||
y: 24918,
|
||||
},
|
||||
{
|
||||
x: 757382400000.0,
|
||||
y: 24119,
|
||||
},
|
||||
{
|
||||
x: 788918400000.0,
|
||||
y: 23174,
|
||||
},
|
||||
{
|
||||
x: 820454400000.0,
|
||||
y: 22104,
|
||||
},
|
||||
{
|
||||
x: 852076800000.0,
|
||||
y: 21330,
|
||||
},
|
||||
{
|
||||
x: 883612800000.0,
|
||||
y: 20556,
|
||||
},
|
||||
{
|
||||
x: 915148800000.0,
|
||||
y: 20280,
|
||||
},
|
||||
{
|
||||
x: 946684800000.0,
|
||||
y: 20032,
|
||||
},
|
||||
{
|
||||
x: 978307200000.0,
|
||||
y: 18839,
|
||||
},
|
||||
{
|
||||
x: 1009843200000.0,
|
||||
y: 17400,
|
||||
},
|
||||
{
|
||||
x: 1041379200000.0,
|
||||
y: 17170,
|
||||
},
|
||||
{
|
||||
x: 1072915200000.0,
|
||||
y: 16381,
|
||||
},
|
||||
{
|
||||
x: 1104537600000.0,
|
||||
y: 15692,
|
||||
},
|
||||
{
|
||||
x: 1136073600000.0,
|
||||
y: 15083,
|
||||
},
|
||||
{
|
||||
x: 1167609600000.0,
|
||||
y: 14348,
|
||||
},
|
||||
{
|
||||
x: 1199145600000.0,
|
||||
y: 13110,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
values: [
|
||||
{
|
||||
x: -157766400000.0,
|
||||
y: 80812,
|
||||
},
|
||||
{
|
||||
x: -126230400000.0,
|
||||
y: 79709,
|
||||
},
|
||||
{
|
||||
x: -94694400000.0,
|
||||
y: 82204,
|
||||
},
|
||||
{
|
||||
x: -63158400000.0,
|
||||
y: 81785,
|
||||
},
|
||||
{
|
||||
x: -31536000000.0,
|
||||
y: 84893,
|
||||
},
|
||||
{
|
||||
x: 0.0,
|
||||
y: 85015,
|
||||
},
|
||||
{
|
||||
x: 31536000000.0,
|
||||
y: 77321,
|
||||
},
|
||||
{
|
||||
x: 63072000000.0,
|
||||
y: 71197,
|
||||
},
|
||||
{
|
||||
x: 94694400000.0,
|
||||
y: 67598,
|
||||
},
|
||||
{
|
||||
x: 126230400000.0,
|
||||
y: 67304,
|
||||
},
|
||||
{
|
||||
x: 157766400000.0,
|
||||
y: 68149,
|
||||
},
|
||||
{
|
||||
x: 189302400000.0,
|
||||
y: 66686,
|
||||
},
|
||||
{
|
||||
x: 220924800000.0,
|
||||
y: 67344,
|
||||
},
|
||||
{
|
||||
x: 252460800000.0,
|
||||
y: 66875,
|
||||
},
|
||||
{
|
||||
x: 283996800000.0,
|
||||
y: 67473,
|
||||
},
|
||||
{
|
||||
x: 315532800000.0,
|
||||
y: 68375,
|
||||
},
|
||||
{
|
||||
x: 347155200000.0,
|
||||
y: 68467,
|
||||
},
|
||||
{
|
||||
x: 378691200000.0,
|
||||
y: 67904,
|
||||
},
|
||||
{
|
||||
x: 410227200000.0,
|
||||
y: 67708,
|
||||
},
|
||||
{
|
||||
x: 441763200000.0,
|
||||
y: 67457,
|
||||
},
|
||||
{
|
||||
x: 473385600000.0,
|
||||
y: 64667,
|
||||
},
|
||||
{
|
||||
x: 504921600000.0,
|
||||
y: 63959,
|
||||
},
|
||||
{
|
||||
x: 536457600000.0,
|
||||
y: 63442,
|
||||
},
|
||||
{
|
||||
x: 567993600000.0,
|
||||
y: 63924,
|
||||
},
|
||||
{
|
||||
x: 599616000000.0,
|
||||
y: 65233,
|
||||
},
|
||||
{
|
||||
x: 631152000000.0,
|
||||
y: 65138,
|
||||
},
|
||||
{
|
||||
x: 662688000000.0,
|
||||
y: 60646,
|
||||
},
|
||||
{
|
||||
x: 694224000000.0,
|
||||
y: 54216,
|
||||
},
|
||||
{
|
||||
x: 725846400000.0,
|
||||
y: 49443,
|
||||
},
|
||||
{
|
||||
x: 757382400000.0,
|
||||
y: 44361,
|
||||
},
|
||||
{
|
||||
x: 788918400000.0,
|
||||
y: 41311,
|
||||
},
|
||||
{
|
||||
x: 820454400000.0,
|
||||
y: 38284,
|
||||
},
|
||||
{
|
||||
x: 852076800000.0,
|
||||
y: 37459,
|
||||
},
|
||||
{
|
||||
x: 883612800000.0,
|
||||
y: 36525,
|
||||
},
|
||||
{
|
||||
x: 915148800000.0,
|
||||
y: 33820,
|
||||
},
|
||||
{
|
||||
x: 946684800000.0,
|
||||
y: 31956,
|
||||
},
|
||||
{
|
||||
x: 978307200000.0,
|
||||
y: 29612,
|
||||
},
|
||||
{
|
||||
x: 1009843200000.0,
|
||||
y: 28156,
|
||||
},
|
||||
{
|
||||
x: 1041379200000.0,
|
||||
y: 27031,
|
||||
},
|
||||
{
|
||||
x: 1072915200000.0,
|
||||
y: 25418,
|
||||
},
|
||||
{
|
||||
x: 1104537600000.0,
|
||||
y: 23678,
|
||||
},
|
||||
{
|
||||
x: 1136073600000.0,
|
||||
y: 22498,
|
||||
},
|
||||
{
|
||||
x: 1167609600000.0,
|
||||
y: 21805,
|
||||
},
|
||||
{
|
||||
x: 1199145600000.0,
|
||||
y: 20271,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -1,57 +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 { SqlaFormData } from '@superset-ui/core';
|
||||
import * as ChartControls from '@superset-ui/chart-controls';
|
||||
import controlPanel from '../../src/TimePivot/controlPanel';
|
||||
|
||||
const { __mockShiftMetric } = ChartControls as typeof ChartControls & {
|
||||
__mockShiftMetric: jest.Mock;
|
||||
};
|
||||
|
||||
jest.mock('@superset-ui/core', () => ({
|
||||
...jest.requireActual('@superset-ui/core'),
|
||||
t: (str: string) => str,
|
||||
}));
|
||||
|
||||
jest.mock('@superset-ui/chart-controls', () => {
|
||||
const original = jest.requireActual('@superset-ui/chart-controls');
|
||||
const mockShiftMetric = jest.fn(() => 'shiftedMetric');
|
||||
return {
|
||||
...original,
|
||||
getStandardizedControls: () => ({
|
||||
shiftMetric: mockShiftMetric,
|
||||
}),
|
||||
__mockShiftMetric: mockShiftMetric,
|
||||
};
|
||||
});
|
||||
|
||||
describe('TimePivot Control Panel Config', () => {
|
||||
test('should override formData metric using getStandardizedControls', () => {
|
||||
const dummyFormData = { someProp: 'test' } as unknown as SqlaFormData;
|
||||
const newFormData = controlPanel.formDataOverrides!(dummyFormData);
|
||||
|
||||
// The original properties are spread correctly.
|
||||
expect(newFormData.someProp).toBe('test');
|
||||
// The metric property should be replaced by the output of shiftMetric.
|
||||
expect(newFormData.metric).toBe('shiftedMetric');
|
||||
|
||||
// Ensure that the mockShiftMetric function was called.
|
||||
expect(__mockShiftMetric).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -17,10 +17,10 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## @superset-ui/legacy-plugin-chart-calendar
|
||||
## @superset-ui/plugin-chart-calendar
|
||||
|
||||
[](https://www.npmjs.com/package/@superset-ui/legacy-plugin-chart-calendar)
|
||||
[](https://libraries.io/npm/@superset-ui%2Flegacy-plugin-chart-calendar)
|
||||
[](https://www.npmjs.com/package/@superset-ui/plugin-chart-calendar)
|
||||
[](https://libraries.io/npm/@superset-ui%2Fplugin-chart-calendar)
|
||||
|
||||
This plugin provides Calendar Heatmap for Superset.
|
||||
|
||||
@@ -30,7 +30,7 @@ Configure `key`, which can be any `string`, and register the plugin. This `key`
|
||||
lookup this chart throughout the app.
|
||||
|
||||
```js
|
||||
import CalendarChartPlugin from '@superset-ui/legacy-plugin-chart-calendar';
|
||||
import CalendarChartPlugin from '@superset-ui/plugin-chart-calendar';
|
||||
|
||||
new CalendarChartPlugin().configure({ key: 'calendar' }).register();
|
||||
```
|
||||
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"name": "@superset-ui/legacy-plugin-chart-calendar",
|
||||
"name": "@superset-ui/plugin-chart-calendar",
|
||||
"version": "0.20.3",
|
||||
"description": "Superset Legacy Chart - Calendar Heatmap",
|
||||
"keywords": [
|
||||
"superset"
|
||||
],
|
||||
"homepage": "https://github.com/apache/superset/tree/master/superset-frontend/plugins/legacy-plugin-chart-calendar#readme",
|
||||
"homepage": "https://github.com/apache/superset/tree/master/superset-frontend/plugins/plugin-chart-calendar#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/superset/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/superset.git",
|
||||
"directory": "superset-frontend/plugins/legacy-plugin-chart-calendar"
|
||||
"directory": "superset-frontend/plugins/plugin-chart-calendar"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"author": "Superset",
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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 {
|
||||
buildQueryContext,
|
||||
QueryFormData,
|
||||
TimeGranularity,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
const SUBDOMAIN_TO_TIME_GRAIN: Record<string, TimeGranularity> = {
|
||||
min: TimeGranularity.MINUTE,
|
||||
hour: TimeGranularity.HOUR,
|
||||
day: TimeGranularity.DAY,
|
||||
week: TimeGranularity.WEEK,
|
||||
month: TimeGranularity.MONTH,
|
||||
year: TimeGranularity.YEAR,
|
||||
};
|
||||
|
||||
/**
|
||||
* Mirrors the legacy CalHeatmapViz.query_obj: a timeseries query whose
|
||||
* time grain is forced from the subdomain granularity control.
|
||||
*/
|
||||
export default function buildQuery(formData: QueryFormData) {
|
||||
const { subdomain_granularity } = formData;
|
||||
const timeGrain =
|
||||
SUBDOMAIN_TO_TIME_GRAIN[(subdomain_granularity as string) ?? 'min'] ??
|
||||
TimeGranularity.MINUTE;
|
||||
return buildQueryContext(formData, baseQueryObject => [
|
||||
{
|
||||
...baseQueryObject,
|
||||
is_timeseries: true,
|
||||
extras: {
|
||||
...baseQueryObject.extras,
|
||||
time_grain_sqla: timeGrain,
|
||||
},
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
@@ -43,13 +43,13 @@ const metadata = new ChartMetadata({
|
||||
],
|
||||
thumbnail,
|
||||
thumbnailDark,
|
||||
useLegacyApi: true,
|
||||
});
|
||||
|
||||
export default class CalendarChartPlugin extends ChartPlugin {
|
||||
constructor() {
|
||||
super({
|
||||
loadChart: () => import('./ReactCalendar'),
|
||||
loadBuildQuery: () => import('./buildQuery'),
|
||||
metadata,
|
||||
transformProps,
|
||||
controlPanel,
|
||||
@@ -18,14 +18,14 @@
|
||||
*/
|
||||
|
||||
import { SuperChart } from '@superset-ui/core';
|
||||
import CalendarChartPlugin from '@superset-ui/legacy-plugin-chart-calendar';
|
||||
import CalendarChartPlugin from '@superset-ui/plugin-chart-calendar';
|
||||
import data from './data';
|
||||
import { dummyDatasource, withResizableChartDemo } from '@storybook-shared';
|
||||
|
||||
new CalendarChartPlugin().configure({ key: 'calendar' }).register();
|
||||
|
||||
export default {
|
||||
title: 'Legacy Chart Plugins/legacy-plugin-chart-calendar',
|
||||
title: 'Chart Plugins/plugin-chart-calendar',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
cellSize: 10,
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* 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 '@apache-superset/core/translation';
|
||||
import { DTTM_ALIAS } from '@superset-ui/core';
|
||||
|
||||
export interface CalHeatmapPayload {
|
||||
data: Record<string, Record<string, unknown>>;
|
||||
start: number;
|
||||
domain?: string;
|
||||
subdomain?: string;
|
||||
range: number;
|
||||
}
|
||||
|
||||
const daysInMonth = (year: number, month: number) =>
|
||||
new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
||||
|
||||
/** Adds calendar months, clamping the day like dateutil.relativedelta. */
|
||||
const addMonths = (date: Date, months: number): Date => {
|
||||
const totalMonths = date.getUTCFullYear() * 12 + date.getUTCMonth() + months;
|
||||
const year = Math.floor(totalMonths / 12);
|
||||
const month = totalMonths % 12;
|
||||
const day = Math.min(date.getUTCDate(), daysInMonth(year, month));
|
||||
return new Date(
|
||||
Date.UTC(
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
date.getUTCHours(),
|
||||
date.getUTCMinutes(),
|
||||
date.getUTCSeconds(),
|
||||
date.getUTCMilliseconds(),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calendar delta between two dates with dateutil.relativedelta semantics:
|
||||
* whole months first, then remaining days (weeks = days // 7).
|
||||
*/
|
||||
export const calendarDelta = (start: Date, end: Date) => {
|
||||
let months =
|
||||
(end.getUTCFullYear() - start.getUTCFullYear()) * 12 +
|
||||
(end.getUTCMonth() - start.getUTCMonth());
|
||||
if (addMonths(start, months) > end) {
|
||||
months -= 1;
|
||||
}
|
||||
const anchor = addMonths(start, months);
|
||||
const days = Math.floor(
|
||||
(end.getTime() - anchor.getTime()) / (24 * 60 * 60 * 1000),
|
||||
);
|
||||
return {
|
||||
years: Math.trunc(months / 12),
|
||||
months: months % 12,
|
||||
weeks: Math.floor(days / 7),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Ports the legacy CalHeatmapViz.get_data reshape: per-metric value maps
|
||||
* keyed by unix seconds, plus the domain range computed from the query's
|
||||
* time bounds exactly like the backend's relativedelta arithmetic.
|
||||
*/
|
||||
export default function transformData(
|
||||
records: Record<string, unknown>[],
|
||||
metricLabels: string[],
|
||||
fromDttm: number | null | undefined,
|
||||
toDttm: number | null | undefined,
|
||||
domain: string,
|
||||
subdomain: string,
|
||||
): CalHeatmapPayload {
|
||||
if (fromDttm == null || toDttm == null) {
|
||||
throw new Error(t('Please provide both time bounds (Since and Until)'));
|
||||
}
|
||||
const data: Record<string, Record<string, unknown>> = {};
|
||||
metricLabels.forEach(metric => {
|
||||
const values: Record<string, unknown> = {};
|
||||
records.forEach(record => {
|
||||
const timestamp = record[DTTM_ALIAS];
|
||||
if (timestamp != null) {
|
||||
values[String((timestamp as number) / 1000)] = record[metric];
|
||||
}
|
||||
});
|
||||
data[metric] = values;
|
||||
});
|
||||
|
||||
const start = new Date(fromDttm);
|
||||
const end = new Date(toDttm);
|
||||
const delta = calendarDelta(start, end);
|
||||
const diffSecs = (toDttm - fromDttm) / 1000;
|
||||
|
||||
let range: number;
|
||||
if (domain === 'year') {
|
||||
range = end.getUTCFullYear() - start.getUTCFullYear() + 1;
|
||||
} else if (domain === 'month') {
|
||||
range = delta.years * 12 + delta.months + 1;
|
||||
} else if (domain === 'week') {
|
||||
range = delta.years * 53 + delta.weeks + 1;
|
||||
} else if (domain === 'day') {
|
||||
range = Math.floor(diffSecs / (24 * 60 * 60)) + 1;
|
||||
} else {
|
||||
range = Math.floor(diffSecs / (60 * 60)) + 1;
|
||||
}
|
||||
|
||||
return { data, start: fromDttm, domain, subdomain, range };
|
||||
}
|
||||
@@ -17,8 +17,15 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { ChartProps, getNumberFormatter } from '@superset-ui/core';
|
||||
import {
|
||||
ChartProps,
|
||||
ensureIsArray,
|
||||
getMetricLabel,
|
||||
getNumberFormatter,
|
||||
QueryFormMetric,
|
||||
} from '@superset-ui/core';
|
||||
import { getFormattedUTCTime } from './utils';
|
||||
import transformData from './transformData';
|
||||
|
||||
export default function transformProps(chartProps: ChartProps) {
|
||||
const { height, formData, queriesData, datasource } = chartProps;
|
||||
@@ -42,9 +49,29 @@ export default function transformProps(chartProps: ChartProps) {
|
||||
getFormattedUTCTime(ts, xAxisTimeFormat);
|
||||
const valueFormatter = getNumberFormatter(yAxisFormat);
|
||||
|
||||
// The legacy explore_json endpoint computed the per-metric value maps
|
||||
// and domain range server-side; v1 responses arrive as flat records.
|
||||
const {
|
||||
data: rawData,
|
||||
from_dttm: fromDttm,
|
||||
to_dttm: toDttm,
|
||||
} = queriesData[0];
|
||||
const data = Array.isArray(rawData)
|
||||
? transformData(
|
||||
rawData,
|
||||
ensureIsArray(formData.metrics as QueryFormMetric[]).map(
|
||||
getMetricLabel,
|
||||
),
|
||||
fromDttm,
|
||||
toDttm,
|
||||
domainGranularity,
|
||||
subdomainGranularity,
|
||||
)
|
||||
: rawData;
|
||||
|
||||
return {
|
||||
height,
|
||||
data: queriesData[0].data,
|
||||
data,
|
||||
cellPadding,
|
||||
cellRadius,
|
||||
cellSize,
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 { QueryFormData } from '@superset-ui/core';
|
||||
import buildQuery from '../src/buildQuery';
|
||||
|
||||
const formData: QueryFormData = {
|
||||
datasource: '5__table',
|
||||
granularity_sqla: 'ds',
|
||||
time_range: 'Last year',
|
||||
viz_type: 'cal_heatmap',
|
||||
metrics: ['sum__num'],
|
||||
domain_granularity: 'month',
|
||||
subdomain_granularity: 'day',
|
||||
};
|
||||
|
||||
test('forces the time grain from the subdomain granularity', () => {
|
||||
const [query] = buildQuery(formData).queries;
|
||||
expect(query.extras?.time_grain_sqla).toEqual('P1D');
|
||||
expect(query.is_timeseries).toBe(true);
|
||||
expect(query.metrics).toEqual(['sum__num']);
|
||||
});
|
||||
|
||||
test('defaults the time grain to minutes like the legacy backend', () => {
|
||||
const [query] = buildQuery({
|
||||
...formData,
|
||||
subdomain_granularity: undefined,
|
||||
}).queries;
|
||||
expect(query.extras?.time_grain_sqla).toEqual('PT1M');
|
||||
});
|
||||
@@ -16,18 +16,8 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { ChartProps } from '@superset-ui/core';
|
||||
import controlPanel from '../src/controlPanel';
|
||||
|
||||
export default function transformProps(chartProps: ChartProps) {
|
||||
const { width, height, formData, queriesData } = chartProps;
|
||||
const { yAxisFormat, colorScheme, sliceId } = formData;
|
||||
|
||||
return {
|
||||
colorScheme,
|
||||
data: queriesData[0].data,
|
||||
height,
|
||||
numberFormat: yAxisFormat,
|
||||
width,
|
||||
sliceId,
|
||||
};
|
||||
}
|
||||
test('exposes a datetime column control because the query is is_timeseries', () => {
|
||||
expect(JSON.stringify(controlPanel)).toContain('granularity_sqla');
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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 transformData, { calendarDelta } from '../src/transformData';
|
||||
|
||||
const jan1 = Date.UTC(2024, 0, 1); // 1704067200000
|
||||
const jan2 = Date.UTC(2024, 0, 2);
|
||||
|
||||
test('keys per-metric values by unix seconds like the legacy backend', () => {
|
||||
const { data, start } = transformData(
|
||||
[
|
||||
{ __timestamp: jan1, sum__num: 10 },
|
||||
{ __timestamp: jan2, sum__num: 20 },
|
||||
],
|
||||
['sum__num'],
|
||||
jan1,
|
||||
Date.UTC(2024, 11, 31),
|
||||
'month',
|
||||
'day',
|
||||
);
|
||||
expect(data.sum__num).toEqual({
|
||||
'1704067200': 10,
|
||||
'1704153600': 20,
|
||||
});
|
||||
expect(start).toEqual(jan1);
|
||||
});
|
||||
|
||||
test('throws when time bounds are missing', () => {
|
||||
expect(() =>
|
||||
transformData([], ['sum__num'], null, jan1, 'month', 'day'),
|
||||
).toThrow('time bounds');
|
||||
});
|
||||
|
||||
test.each([
|
||||
['year', Date.UTC(2022, 5, 15), Date.UTC(2024, 1, 1), 3],
|
||||
// Jan 15 -> Apr 10 is 2 whole months + 26 days => 2 + 1
|
||||
['month', Date.UTC(2024, 0, 15), Date.UTC(2024, 3, 10), 3],
|
||||
['day', jan1, Date.UTC(2024, 0, 8, 12), 8],
|
||||
['hour', jan1, Date.UTC(2024, 0, 1, 5, 30), 6],
|
||||
])('computes the %s domain range', (domain, start, end, expected) => {
|
||||
const { range } = transformData(
|
||||
[],
|
||||
['m'],
|
||||
start as number,
|
||||
end as number,
|
||||
domain as string,
|
||||
'day',
|
||||
);
|
||||
expect(range).toEqual(expected);
|
||||
});
|
||||
|
||||
test('computes week ranges with relativedelta semantics', () => {
|
||||
// 2024-01-01 -> 2024-03-20: 2 full months + 19 days => weeks = 2
|
||||
const { range } = transformData(
|
||||
[],
|
||||
['m'],
|
||||
Date.UTC(2024, 0, 1),
|
||||
Date.UTC(2024, 2, 20),
|
||||
'week',
|
||||
'day',
|
||||
);
|
||||
expect(range).toEqual(0 * 53 + 2 + 1);
|
||||
});
|
||||
|
||||
test('calendarDelta matches dateutil for month-end clamping', () => {
|
||||
// Jan 31 -> Feb 29 is a full month in dateutil terms (clamped day)
|
||||
expect(
|
||||
calendarDelta(
|
||||
new Date(Date.UTC(2024, 0, 31)),
|
||||
new Date(Date.UTC(2024, 1, 29)),
|
||||
),
|
||||
).toEqual({
|
||||
years: 0,
|
||||
months: 1,
|
||||
weeks: 0,
|
||||
});
|
||||
});
|
||||
@@ -17,10 +17,10 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## @superset-ui/legacy-plugin-chart-chord
|
||||
## @superset-ui/plugin-chart-chord
|
||||
|
||||
[](https://www.npmjs.com/package/@superset-ui/legacy-plugin-chart-chord)
|
||||
[](https://libraries.io/npm/@superset-ui%2Flegacy-plugin-chart-chord)
|
||||
[](https://www.npmjs.com/package/@superset-ui/plugin-chart-chord)
|
||||
[](https://libraries.io/npm/@superset-ui%2Fplugin-chart-chord)
|
||||
|
||||
This plugin provides Chord Diagram for Superset.
|
||||
|
||||
@@ -30,7 +30,7 @@ Configure `key`, which can be any `string`, and register the plugin. This `key`
|
||||
lookup this chart throughout the app.
|
||||
|
||||
```js
|
||||
import ChordChartPlugin from '@superset-ui/legacy-plugin-chart-chord';
|
||||
import ChordChartPlugin from '@superset-ui/plugin-chart-chord';
|
||||
|
||||
new ChordChartPlugin().configure({ key: 'chord' }).register();
|
||||
```
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@superset-ui/legacy-plugin-chart-chord",
|
||||
"name": "@superset-ui/plugin-chart-chord",
|
||||
"version": "0.20.3",
|
||||
"description": "Superset Legacy Chart - Chord Diagram",
|
||||
"sideEffects": [
|
||||
@@ -14,7 +14,7 @@
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/superset.git",
|
||||
"directory": "superset-frontend/plugins/legacy-plugin-chart-chord"
|
||||
"directory": "superset-frontend/plugins/plugin-chart-chord"
|
||||
},
|
||||
"keywords": [
|
||||
"superset"
|
||||
@@ -24,7 +24,7 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/superset/issues"
|
||||
},
|
||||
"homepage": "https://github.com/apache/superset/tree/master/superset-frontend/plugins/legacy-plugin-chart-chord#readme",
|
||||
"homepage": "https://github.com/apache/superset/tree/master/superset-frontend/plugins/plugin-chart-chord#readme",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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 {
|
||||
buildQueryContext,
|
||||
ensureIsArray,
|
||||
QueryFormColumn,
|
||||
QueryFormData,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
/**
|
||||
* Mirrors the legacy ChordViz.query_obj: one query grouped by the source
|
||||
* (groupby) and target (columns) dimensions, selecting the single metric,
|
||||
* ordered by that metric when sort_by_metric is on.
|
||||
*/
|
||||
export default function buildQuery(formData: QueryFormData) {
|
||||
const { groupby, columns, metric, sort_by_metric } = formData;
|
||||
const source = ensureIsArray(
|
||||
groupby as QueryFormColumn | QueryFormColumn[],
|
||||
)[0];
|
||||
const target = ensureIsArray(
|
||||
columns as QueryFormColumn | QueryFormColumn[],
|
||||
)[0];
|
||||
return buildQueryContext(formData, baseQueryObject => [
|
||||
{
|
||||
...baseQueryObject,
|
||||
columns: [source, target].filter(column => column != null),
|
||||
metrics: metric ? [metric] : [],
|
||||
orderby: sort_by_metric && metric ? [[metric, false]] : undefined,
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |
@@ -39,16 +39,16 @@ const metadata = new ChartMetadata({
|
||||
},
|
||||
],
|
||||
name: t('Chord Diagram'),
|
||||
tags: [t('Circular'), t('Legacy'), t('Proportional'), t('Relational')],
|
||||
tags: [t('Circular'), t('Proportional'), t('Relational')],
|
||||
thumbnail,
|
||||
thumbnailDark,
|
||||
useLegacyApi: true,
|
||||
});
|
||||
|
||||
export default class ChordChartPlugin extends ChartPlugin {
|
||||
constructor() {
|
||||
super({
|
||||
loadChart: () => import('./ReactChord'),
|
||||
loadBuildQuery: () => import('./buildQuery'),
|
||||
metadata,
|
||||
transformProps,
|
||||
controlPanel,
|
||||
@@ -18,14 +18,14 @@
|
||||
*/
|
||||
|
||||
import { SuperChart, VizType } from '@superset-ui/core';
|
||||
import ChordChartPlugin from '@superset-ui/legacy-plugin-chart-chord';
|
||||
import ChordChartPlugin from '@superset-ui/plugin-chart-chord';
|
||||
import data from './data';
|
||||
import { withResizableChartDemo } from '@storybook-shared';
|
||||
|
||||
new ChordChartPlugin().configure({ key: VizType.Chord }).register();
|
||||
|
||||
export default {
|
||||
title: 'Legacy Chart Plugins/legacy-plugin-chart-chord',
|
||||
title: 'Chart Plugins/plugin-chart-chord',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
colorScheme: 'd3Category10',
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 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 {
|
||||
ChartProps,
|
||||
ensureIsArray,
|
||||
getColumnLabel,
|
||||
getMetricLabel,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
interface ChordData {
|
||||
nodes: unknown[];
|
||||
matrix: unknown[][];
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the square adjacency matrix that d3.chord expects, the way the
|
||||
* legacy explore_json endpoint used to server-side: nodes are the union
|
||||
* of source and target values, matrix[target][source] holds the
|
||||
* (directional) metric value.
|
||||
*/
|
||||
function buildChordData(
|
||||
records: Record<string, unknown>[],
|
||||
sourceLabel: string,
|
||||
targetLabel: string,
|
||||
metricLabel: string,
|
||||
): ChordData {
|
||||
const nodes = Array.from(
|
||||
new Set(
|
||||
records.flatMap(record => [record[sourceLabel], record[targetLabel]]),
|
||||
),
|
||||
);
|
||||
const values = new Map<unknown, Map<unknown, unknown>>();
|
||||
records.forEach(record => {
|
||||
const source = record[sourceLabel];
|
||||
if (!values.has(source)) {
|
||||
values.set(source, new Map());
|
||||
}
|
||||
values.get(source)!.set(record[targetLabel], record[metricLabel]);
|
||||
});
|
||||
return {
|
||||
nodes,
|
||||
matrix: nodes.map(target =>
|
||||
nodes.map(source => values.get(source)?.get(target) ?? 0),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
export default function transformProps(chartProps: ChartProps) {
|
||||
const { width, height, formData, queriesData } = chartProps;
|
||||
const { yAxisFormat, colorScheme, sliceId, groupby, columns, metric } =
|
||||
formData;
|
||||
|
||||
const rawData = queriesData[0].data;
|
||||
const data =
|
||||
Array.isArray(rawData) && metric
|
||||
? buildChordData(
|
||||
rawData,
|
||||
getColumnLabel(ensureIsArray(groupby)[0]),
|
||||
getColumnLabel(ensureIsArray(columns)[0]),
|
||||
getMetricLabel(metric),
|
||||
)
|
||||
: // legacy explore_json payloads arrive pre-shaped
|
||||
rawData;
|
||||
|
||||
return {
|
||||
colorScheme,
|
||||
data,
|
||||
height,
|
||||
numberFormat: yAxisFormat,
|
||||
width,
|
||||
sliceId,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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 { QueryFormData } from '@superset-ui/core';
|
||||
import buildQuery from '../src/buildQuery';
|
||||
|
||||
const formData: QueryFormData = {
|
||||
datasource: '5__table',
|
||||
granularity_sqla: 'ds',
|
||||
time_range: 'No filter',
|
||||
viz_type: 'chord',
|
||||
groupby: ['source_col'],
|
||||
columns: ['target_col'],
|
||||
metric: 'sum__value',
|
||||
};
|
||||
|
||||
test('groups by source then target and selects the single metric', () => {
|
||||
const [query] = buildQuery(formData).queries;
|
||||
expect(query.columns).toEqual(['source_col', 'target_col']);
|
||||
expect(query.metrics).toEqual(['sum__value']);
|
||||
expect(query.orderby).toBeUndefined();
|
||||
});
|
||||
|
||||
test('orders by the metric descending when sort_by_metric is on', () => {
|
||||
const [query] = buildQuery({ ...formData, sort_by_metric: true }).queries;
|
||||
expect(query.orderby).toEqual([['sum__value', false]]);
|
||||
});
|
||||
|
||||
test('handles bare-string source/target as stored by the single-value controls', () => {
|
||||
const [query] = buildQuery({
|
||||
...formData,
|
||||
groupby: 'source_col',
|
||||
columns: 'target_col',
|
||||
} as unknown as QueryFormData).queries;
|
||||
expect(query.columns).toEqual(['source_col', 'target_col']);
|
||||
});
|
||||
|
||||
test('maps legacy granularity_sqla saved form data', () => {
|
||||
const [query] = buildQuery(formData).queries;
|
||||
expect(query.granularity).toEqual('ds');
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* 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 { supersetTheme } from '@apache-superset/core/theme';
|
||||
import { ChartProps } from '@superset-ui/core';
|
||||
import transformProps from '../src/transformProps';
|
||||
|
||||
const baseChartProps = {
|
||||
width: 800,
|
||||
height: 600,
|
||||
datasource: {},
|
||||
theme: supersetTheme,
|
||||
hooks: {},
|
||||
};
|
||||
|
||||
const formData = {
|
||||
groupby: 'source_col',
|
||||
columns: 'target_col',
|
||||
metric: 'sum__value',
|
||||
yAxisFormat: '.2f',
|
||||
colorScheme: 'd3Category10',
|
||||
sliceId: 1,
|
||||
};
|
||||
|
||||
test('builds the chord node list and matrix from v1 records', () => {
|
||||
const chartProps = new ChartProps({
|
||||
...baseChartProps,
|
||||
formData,
|
||||
queriesData: [
|
||||
{
|
||||
data: [
|
||||
{ source_col: 'a', target_col: 'b', sum__value: 10 },
|
||||
{ source_col: 'b', target_col: 'a', sum__value: 5 },
|
||||
{ source_col: 'a', target_col: 'c', sum__value: 2 },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
const { data } = transformProps(chartProps) as {
|
||||
data: { nodes: string[]; matrix: number[][] };
|
||||
};
|
||||
expect(data.nodes).toEqual(['a', 'b', 'c']);
|
||||
// matrix[targetIndex][sourceIndex], matching the legacy backend layout
|
||||
expect(data.matrix).toEqual([
|
||||
[0, 5, 0], // into a: from a, b, c
|
||||
[10, 0, 0], // into b
|
||||
[2, 0, 0], // into c
|
||||
]);
|
||||
});
|
||||
|
||||
test('keeps the last value for duplicate source/target pairs', () => {
|
||||
const chartProps = new ChartProps({
|
||||
...baseChartProps,
|
||||
formData,
|
||||
queriesData: [
|
||||
{
|
||||
data: [
|
||||
{ source_col: 'a', target_col: 'b', sum__value: 1 },
|
||||
{ source_col: 'a', target_col: 'b', sum__value: 9 },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
const { data } = transformProps(chartProps) as {
|
||||
data: { nodes: string[]; matrix: number[][] };
|
||||
};
|
||||
expect(data.matrix[1][0]).toEqual(9);
|
||||
});
|
||||
|
||||
test('passes through legacy pre-shaped payloads', () => {
|
||||
const legacyPayload = { nodes: ['a'], matrix: [[0]] };
|
||||
const chartProps = new ChartProps({
|
||||
...baseChartProps,
|
||||
formData,
|
||||
queriesData: [{ data: legacyPayload }],
|
||||
});
|
||||
const { data } = transformProps(chartProps) as { data: unknown };
|
||||
expect(data).toEqual(legacyPayload);
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": false,
|
||||
"emitDeclarationOnly": false
|
||||
},
|
||||
"extends": "../../../tsconfig.json",
|
||||
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
|
||||
}
|
||||
@@ -17,10 +17,10 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## @superset-ui/legacy-plugin-chart-country-map
|
||||
## @superset-ui/plugin-chart-country-map
|
||||
|
||||
[](https://www.npmjs.com/package/@superset-ui/legacy-plugin-chart-country-map)
|
||||
[](https://libraries.io/npm/@superset-ui%2Flegacy-plugin-chart-country-map)
|
||||
[](https://www.npmjs.com/package/@superset-ui/plugin-chart-country-map)
|
||||
[](https://libraries.io/npm/@superset-ui%2Fplugin-chart-country-map)
|
||||
|
||||
This plugin provides Country Map for Superset.
|
||||
|
||||
@@ -30,7 +30,7 @@ Configure `key`, which can be any `string`, and register the plugin. This `key`
|
||||
lookup this chart throughout the app.
|
||||
|
||||
```js
|
||||
import CountryMapChartPlugin from '@superset-ui/legacy-plugin-chart-country-map';
|
||||
import CountryMapChartPlugin from '@superset-ui/plugin-chart-country-map';
|
||||
|
||||
new CountryMapChartPlugin().configure({ key: 'country-map' }).register();
|
||||
```
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@superset-ui/legacy-plugin-chart-country-map",
|
||||
"name": "@superset-ui/plugin-chart-country-map",
|
||||
"version": "0.20.3",
|
||||
"description": "Superset Legacy Chart - Country Map",
|
||||
"main": "lib/index.js",
|
||||
@@ -11,7 +11,7 @@
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/superset.git",
|
||||
"directory": "superset-frontend/plugins/legacy-plugin-chart-country-map"
|
||||
"directory": "superset-frontend/plugins/plugin-chart-country-map"
|
||||
},
|
||||
"keywords": [
|
||||
"superset"
|
||||
@@ -21,7 +21,7 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/superset/issues"
|
||||
},
|
||||
"homepage": "https://github.com/apache/superset/tree/master/superset-frontend/plugins/legacy-plugin-chart-country-map#readme",
|
||||
"homepage": "https://github.com/apache/superset/tree/master/superset-frontend/plugins/plugin-chart-country-map#readme",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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 { buildQueryContext, QueryFormData } from '@superset-ui/core';
|
||||
|
||||
/**
|
||||
* Mirrors the legacy CountryMapViz.query_obj: one query grouped by the
|
||||
* ISO-code entity column, selecting the single metric.
|
||||
*/
|
||||
export default function buildQuery(formData: QueryFormData) {
|
||||
const { entity, metric } = formData;
|
||||
return buildQueryContext(formData, baseQueryObject => [
|
||||
{
|
||||
...baseQueryObject,
|
||||
columns: entity ? [entity] : [],
|
||||
metrics: metric ? [metric] : [],
|
||||
},
|
||||
]);
|
||||
}
|
||||