Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffdaf9e6b8 | ||
|
|
3b164e4270 | ||
|
|
bf294cfa43 | ||
|
|
42e4030104 | ||
|
|
8181917f79 | ||
|
|
d14ab29dcb | ||
|
|
a75665b014 | ||
|
|
db5cd1aa38 | ||
|
|
abb6dd6e39 | ||
|
|
4a587b8539 | ||
|
|
127a6f92a6 | ||
|
|
25481799f6 | ||
|
|
1da7a7fdb1 | ||
|
|
185b5938ba | ||
|
|
503309531f | ||
|
|
44a86b725f | ||
|
|
38727906a2 | ||
|
|
2a9c5acb01 | ||
|
|
d8b97e31fa | ||
|
|
bd03440ac8 | ||
|
|
a6c478c59d | ||
|
|
fd36419ca2 | ||
|
|
d80f4c841d | ||
|
|
6baa467f59 | ||
|
|
b18015f63b | ||
|
|
eb8592d4bf | ||
|
|
55af4685a2 | ||
|
|
c901f01693 | ||
|
|
4c894affb2 | ||
|
|
0f9049608a | ||
|
|
91b1a6cac5 | ||
|
|
86a328ca9e | ||
|
|
38ba4a69bf | ||
|
|
280253b1fb | ||
|
|
79c2cd367d | ||
|
|
fd6a0a60a6 | ||
|
|
c2b5311f47 | ||
|
|
70a82a28bf | ||
|
|
f348cf425d | ||
|
|
74196cf694 | ||
|
|
fe06ebe796 | ||
|
|
f1411ccd6c | ||
|
|
1770823f0a | ||
|
|
b7b873321d | ||
|
|
d363cabec9 | ||
|
|
8683d1608e | ||
|
|
14583b6a5f | ||
|
|
27498d26aa | ||
|
|
39e66476e1 | ||
|
|
8153a82489 | ||
|
|
448eb25d76 | ||
|
|
9cec7411e9 | ||
|
|
ae66b697e5 | ||
|
|
22fb1b3a44 | ||
|
|
7dd6ce835f | ||
|
|
4f2147009f | ||
|
|
2ecce20e48 | ||
|
|
01a9fdc621 |
@@ -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
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
|
||||
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@@ -75,6 +75,6 @@ jobs:
|
||||
# queries: security-extended,security-and-quality
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
|
||||
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
@@ -182,11 +182,6 @@ jobs:
|
||||
docker run --rm $TAG bash -c \
|
||||
"npm ls --all --package-lock-only --depth=0 --json > /dev/null"
|
||||
|
||||
- name: Build Plugins Packages
|
||||
run: |
|
||||
docker run --rm $TAG bash -c \
|
||||
"npm run plugins:build"
|
||||
|
||||
test-storybook:
|
||||
needs: frontend-build
|
||||
if: needs.frontend-build.outputs.should-run == 'true'
|
||||
|
||||
@@ -138,6 +138,7 @@ PROJECT.md
|
||||
.aider*
|
||||
.claude_rc*
|
||||
.claude/settings.local.json
|
||||
.claude/worktrees/
|
||||
.env.local
|
||||
oxc-custom-build/
|
||||
*.code-workspace
|
||||
|
||||
@@ -24,6 +24,8 @@ assists people when migrating to a new version.
|
||||
|
||||
## Next
|
||||
|
||||
- [42393](https://github.com/apache/superset/pull/42393): Exported dataset YAML now carries a `uuid` for each metric and column so that custom folder assignments (which reference metrics/columns by UUID) survive an import into another workspace. This affects any export bundle that contains datasets, not just a dataset export: chart, dashboard, database and full-asset exports all embed the same dataset YAML, so a dashboard exported from this release also fails to import into an older one even though no dataset was exported directly. As with `folders` and `currency_code_column`, the affected `datasets/` files fail schema validation (`Unknown field: uuid`) when imported into Superset releases that predate this change; regenerate or hand-edit exports for older targets in mixed-version fleets.
|
||||
|
||||
### Soft delete is on by default, and purging is live
|
||||
|
||||
`SOFT_DELETE` now ships **on** (`DEFAULT_FEATURE_FLAGS`), so deleting a
|
||||
@@ -52,6 +54,33 @@ One caveat on turning soft delete back off: objects archived while it was on are
|
||||
**resurrected** into normal listings, since the rows were never removed — an
|
||||
emergency stop rather than a clean rollback.
|
||||
|
||||
### Version history is on by default
|
||||
|
||||
`VERSION_HISTORY` and `ENABLE_VERSIONING_CAPTURE` now both ship **on**. Every
|
||||
save of a chart, dashboard, or dataset writes version rows, and the version
|
||||
history panel appears on Explore and Dashboard pages. The two flip together
|
||||
deliberately: a panel with capture off renders an empty "No history yet" that
|
||||
misrepresents the entity as unchanged.
|
||||
|
||||
**What operators should expect:**
|
||||
|
||||
- **Storage growth.** Capture writes shadow rows per save, so the metadata
|
||||
database grows with edit volume. The `version_history.prune_old_versions`
|
||||
beat task removes rows whose transaction is older than
|
||||
`SUPERSET_VERSION_HISTORY_RETENTION_DAYS` (default 30). A deployment that
|
||||
replaces `CELERY_CONFIG` rather than inheriting it must carry both the
|
||||
`superset.tasks.version_history_retention` import and the beat entry; a
|
||||
startup warning names whichever is absent.
|
||||
- **`PUT` responses change shape.** Entity updates now return populated
|
||||
`old_version_uuid` / `new_version_uuid` fields and an `ETag` header, which
|
||||
were null or absent while capture was off.
|
||||
|
||||
`ENABLE_VERSIONING_CAPTURE` is **retained permanently** as an operational
|
||||
kill-switch — not removed with the rollout toggles. Setting it to a falsy value
|
||||
stops capture within a restart, without a revert-and-redeploy. Unlike the
|
||||
soft-delete toggle, turning it off is a clean stop: existing version rows remain
|
||||
readable and no entity state is altered.
|
||||
|
||||
### Scheduled report execution now enforces one application deadline
|
||||
|
||||
Scheduled report (not alert) executions are now governed by a single
|
||||
@@ -289,6 +318,10 @@ 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, which restores the nvd3 renderer's interactive percent re-basing via a draggable baseline. The deck.gl Multiple Layers chart now fetches its layers entirely client-side, refitting the viewport as each layer's data arrives, and caps the number of sub-slices fanned out per chart at `DECK_MULTI_MAX_SLICES` (default 50, configurable); dashboard filter badges no longer aggregate child-layer filter metadata.
|
||||
|
||||
- [41714](https://github.com/apache/superset/pull/41714): Charts migrated in place keep a `NULL` saved query context until they are next opened in Explore (which regenerates it automatically) or re-saved. Until then, cache warm-up and annotation layers referencing such a chart report an actionable error rather than warming/rendering; opening the chart once resolves it.
|
||||
- [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`.
|
||||
|
||||
- [41813](https://github.com/apache/superset/pull/41813): `redis` (the Python client, `redis-py`) is bumped from 5.3.1 to 8.0.1. redis-py 8 changes several connection defaults; Superset's own Redis-backed features (`GLOBAL_ASYNC_QUERIES_CACHE_BACKEND`, `DISTRIBUTED_COORDINATION_CONFIG`, and the MCP Redis store) explicitly pin the pre-upgrade behavior so this bump is a no-op for them: the wire protocol stays RESP2 (not the new RESP3 default, which requires Redis/Sentinel 6+ to speak `HELLO`) and there is still no socket timeout by default (redis-py 8 defaults to 5s, which could otherwise newly time out large cached payloads or slow networks). The no-timeout default can now be overridden via two new config keys, `CACHE_REDIS_SOCKET_TIMEOUT` / `CACHE_REDIS_SOCKET_CONNECT_TIMEOUT`, on any `CacheConfig` dict using `CACHE_TYPE: RedisCache` or `RedisSentinelCache`. Separately, redis-py 6+ changed the default for `ssl_check_hostname` from `False` to `True` for SSL connections using `ssl_cert_reqs="required"` (the default) — this is a security improvement, so it has **not** been reverted; deployments with `CACHE_REDIS_SSL=True` whose certificates lack a hostname matching the connection address should set `CACHE_REDIS_SSL_CERT_REQS="none"` (disables cert verification entirely, matching hostname-check bypass) or replace the certificate. General-purpose cache/results backends configured via `CACHE_CONFIG` / `DATA_CACHE_CONFIG` / `RESULTS_BACKEND` with `CACHE_TYPE: RedisCache` go through `flask-caching`'s own Redis backend (outside Superset's code) and are subject to the same new defaults; pass `socket_timeout` / `protocol` via `CACHE_OPTIONS` there if needed. Celery broker and result-backend connections (built by `kombu`, also outside Superset's code) keep their no-socket-timeout behavior (`kombu` passes `socket_timeout=None` explicitly) but do **not** pin the wire protocol, so they follow redis-py's RESP3 default — which requires a Redis server new enough to speak `HELLO` (Redis 6+). Deployments using a pre-6.0 Redis server (EOL) as a Celery broker should upgrade the server before taking this bump.
|
||||
|
||||
@@ -308,7 +341,7 @@ in a later major version.
|
||||
|
||||
- **`SqlaTable.sql_url` query-string format.** `SqlaTable.sql_url` now URL-encodes `table_name` and joins it as a query parameter rather than concatenating a second `?`. Previously, with `Database.sql_url` returning `/sqllab/?dbid=<id>`, the concatenation produced `/sqllab/?dbid=<id>?table_name=<raw>` — a malformed second `?` that broke the query parser. External code that parsed the legacy `<base>?table_name=<raw>` shape now sees properly percent-encoded values (e.g. `/` → `%2F`, ` ` → `+` or `%20`); decode with `urllib.parse.parse_qsl`.
|
||||
|
||||
- **New config flag `EMBEDDED_DISABLE_PERMALINK_ORIGIN_REWRITE` (default `False`).** Share/permalink URLs now substitute `window.location.origin` for the backend-supplied origin so a proxied or subdirectory-deployed Superset never hands the user an unreachable internal hostname. Operators whose reverse proxy correctly forwards `X-Forwarded-Host` *and* who want permalinks to carry the backend's literal origin can opt out by setting `EMBEDDED_DISABLE_PERMALINK_ORIGIN_REWRITE = True` in `superset_config.py`. Default `False` (rewrite is on); flipping the default would regress the dominant proxied/subdir deployment to an unreachable host.
|
||||
- **New config flag `EMBEDDED_DISABLE_PERMALINK_ORIGIN_REWRITE` (default `False`).** Share/permalink URLs now substitute `window.location.origin` for the backend-supplied origin so a proxied or subdirectory-deployed Superset never hands the user an unreachable internal hostname. Operators whose reverse proxy correctly forwards `X-Forwarded-Host` _and_ who want permalinks to carry the backend's literal origin can opt out by setting `EMBEDDED_DISABLE_PERMALINK_ORIGIN_REWRITE = True` in `superset_config.py`. Default `False` (rewrite is on); flipping the default would regress the dominant proxied/subdir deployment to an unreachable host.
|
||||
|
||||
- [41651](https://github.com/apache/superset/pull/41651): **New do-not-translate standard for translation catalogs.** Strings that must stay identical to the source — icon names (e.g. `bolt`), enum/option values (`step-after`), SQL keywords, API field names (`error_message`), code constants, and example placeholders — are now marked with a `#. do-not-translate` extracted comment. The list lives in the `superset/translations/do-not-translate.txt` registry; `scripts/translations/apply_do_not_translate.py` stamps the marker onto `messages.pot` during `babel_update.sh`, and `pybabel update` propagates it to every `.po`, so the status is consistent across all languages. The AI backfill (`backfill_po.py`) and translators leave these entries untranslated (source fallback). The legacy per-catalog convention (a `# Не переводить` translator comment in the `ru` catalog) is still honored for back-compat but is superseded by this standard; contributors adding new machine-read strings should add the msgid to the registry rather than annotating individual catalogs.
|
||||
|
||||
@@ -345,7 +378,7 @@ Theme tokens are unaffected — antd 6 removed none of the tokens Superset expos
|
||||
|
||||
### Guest-token RLS rules reject unknown fields
|
||||
|
||||
The `rls` rules passed to `POST /api/v1/security/guest_token/` are now validated strictly: a rule may only contain `dataset` and `clause`. Previously unknown fields were silently dropped, so a mistyped or legacy scope key (most commonly `datasource` instead of `dataset`) produced a rule with no `dataset`, which is treated as a *global* rule applied to every dataset the embedded resource can reach. Such a request now returns HTTP 400 identifying the offending field instead of issuing a token with an unintended global rule. Integrators that were sending extra fields in RLS rules must remove them; valid dataset-scoped (`{"dataset": 41, "clause": "..."}`) and global (`{"clause": "..."}`) rules are unaffected.
|
||||
The `rls` rules passed to `POST /api/v1/security/guest_token/` are now validated strictly: a rule may only contain `dataset` and `clause`. Previously unknown fields were silently dropped, so a mistyped or legacy scope key (most commonly `datasource` instead of `dataset`) produced a rule with no `dataset`, which is treated as a _global_ rule applied to every dataset the embedded resource can reach. Such a request now returns HTTP 400 identifying the offending field instead of issuing a token with an unintended global rule. Integrators that were sending extra fields in RLS rules must remove them; valid dataset-scoped (`{"dataset": 41, "clause": "..."}`) and global (`{"clause": "..."}`) rules are unaffected.
|
||||
|
||||
### MCP service requires `MCP_JWT_AUDIENCE` when JWT auth is enabled
|
||||
|
||||
@@ -443,6 +476,7 @@ ALTER TABLE tagged_object DROP CONSTRAINT <constraint_name>;
|
||||
-- MySQL: find names via `SHOW CREATE TABLE tagged_object;`
|
||||
ALTER TABLE tagged_object DROP FOREIGN KEY <constraint_name>;
|
||||
```
|
||||
|
||||
### Entity version-history infrastructure (gated off by default)
|
||||
|
||||
Introduces the schema and SQLAlchemy-Continuum wiring that captures version history for charts, dashboards, and datasets, plus read-only `GET /api/v1/{chart,dashboard,dataset}/<uuid>/versions/` endpoints. This ships **inert**: a new config flag `ENABLE_VERSIONING_CAPTURE` defaults to `False`, so no save writes any version rows and the endpoints return empty. It is an operational kill-switch (a release toggle that becomes a permanent ops switch), not a feature flag — set it to `True` to enable capture once validated. The migration is additive; existing entity `PUT` responses gain `old_version_uuid` / `new_version_uuid` body fields and an `ETag` header (both null/absent when capture is off).
|
||||
@@ -459,12 +493,12 @@ These are behavior changes that take effect on upgrade regardless of `ENABLE_VER
|
||||
|
||||
A read-only companion to the version-history endpoints: each entity type gains a `GET /api/v1/{chart,dashboard,dataset}/<uuid>/activity/` endpoint returning a chronological, access-filtered stream of edits — the entity's own edits plus, for charts and dashboards, transitive edits to related entities during their association windows. Datasets have no related layer in V2, so `include=related` returns an empty stream for a dataset and `include=all` reduces to the dataset's own edits.
|
||||
|
||||
| Param | Type | Default | Purpose |
|
||||
|---|---|---|---|
|
||||
| `since` / `until` | ISO 8601 | — | Bound `issued_at` |
|
||||
| `include` | `self` \| `related` \| `all` | `all` | Own edits, related edits, or both |
|
||||
| `q` | string | — | Case-insensitive search over the full history, applied before pagination (so `count` reflects matches) |
|
||||
| `page` / `page_size` | integer | `0` / `25` | Pagination (`page_size` clamped to 200) |
|
||||
| Param | Type | Default | Purpose |
|
||||
| -------------------- | ---------------------------- | ---------- | ------------------------------------------------------------------------------------------------------ |
|
||||
| `since` / `until` | ISO 8601 | — | Bound `issued_at` |
|
||||
| `include` | `self` \| `related` \| `all` | `all` | Own edits, related edits, or both |
|
||||
| `q` | string | — | Case-insensitive search over the full history, applied before pagination (so `count` reflects matches) |
|
||||
| `page` / `page_size` | integer | `0` / `25` | Pagination (`page_size` clamped to 200) |
|
||||
|
||||
Authorization reuses the resource's `can_read` permission and per-object `raise_for_access`; related-entity rows are visibility-filtered to what the caller may see. The stream is empty unless version capture is on (`ENABLE_VERSIONING_CAPTURE`).
|
||||
|
||||
@@ -476,7 +510,7 @@ Entity version history (the `version_transaction` / `*_version` shadow tables th
|
||||
|---|---|---|
|
||||
| `SUPERSET_VERSION_HISTORY_RETENTION_DAYS` | `30` | Version rows whose owning `version_transaction.issued_at` is older than this many days are pruned. Each entity's live row (`end_transaction_id IS NULL`) is always preserved, as are the live rows of its children and associations; closed historical rows (including the baseline) age out. Set to `0` or a negative value to disable pruning. |
|
||||
|
||||
The task ships in the default `CeleryConfig` (both the `superset.tasks.version_history_retention` import and the beat entry). A deployment that overrides `CELERY_CONFIG` without the beat entry logs a startup warning. When the override explicitly defines `imports`, a missing retention module is also reported; an absent `imports` setting is not diagnosed because Celery may register tasks through `include`, autodiscovery, or worker startup imports. Retention only prunes whatever history exists — capture itself is gated separately by `ENABLE_VERSIONING_CAPTURE` (ships off).
|
||||
The task ships in the default `CeleryConfig` (both the `superset.tasks.version_history_retention` import and the beat entry). A deployment that overrides `CELERY_CONFIG` without the beat entry logs a startup warning. When the override explicitly defines `imports`, a missing retention module is also reported; an absent `imports` setting is not diagnosed because Celery may register tasks through `include`, autodiscovery, or worker startup imports. Retention only prunes whatever history exists — capture itself is gated separately by `ENABLE_VERSIONING_CAPTURE`, which now ships on.
|
||||
|
||||
### Deletion retention (soft-deleted entities are eventually purged)
|
||||
|
||||
@@ -486,7 +520,7 @@ Purging is **live by default** (`SOFT_DELETE_PURGE_DRY_RUN=False`), so the reten
|
||||
|
||||
Deployments that replace the default `CELERY_CONFIG` must ensure workers register `superset.tasks.deletion_retention` and schedule the `deletion_retention.purge_soft_deleted` task themselves. The shipped Docker development config uses `imports` and includes both entries. While `SOFT_DELETE` is statically enabled, a missing beat entry logs a startup warning; when the override explicitly defines `imports`, a missing purge module is also reported.
|
||||
|
||||
Operators can immediately erase a specific entity for compliance (GDPR) via `superset deletion-retention force-purge --uuid <uuid>`; this applies legacy hard-delete semantics — a live chart referencing a force-purged dataset is left without a datasource until re-pointed (the chart is not modified), and it purges the named entity even when it was never soft-deleted. Every purge writes an immutable, content-free audit record to the new `purge_audit_log` table that survives the entity it names: the **scheduled** purge fails closed (an entity whose audit row cannot be written is skipped and retried next run), while **force-purge** proceeds even if the audit write fails — the operator is present and deletion outranks audit for a compliance erasure.
|
||||
Operators can immediately erase a specific entity for compliance (GDPR) via `superset deletion-retention force-purge --uuid <uuid>`; this applies legacy hard-delete semantics — a live chart referencing a force-purged dataset is left without a datasource until re-pointed (the chart is not modified), and it purges the named entity even when it was never soft-deleted. Every scheduled evaluation writes a provisional, content-free record to the new `purge_audit_log` table before the cascade starts. Meaningful retained outcomes survive the entity they name. Consecutive scheduled evaluations with the same blocked outcome suppress only the redundant current provisional record; completed outcomes, outcome transitions, and every force-purge attempt remain independent and immutable. The **scheduled** purge fails closed when its provisional record cannot be written, while **force-purge** proceeds even if the audit write fails — the operator is present and deletion outranks audit for a compliance erasure. Operators can monitor `deletion_retention.blocked_audit_suppressed` and `deletion_retention.blocked_audit_dedupe_fallback` to verify suppression and fail-safe fallback behavior without changing the existing blocked-workload gauge.
|
||||
|
||||
### Recently Archived view and permanent delete (purge) endpoints
|
||||
|
||||
@@ -548,6 +582,7 @@ Operators can tune or disable the policy via config:
|
||||
### Data uploads bounded by UPLOAD_MAX_FILE_SIZE_BYTES
|
||||
|
||||
Single data-file uploads (CSV, Excel, columnar) are now bounded by the `UPLOAD_MAX_FILE_SIZE_BYTES` config option, which defaults to `100 * 1024 * 1024` (100 MB). Files larger than this are rejected with a `413` before their contents are buffered into memory. Set `UPLOAD_MAX_FILE_SIZE_BYTES = None` to disable the check and restore unbounded uploads.
|
||||
|
||||
### Currency symbol position follows the locale when unset
|
||||
|
||||
When a chart's currency control leaves the **Prefix or suffix** field empty, the currency symbol position is now derived from the deployment locale's own convention via `Intl.NumberFormat` instead of always defaulting to a suffix. For example, under the default `en-US` locale `USD`, `GBP`, and `EUR` render as a prefix (`$ 1,000`), while eurozone locales such as `fr-FR` render `EUR` as a suffix (`1 000 €`). An explicit Prefix/Suffix selection is always honored and is unaffected.
|
||||
@@ -673,7 +708,7 @@ SQLALCHEMY_ENCRYPTED_FIELD_ENGINE = "aes"
|
||||
```bash
|
||||
superset re-encrypt-secrets --engine aes-gcm
|
||||
```
|
||||
A live instance keeps writing *new* secrets as AES-CBC during the window between step 2 and the restart in step 4; this second pass sweeps those up (it is idempotent, so already-migrated values are skipped).
|
||||
A live instance keeps writing _new_ secrets as AES-CBC during the window between step 2 and the restart in step 4; this second pass sweeps those up (it is idempotent, so already-migrated values are skipped).
|
||||
|
||||
Schedule the cutover in a quiet window. Runtime reads use only the single configured engine, so in a multi-worker deployment there is an unavoidable brief decrypt-outage between the migration commit and the last worker restarting with the new config — each migrator run is transactional, but the fleet-wide cutover is not zero-downtime.
|
||||
|
||||
@@ -701,11 +736,11 @@ With the flag enabled: `DELETE /api/v1/dataset/<id>` no longer hard-deletes the
|
||||
|
||||
**Schema migration:** the migration adds a nullable `deleted_at` column and an index on it (`ix_tables_deleted_at`) to the `tables` table. The column add is instant; the index build runs inline (no `CONCURRENTLY`) and may briefly block writes on the `tables` table (INSERT/UPDATE/DELETE are queued while the index builds; reads are unaffected) on large Postgres deployments. MySQL InnoDB builds the index online (no blocking). Production deployments with many thousands of datasets should run this migration during a maintenance window.
|
||||
|
||||
**Rollback note:** if the application code is rolled back after datasets have been soft-deleted, the older code path's visibility filter no longer applies and previously hidden rows become visible to the older code. Pair the rollback with a data decision (restore the rows, hard-delete them, or also downgrade the migration) rather than assuming the old hard-delete semantics still hold. **Downgrading the migration destroys the deletion markers**: `downgrade()` drops the `deleted_at` column, so any not-yet-restored soft-deleted datasets silently become live, active datasets with no record they were ever deleted. Reconcile the trash (restore or hard-delete each row) *before* downgrading, and disable the `SOFT_DELETE` flag first so no new soft deletes land mid-rollback.
|
||||
**Rollback note:** if the application code is rolled back after datasets have been soft-deleted, the older code path's visibility filter no longer applies and previously hidden rows become visible to the older code. Pair the rollback with a data decision (restore the rows, hard-delete them, or also downgrade the migration) rather than assuming the old hard-delete semantics still hold. **Downgrading the migration destroys the deletion markers**: `downgrade()` drops the `deleted_at` column, so any not-yet-restored soft-deleted datasets silently become live, active datasets with no record they were ever deleted. Reconcile the trash (restore or hard-delete each row) _before_ downgrading, and disable the `SOFT_DELETE` flag first so no new soft deletes land mid-rollback.
|
||||
|
||||
**SQL Lab / dataset-creation flows:** creating a dataset over a table whose dataset sits in the trash is refused. The SQL Lab "save as dataset" flow (`get_or_create_dataset`) and file uploads return a **422 naming the hidden twin and the restore endpoint**; the plain create, update, and duplicate paths currently fail with the generic "already exists" 422. In all cases the remediation is the same: restore the hidden dataset (or use a different table name). Perm-string maintenance also covers hidden rows: renaming a database rewrites `perm`/`schema_perm`/`catalog_perm` on soft-deleted datasets and their charts, so a later restore does not resurrect stale permission strings.
|
||||
|
||||
**Importer behavior:** importing a dataset YAML whose UUID matches an existing **soft-deleted** dataset is treated as an implicit restore-with-update — **and this happens even when `overwrite` is not set**. This is a deliberate asymmetry with active rows: an active dataset imported without `overwrite=true` is returned unchanged, but a soft-deleted UUID match is restored *and* has the upload's contents applied regardless of the `overwrite` argument, on the reasoning that re-importing a deleted dataset's exact UUID is an explicit request to bring it back. The restore preserves the original PK, the chart back-reference, `table_columns`, and `sql_metrics`. Non-editors get `ImportFailedError`. Callers without `can_write` get `ImportFailedError` instead of silently receiving the soft-deleted row.
|
||||
**Importer behavior:** importing a dataset YAML whose UUID matches an existing **soft-deleted** dataset is treated as an implicit restore-with-update — **and this happens even when `overwrite` is not set**. This is a deliberate asymmetry with active rows: an active dataset imported without `overwrite=true` is returned unchanged, but a soft-deleted UUID match is restored _and_ has the upload's contents applied regardless of the `overwrite` argument, on the reasoning that re-importing a deleted dataset's exact UUID is an explicit request to bring it back. The restore preserves the original PK, the chart back-reference, `table_columns`, and `sql_metrics`. Non-editors get `ImportFailedError`. Callers without `can_write` get `ImportFailedError` instead of silently receiving the soft-deleted row.
|
||||
|
||||
**Uniqueness-validation changes that apply regardless of the feature flag:** two dataset uniqueness checks were tightened alongside this work and are active even with `SOFT_DELETE` off. (1) Create/update uniqueness treats a dataset whose `catalog` is `NULL` as belonging to the database's default catalog, so a legacy twin pair (`catalog=NULL` vs. `catalog=<default>`, same database/schema/name) that older versions allowed now fails validation with "already exists" when either row is edited — resolve by renaming or removing one of the twins. (2) Duplicating a dataset now checks name collisions scoped to the target (database, catalog, schema) instead of globally by name alone: duplicates into other databases that were previously blocked are now allowed.
|
||||
|
||||
@@ -725,9 +760,9 @@ With the flag enabled: `DELETE /api/v1/chart/<id>` no longer hard-deletes the ch
|
||||
|
||||
**Schema migration:** the migration adds a nullable `deleted_at` column and an index on it (`ix_slices_deleted_at`) to the `slices` table. The column add is instant; the index build runs inline (no `CONCURRENTLY`) and may briefly block writes on the `slices` table (INSERT/UPDATE/DELETE are queued while the index builds; reads are unaffected) on large Postgres deployments. MySQL InnoDB builds the index online (no blocking).
|
||||
|
||||
**Rollback note:** if the application code is rolled back after charts have been soft-deleted, the older code path's visibility filter no longer applies and previously hidden rows become visible to the older code. Pair the rollback with a data decision (restore the rows, hard-delete them, or also downgrade the migration) rather than assuming the old hard-delete semantics still hold. **Downgrading the migration destroys the deletion markers**: `downgrade()` drops the `deleted_at` column, so any not-yet-restored soft-deleted charts silently become live, active charts with no record they were ever deleted. Reconcile the trash (restore or hard-delete each row) *before* downgrading, and disable the `SOFT_DELETE` flag first so no new soft deletes land mid-rollback.
|
||||
**Rollback note:** if the application code is rolled back after charts have been soft-deleted, the older code path's visibility filter no longer applies and previously hidden rows become visible to the older code. Pair the rollback with a data decision (restore the rows, hard-delete them, or also downgrade the migration) rather than assuming the old hard-delete semantics still hold. **Downgrading the migration destroys the deletion markers**: `downgrade()` drops the `deleted_at` column, so any not-yet-restored soft-deleted charts silently become live, active charts with no record they were ever deleted. Reconcile the trash (restore or hard-delete each row) _before_ downgrading, and disable the `SOFT_DELETE` flag first so no new soft deletes land mid-rollback.
|
||||
|
||||
**Importer behavior:** importing a chart YAML whose UUID matches an existing **soft-deleted** chart is treated as an implicit restore-with-update — **and this happens even when `overwrite` is not set**. This is a deliberate asymmetry with active rows: an active chart imported without `overwrite=true` is returned unchanged, but a soft-deleted UUID match is restored *and* has the upload's contents applied regardless of the `overwrite` argument, on the reasoning that re-importing a deleted chart's exact UUID is an explicit request to bring it back. The restore preserves the original PK and all out-of-archive references (`dashboard_slices` junctions, `report.chart_id`, tag rows). The operation is permission-gated: non-editors get `ImportFailedError`, and callers without `can_write` get `ImportFailedError` instead of silently receiving the soft-deleted row.
|
||||
**Importer behavior:** importing a chart YAML whose UUID matches an existing **soft-deleted** chart is treated as an implicit restore-with-update — **and this happens even when `overwrite` is not set**. This is a deliberate asymmetry with active rows: an active chart imported without `overwrite=true` is returned unchanged, but a soft-deleted UUID match is restored _and_ has the upload's contents applied regardless of the `overwrite` argument, on the reasoning that re-importing a deleted chart's exact UUID is an explicit request to bring it back. The restore preserves the original PK and all out-of-archive references (`dashboard_slices` junctions, `report.chart_id`, tag rows). The operation is permission-gated: non-editors get `ImportFailedError`, and callers without `can_write` get `ImportFailedError` instead of silently receiving the soft-deleted row.
|
||||
|
||||
- [39914](https://github.com/apache/superset/pull/39914) `ALERT_REPORT_SLACK_V2` now defaults to `True` and the legacy Slack v1 integration (`Slack` recipient type, `files.upload` API) is deprecated for removal in the next major. Slack blocked new apps from `files.upload` in May 2024 and fully retired the method for all apps on November 12, 2025; because the v1 path sends files through `files.upload`, v1 file-bearing sends now fail at the API level — only text-only `chat_postMessage` still works via the legacy path. Grant your Slack bot the `channels:read` and `groups:read` scopes so existing `Slack` recipients can be auto-upgraded to `SlackV2` on next send. Operators who explicitly override the flag to `False`, or whose Slack bot is missing those scopes, will see deprecation warnings while text-only sends continue through the legacy path.
|
||||
|
||||
@@ -751,7 +786,7 @@ The partial-index replacement is dialect-dependent: PostgreSQL uses a native `WH
|
||||
|
||||
**Slug semantics:** on PostgreSQL and MySQL 8.0.13+, the slug of a soft-deleted dashboard is **free for reuse**. A new active dashboard can claim it immediately. Restoring a soft-deleted dashboard whose slug has since been claimed returns **422 with a clean error** (`DashboardSlugConflictError`) — rename one of the dashboards and retry; the restore is not silently rejected by a database-level constraint violation.
|
||||
|
||||
**Importer behavior:** importing a dashboard YAML whose UUID matches an existing **soft-deleted** dashboard is treated as an implicit restore-with-update — **and this happens even when `overwrite` is not set**. This is a deliberate asymmetry with active rows: an active dashboard imported without `overwrite=true` is returned unchanged (the import never mutates it), but a soft-deleted UUID match is restored *and* has the upload's contents applied regardless of the `overwrite` argument, on the reasoning that re-importing a deleted dashboard's exact UUID is an explicit request to bring it back. The restore preserves the original PK and all pre-deletion relationship rows (`dashboard_slices` junctions, editor/viewer subjects, tags). Callers whose imports must never mutate existing state should treat bundles that may contain previously deleted UUIDs accordingly. The operation is permission-gated: it requires `can_write` and editorship of the deleted row (or admin) — non-editors get `ImportFailedError`, and callers without `can_write` get `ImportFailedError` instead of silently receiving the soft-deleted row.
|
||||
**Importer behavior:** importing a dashboard YAML whose UUID matches an existing **soft-deleted** dashboard is treated as an implicit restore-with-update — **and this happens even when `overwrite` is not set**. This is a deliberate asymmetry with active rows: an active dashboard imported without `overwrite=true` is returned unchanged (the import never mutates it), but a soft-deleted UUID match is restored _and_ has the upload's contents applied regardless of the `overwrite` argument, on the reasoning that re-importing a deleted dashboard's exact UUID is an explicit request to bring it back. The restore preserves the original PK and all pre-deletion relationship rows (`dashboard_slices` junctions, editor/viewer subjects, tags). Callers whose imports must never mutate existing state should treat bundles that may contain previously deleted UUIDs accordingly. The operation is permission-gated: it requires `can_write` and editorship of the deleted row (or admin) — non-editors get `ImportFailedError`, and callers without `can_write` get `ImportFailedError` instead of silently receiving the soft-deleted row.
|
||||
|
||||
### Engine spec capability flag: `supports_offset`
|
||||
|
||||
@@ -763,10 +798,10 @@ A new `BaseEngineSpec.supports_offset` attribute (default `True`) indicates whet
|
||||
|
||||
A new feature flag `GRANULAR_EXPORT_CONTROLS` introduces three fine-grained permissions that replace the legacy `can_csv` permission:
|
||||
|
||||
| Permission | Controls |
|
||||
|---|---|
|
||||
| `can_export_data` | CSV, Excel, JSON exports |
|
||||
| `can_export_image` | Screenshot/PDF exports |
|
||||
| Permission | Controls |
|
||||
| -------------------- | ---------------------------- |
|
||||
| `can_export_data` | CSV, Excel, JSON exports |
|
||||
| `can_export_image` | Screenshot/PDF exports |
|
||||
| `can_copy_clipboard` | Copy-to-clipboard operations |
|
||||
|
||||
When the feature flag is enabled, these permissions are enforced on both the frontend (disabled buttons with tooltips) and backend (403 responses from API endpoints). When disabled, legacy `can_csv` behavior is preserved.
|
||||
@@ -810,14 +845,17 @@ The Kenya country map has been updated to reflect the 47 counties established un
|
||||
MCP (Model Context Protocol) tools now include enhanced observability instrumentation for monitoring and debugging:
|
||||
|
||||
**Two-layer instrumentation:**
|
||||
|
||||
1. **Middleware layer** (`LoggingMiddleware`): Automatically logs all MCP tool calls with `duration_ms` and `success` status in the audit log (Action Log UI, logs table)
|
||||
2. **Sub-operation tracking**: All 19 MCP tools include granular `event_logger.log_context()` blocks for tracking individual operations like validation, database writes, and query execution
|
||||
|
||||
**Action naming convention:**
|
||||
|
||||
- Tool-level logs: `mcp_tool_call` (via middleware)
|
||||
- Sub-operation logs: `mcp.{tool_name}.{operation}` (e.g., `mcp.generate_chart.validation`, `mcp.execute_sql.query_execution`)
|
||||
|
||||
**Querying MCP logs:**
|
||||
|
||||
```sql
|
||||
-- Top slowest MCP operations
|
||||
SELECT action, COUNT(*) as calls, AVG(duration_ms) as avg_ms
|
||||
@@ -852,6 +890,7 @@ A new `DISTRIBUTED_COORDINATION_CONFIG` configuration provides a unified Redis-b
|
||||
The distributed coordination is used by the Global Task Framework (GTF) for abort notifications and task completion signaling, and will eventually replace `GLOBAL_ASYNC_QUERIES_CACHE_BACKEND` as the standard signaling backend. Configuring this is recommended for Redis enabled production deployments.
|
||||
|
||||
Example configuration in `superset_config.py`:
|
||||
|
||||
```python
|
||||
DISTRIBUTED_COORDINATION_CONFIG = {
|
||||
"CACHE_TYPE": "RedisCache",
|
||||
@@ -866,9 +905,11 @@ See `superset/config.py` for complete configuration options.
|
||||
### WebSocket config for GAQ with Docker
|
||||
|
||||
[35896](https://github.com/apache/superset/pull/35896) and [37624](https://github.com/apache/superset/pull/37624) updated documentation on how to run and configure Superset with Docker. Specifically for the WebSocket configuration, a new `docker/superset-websocket/config.example.json` was added to the repo, so that users could copy it to create a `docker/superset-websocket/config.json` file. The existing `docker/superset-websocket/config.json` was removed and git-ignored, so if you're using GAQ / WebSocket make sure to:
|
||||
|
||||
- Stash/backup your existing `config.json` file, to re-apply it after (will get git-ignored going forward)
|
||||
- Update the `volumes` configuration for the `superset-websocket` service in your `docker-compose.override.yml` file, to include the `docker/superset-websocket/config.json` file. For example:
|
||||
``` yaml
|
||||
|
||||
```yaml
|
||||
services:
|
||||
superset-websocket:
|
||||
volumes:
|
||||
@@ -881,7 +922,9 @@ services:
|
||||
### Example Data Loading Improvements
|
||||
|
||||
#### New Directory Structure
|
||||
|
||||
Examples are now organized by name with data and configs co-located:
|
||||
|
||||
```
|
||||
superset/examples/
|
||||
├── _shared/ # Shared database & metadata configs
|
||||
@@ -894,12 +937,14 @@ superset/examples/
|
||||
```
|
||||
|
||||
#### Simplified Parquet-based Loading
|
||||
|
||||
- Auto-discovery: create `superset/examples/my_dataset/data.parquet` to add a new example
|
||||
- Parquet is an Apache project format: compressed (~27% smaller), self-describing schema
|
||||
- YAML configs define datasets, charts, and dashboards declaratively
|
||||
- Removed Python-based data generation from individual example files
|
||||
|
||||
#### Test Data Reorganization
|
||||
|
||||
- Moved `big_data.py` to `superset/cli/test_loaders.py` - better reflects its purpose as a test utility
|
||||
- Fixed inverted logic for `--load-test-data` flag (now correctly includes .test.yaml files when flag is set)
|
||||
- Clarified CLI flags:
|
||||
@@ -909,6 +954,7 @@ superset/examples/
|
||||
- `--load-big-data` / `-b`: Generate synthetic stress-test data
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
- Fixed numpy array serialization for PostgreSQL (converts complex types to JSON strings)
|
||||
- Fixed KeyError for `allow_csv_upload` field in database configs (now optional with default)
|
||||
- Fixed test data loading logic that was incorrectly filtering files
|
||||
@@ -918,6 +964,7 @@ superset/examples/
|
||||
The MCP (Model Context Protocol) service enables AI assistants and automation tools to interact programmatically with Superset.
|
||||
|
||||
#### New Features
|
||||
|
||||
- MCP service infrastructure with FastMCP framework
|
||||
- Tools for dashboards, charts, datasets, SQL Lab, and instance metadata
|
||||
- Optional dependency: install with `pip install apache-superset[fastmcp]`
|
||||
@@ -927,6 +974,7 @@ The MCP (Model Context Protocol) service enables AI assistants and automation to
|
||||
#### New Configuration Options
|
||||
|
||||
**Development** (single-user, local testing):
|
||||
|
||||
```python
|
||||
# superset_config.py
|
||||
MCP_DEV_USERNAME = "admin" # User for MCP authentication
|
||||
@@ -935,6 +983,7 @@ MCP_SERVICE_PORT = 5008
|
||||
```
|
||||
|
||||
**Production** (JWT-based, multi-user):
|
||||
|
||||
```python
|
||||
# superset_config.py
|
||||
MCP_AUTH_ENABLED = True
|
||||
@@ -980,12 +1029,14 @@ superset mcp run --port 5008 --use-factory-config
|
||||
The MCP service runs as a **separate process** from the Superset web server.
|
||||
|
||||
**Important**:
|
||||
|
||||
- Requires same Python environment and configuration as Superset
|
||||
- Shares database connections with main Superset app
|
||||
- Can be scaled independently from web server
|
||||
- Requires `fastmcp` package (optional dependency)
|
||||
|
||||
**Installation**:
|
||||
|
||||
```bash
|
||||
# Install with MCP support
|
||||
pip install apache-superset[fastmcp]
|
||||
@@ -999,6 +1050,7 @@ Use systemd, supervisord, or Kubernetes to manage the MCP service process.
|
||||
See `superset/mcp_service/PRODUCTION.md` for deployment guides.
|
||||
|
||||
**Security**:
|
||||
|
||||
- Development: Uses `MCP_DEV_USERNAME` for single-user access
|
||||
- Production: **MUST** configure JWT authentication
|
||||
- See `superset/mcp_service/SECURITY.md` for details
|
||||
@@ -1018,8 +1070,10 @@ See `superset/mcp_service/PRODUCTION.md` for deployment guides.
|
||||
- [35062](https://github.com/apache/superset/pull/35062): Changed the function signature of `setupExtensions` to `setupCodeOverrides` with options as arguments.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [37370](https://github.com/apache/superset/pull/37370): The `APP_NAME` configuration variable no longer controls the browser window/tab title or other frontend branding. Application names should now be configured using the theme system with the `brandAppName` token. The `APP_NAME` config is still used for backend contexts (MCP service, logs, etc.) and serves as a fallback if `brandAppName` is not set.
|
||||
- **Migration:**
|
||||
|
||||
```python
|
||||
# Before (Superset 5.x)
|
||||
APP_NAME = "My Custom App"
|
||||
@@ -1063,16 +1117,16 @@ See `superset/mcp_service/PRODUCTION.md` for deployment guides.
|
||||
|
||||
Eight M:N association tables move from a synthetic `id INTEGER PRIMARY KEY` to a composite `PRIMARY KEY (fk1, fk2)` on their two foreign-key columns. The surrogate `id` is dropped, and the redundant `UNIQUE (fk1, fk2)` on the two tables that carried one is removed (now subsumed by the PK).
|
||||
|
||||
| Table | Composite PK |
|
||||
|---|---|
|
||||
| `dashboard_roles` | `(dashboard_id, role_id)` |
|
||||
| `dashboard_slices` | `(dashboard_id, slice_id)` |
|
||||
| `dashboard_user` | `(user_id, dashboard_id)` |
|
||||
| Table | Composite PK |
|
||||
| ---------------------- | ------------------------------- |
|
||||
| `dashboard_roles` | `(dashboard_id, role_id)` |
|
||||
| `dashboard_slices` | `(dashboard_id, slice_id)` |
|
||||
| `dashboard_user` | `(user_id, dashboard_id)` |
|
||||
| `report_schedule_user` | `(user_id, report_schedule_id)` |
|
||||
| `rls_filter_roles` | `(role_id, rls_filter_id)` |
|
||||
| `rls_filter_tables` | `(table_id, rls_filter_id)` |
|
||||
| `slice_user` | `(user_id, slice_id)` |
|
||||
| `sqlatable_user` | `(user_id, table_id)` |
|
||||
| `rls_filter_roles` | `(role_id, rls_filter_id)` |
|
||||
| `rls_filter_tables` | `(table_id, rls_filter_id)` |
|
||||
| `slice_user` | `(user_id, slice_id)` |
|
||||
| `sqlatable_user` | `(user_id, table_id)` |
|
||||
|
||||
**Before upgrading:**
|
||||
|
||||
@@ -1083,6 +1137,7 @@ Eight M:N association tables move from a synthetic `id INTEGER PRIMARY KEY` to a
|
||||
For large `dashboard_slices` / `report_schedule_user` tables, see the operator runbook in [#39859](https://github.com/apache/superset/pull/39859) — pre-flight inventory queries, per-dialect lock-window sizing, and the duplicate / NULL-FK roll-up — to plan the maintenance window.
|
||||
|
||||
## 6.0.0
|
||||
|
||||
- [33055](https://github.com/apache/superset/pull/33055): Upgrades Flask-AppBuilder to 5.0.0. The AUTH_OID authentication type has been deprecated and is no longer available as an option in Flask-AppBuilder. OpenID (OID) is considered a deprecated authentication protocol - if you are using AUTH_OID, you will need to migrate to an alternative authentication method such as OAuth, LDAP, or database authentication before upgrading.
|
||||
- [34871](https://github.com/apache/superset/pull/34871): Fixed Jest test hanging issue from Ant Design v5 upgrade. MessageChannel is now mocked in test environment to prevent rc-overflow from causing Jest to hang. Test environment only - no production impact.
|
||||
- [34782](https://github.com/apache/superset/pull/34782): Dataset exports now include the dataset ID in their file name (similar to charts and dashboards). If managing assets as code, make sure to rename existing dataset YAMLs to include the ID (and avoid duplicated files).
|
||||
@@ -1091,8 +1146,8 @@ For large `dashboard_slices` / `report_schedule_user` tables, see the operator r
|
||||
- Change any hex color values to one of: `"success"`, `"processing"`, `"error"`, `"warning"`, `"default"`
|
||||
- Custom colors are no longer supported to maintain consistency with Ant Design components
|
||||
- [34561](https://github.com/apache/superset/pull/34561) Added tiled screenshot functionality for Playwright-based reports to handle large dashboards more efficiently. When enabled (default: `SCREENSHOT_TILED_ENABLED = True`), dashboards with 20+ charts or height exceeding 5000px will be captured using multiple viewport-sized tiles and combined into a single image. This improves report generation performance and reliability for large dashboards.
|
||||
Note: Pillow is now a required dependency (previously optional) to support image processing for tiled screenshots.
|
||||
`thumbnails` optional dependency is now deprecated and will be removed in the next major release (7.0).
|
||||
Note: Pillow is now a required dependency (previously optional) to support image processing for tiled screenshots.
|
||||
`thumbnails` optional dependency is now deprecated and will be removed in the next major release (7.0).
|
||||
- [33084](https://github.com/apache/superset/pull/33084) The DISALLOWED_SQL_FUNCTIONS configuration now includes additional potentially sensitive database functions across PostgreSQL, MySQL, SQLite, MS SQL Server, and ClickHouse. Existing queries using these functions may now be blocked. Review your SQL Lab queries and dashboards if you encounter "disallowed function" errors after upgrading
|
||||
- [34235](https://github.com/apache/superset/pull/34235) CSV exports now use `utf-8-sig` encoding by default to include a UTF-8 BOM, improving compatibility with Excel.
|
||||
- [34258](https://github.com/apache/superset/pull/34258) changing the default in Dockerfile to INCLUDE_CHROMIUM="false" (from "true") in the past. This ensures the `lean` layer is lean by default, and people can opt-in to the `chromium` layer by setting the build arg `INCLUDE_CHROMIUM=true`. This is a breaking change for anyone using the `lean` layer, as it will no longer include Chromium by default.
|
||||
|
||||
@@ -28,6 +28,7 @@ Alerts and reports are disabled by default. To turn them on, you'll need to chan
|
||||
- Users can customize the email subject by including date code placeholders, which will automatically be replaced with the corresponding UTC date when the email is sent. To enable this functionality, activate the `"DATE_FORMAT_IN_EMAIL_SUBJECT"` [feature flag](/admin-docs/configuration/configuring-superset#feature-flags). This enables date formatting in email subjects, preventing all reporting emails from being grouped into the same thread (optional for the reporting feature).
|
||||
- Use date codes from [strftime.org](https://strftime.org/) to create the email subject.
|
||||
- If no date code is provided, the original string will be used as the email subject.
|
||||
- Each alert/report has an "Include a link back to Superset" option (enabled by default) controlling whether the call-to-action link is included in email and Slack notifications. The link text in emails is configurable via `EMAIL_REPORTS_CTA`; the Slack message always uses "Explore in Superset". Uncheck the option when recipients should not receive a link to your Superset host, e.g. for external audiences.
|
||||
|
||||
##### Disable dry-run mode
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ celery --app=superset.tasks.celery_app:app beat
|
||||
|
||||
To setup a result backend, you need to pass an instance of a derivative of `BaseCache` (`from
|
||||
flask_caching.backends.base import BaseCache`) to the RESULTS_BACKEND configuration key in your
|
||||
superset_config.py. You can use Memcached, Redis, S3 (https://pypi.python.org/pypi/s3werkzeugcache),
|
||||
memory or the file system (in a single server-type setup or for testing), or to write your own
|
||||
superset_config.py. You can use Memcached, Redis, S3, MinIO, memory
|
||||
or the file system (in a single server-type setup or for testing), or to write your own
|
||||
caching interface. Your `superset_config.py` may look something like:
|
||||
|
||||
```python
|
||||
@@ -89,6 +89,12 @@ issues arise. Please clear your existing results cache store when upgrading an e
|
||||
- SQL Lab will _only run your queries asynchronously if_ you enable **Asynchronous Query Execution**
|
||||
in your database settings (Sources > Databases > Edit record).
|
||||
|
||||
- In order to use dedicated results backend, additional python libraries must be installed. These libraries can be installed using pip.
|
||||
- [redis-py](https://pypi.org/project/redis/) for Redis.
|
||||
- [pylibmc](https://pypi.org/project/pylibmc/) for memcached
|
||||
- [s3werkzeugcache](https://pypi.python.org/pypi/s3werkzeugcache) for S3
|
||||
- [minio-flask-cache](https://github.com/greggailly/minio-flask-cache) for MinIO or other S3 compatible service
|
||||
|
||||
## Celery Flower
|
||||
|
||||
Flower is a web based tool for monitoring the Celery cluster which you can install from pip:
|
||||
|
||||
@@ -15,9 +15,8 @@ fail-fast behavior ensures operators are immediately aware of infrastructure iss
|
||||
|
||||
Superset uses [Flask-Caching](https://flask-caching.readthedocs.io/) for caching purposes.
|
||||
Flask-Caching supports various caching backends, including Redis (recommended), Memcached,
|
||||
SimpleCache (in-memory), or the local filesystem.
|
||||
[Custom cache backends](https://flask-caching.readthedocs.io/en/latest/#custom-cache-backends)
|
||||
are also supported.
|
||||
SimpleCache (in-memory), MinIO/S3, or the local filesystem.
|
||||
[Custom cache backends](https://flask-caching.readthedocs.io/en/latest/#custom-cache-backends) are also supported.
|
||||
|
||||
Caching can be configured by providing dictionaries in
|
||||
`superset_config.py` that comply with [the Flask-Caching config specifications](https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching).
|
||||
@@ -47,6 +46,7 @@ In order to use dedicated cache stores, additional python libraries must be inst
|
||||
- For Redis: we recommend the [redis](https://pypi.python.org/pypi/redis) Python package
|
||||
- Memcached: we recommend using [pylibmc](https://pypi.org/project/pylibmc/) client library as
|
||||
`python-memcached` does not handle storing binary data correctly.
|
||||
- MinIO (S3): we recommend using the [minio-flask-cache](https://github.com/greggailly/minio-flask-cache) package
|
||||
|
||||
These libraries can be installed using pip.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -315,6 +315,76 @@ Here's a concrete example:
|
||||
WHERE country_code = 'US'
|
||||
```
|
||||
|
||||
**Guest User Attributes**
|
||||
|
||||
The `{{ get_guest_user_attribute('attribute_name') }}` macro returns a specific attribute value from the guest user context.
|
||||
This is useful when working with embedded Superset where guest tokens can contain custom attributes that need to be
|
||||
accessed in SQL queries.
|
||||
|
||||
This macro only works when the current user is a guest user (authenticated via guest token). If the current user is
|
||||
not a guest user, or if the specified attribute doesn't exist, the macro will return `None` or the provided default value.
|
||||
|
||||
If you have caching enabled in your Superset configuration, then by default the resolved value (whether it
|
||||
came from the guest token, a null attribute, or the provided default) will be used by Superset when
|
||||
calculating the cache key. A cache key is a unique identifier that determines if there's a cache hit in the
|
||||
future and Superset can retrieve cached data. Including the resolved value on every branch ensures two guests
|
||||
whose tokens render different SQL never share a cache entry.
|
||||
|
||||
You can disable the inclusion of the attribute value in the calculation of the
|
||||
cache key by adding the following parameter to your Jinja code, but only do so
|
||||
when the value cannot affect the query results:
|
||||
|
||||
```
|
||||
{{ get_guest_user_attribute('department', add_to_cache_keys=False) }}
|
||||
```
|
||||
|
||||
You can also provide a default value if the attribute is not found:
|
||||
|
||||
```
|
||||
{{ get_guest_user_attribute('region', default='US') }}
|
||||
```
|
||||
|
||||
Here's a concrete example of using guest user attributes in a query:
|
||||
|
||||
```sql
|
||||
SELECT *
|
||||
FROM sales_data
|
||||
WHERE region = '{{ get_guest_user_attribute("user_region", default="global") }}'
|
||||
AND department = '{{ get_guest_user_attribute("department") }}'
|
||||
```
|
||||
|
||||
:::warning[Security Warning]
|
||||
|
||||
Guest token attributes come from the embedding application. By default,
|
||||
`get_guest_user_attribute()` escapes string values — including strings nested inside
|
||||
arrays and object values, and caller-supplied defaults — through the database dialect's
|
||||
literal rendering (the same mechanism as `url_param()`). This covers dialect-specific
|
||||
escape characters such as the backslash on MySQL/MariaDB, so the example above is safe
|
||||
to interpolate directly. If you pass `escape_result=False`, or interpolate non-string
|
||||
values (numbers, booleans), you are responsible for validating or allowlisting the
|
||||
values, since they originate outside Superset.
|
||||
|
||||
If a guest attribute is an array and you plan to pipe it through the `|where_in` filter
|
||||
(for example `full_name IN {{ get_guest_user_attribute('names')|where_in }}`), call
|
||||
`get_guest_user_attribute('names', escape_result=False)`. `where_in` already applies its
|
||||
own dialect-safe quoting, so escaping the values twice can corrupt them (a value such as
|
||||
`O'Brien` would come back doubly escaped and match nothing).
|
||||
|
||||
Only individual string values are escaped as SQL literals. Interpolating an entire array
|
||||
or object directly (rather than through `|where_in`, or by accessing a specific element)
|
||||
renders Python's string form of that structure, which is not valid SQL, and object keys
|
||||
are not escaped at all. Use `|where_in` for arrays, `|tojson` where you need a
|
||||
JSON-stringified value, or read individual keys/elements out of the structure yourself.
|
||||
|
||||
The same double-escaping problem described above for `|where_in` applies to `|tojson`:
|
||||
pass `escape_result=False` before piping to `|tojson` (for example
|
||||
`{{ get_guest_user_attribute('profile', escape_result=False)|tojson }}`), since JSON
|
||||
already handles its own quoting and re-escaping a value first would corrupt it (a nested
|
||||
string such as `O'Brien` would come back as the altered `O''Brien` in the serialized
|
||||
JSON).
|
||||
|
||||
:::
|
||||
|
||||
### Explicitly Including Values in Cache Key
|
||||
|
||||
The `{{ cache_key_wrapper() }}` function explicitly instructs Superset to add a value to the
|
||||
|
||||
@@ -62,10 +62,10 @@
|
||||
"@superset-ui/core": "^0.20.4",
|
||||
"@swc/core": "^1.15.47",
|
||||
"antd": "^6.5.2",
|
||||
"baseline-browser-mapping": "^2.11.7",
|
||||
"baseline-browser-mapping": "^2.11.8",
|
||||
"caniuse-lite": "^1.0.30001806",
|
||||
"docusaurus-plugin-openapi-docs": "^5.1.2",
|
||||
"docusaurus-theme-openapi-docs": "^5.1.2",
|
||||
"docusaurus-plugin-openapi-docs": "^5.1.3",
|
||||
"docusaurus-theme-openapi-docs": "^5.1.3",
|
||||
"js-yaml": "^5.2.2",
|
||||
"json-bigint": "^1.0.0",
|
||||
"prism-react-renderer": "^2.4.1",
|
||||
|
||||
@@ -107,9 +107,9 @@
|
||||
},
|
||||
{
|
||||
"name": "VERSION_HISTORY",
|
||||
"default": false,
|
||||
"default": true,
|
||||
"lifecycle": "development",
|
||||
"description": "Enables the version history panel on Explore and Dashboard pages. History only accrues while ``ENABLE_VERSIONING_CAPTURE`` is also on; with capture off the panel renders but stays empty."
|
||||
"description": "Enables the version history panel on Explore and Dashboard pages. History only accrues while ``ENABLE_VERSIONING_CAPTURE`` is also on; with capture off the panel renders but stays empty, so the two ship with matching defaults and should be changed together."
|
||||
}
|
||||
],
|
||||
"testing": [
|
||||
|
||||
@@ -11383,6 +11383,13 @@
|
||||
},
|
||||
"User3": {
|
||||
"properties": {
|
||||
"attributes": {
|
||||
"additionalProperties": {
|
||||
"nullable": true
|
||||
},
|
||||
"nullable": true,
|
||||
"type": "object"
|
||||
},
|
||||
"first_name": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -6453,10 +6453,10 @@ base64-js@^1.3.1, base64-js@^1.5.1:
|
||||
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
|
||||
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
|
||||
|
||||
baseline-browser-mapping@^2.10.38, baseline-browser-mapping@^2.11.7, baseline-browser-mapping@^2.9.19:
|
||||
version "2.11.7"
|
||||
resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.11.7.tgz#65b41243f29d2cca7b5d72ca6e9b8285df1ed975"
|
||||
integrity sha512-APw5YuIQAg6L9w4sHDI6j26DGFJI6RpYOhnkMPdC9lWbkKvsyPHzDsve1yd73lk21yz7Y09Kci8B2Pp9FonzWA==
|
||||
baseline-browser-mapping@^2.10.38, baseline-browser-mapping@^2.11.8, baseline-browser-mapping@^2.9.19:
|
||||
version "2.11.8"
|
||||
resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.11.8.tgz#42eb5ffc99fd89ca8bf30e31557b487063eec86f"
|
||||
integrity sha512-zAgkquC2WYF0PIc6XbNYkA2uuxxFavzgmX61R+dHDUa558V8Ejf8ozTZFR6QzM24RWu4kBcRkhJ5kpz77j9fnQ==
|
||||
|
||||
batch@0.6.1:
|
||||
version "0.6.1"
|
||||
@@ -7938,10 +7938,10 @@ doctrine@^2.1.0:
|
||||
dependencies:
|
||||
esutils "^2.0.2"
|
||||
|
||||
docusaurus-plugin-openapi-docs@^5.1.2:
|
||||
version "5.1.2"
|
||||
resolved "https://registry.yarnpkg.com/docusaurus-plugin-openapi-docs/-/docusaurus-plugin-openapi-docs-5.1.2.tgz#1ef66a26d80e2a3baf4caae4e72a0dcf85c6d608"
|
||||
integrity sha512-xlgl/8+2iqSQWdhTJay0lfXqWduaGVTYrn+9i+uT3Uk5gkeDjfQOIVnHGnIHfKg0pUjIm008fvEQVAxk3TvgaQ==
|
||||
docusaurus-plugin-openapi-docs@^5.1.3:
|
||||
version "5.1.3"
|
||||
resolved "https://registry.yarnpkg.com/docusaurus-plugin-openapi-docs/-/docusaurus-plugin-openapi-docs-5.1.3.tgz#b8cd5f8451aaf881deb1a744a8295685f1681865"
|
||||
integrity sha512-HnpblSBdXoR39VNTIW9zWERUsMJxXOpvdQoBKyaTkUBPwCM48Z76+ndo2yO2vADq+EhWjJlfxL1DUzCrgNjThQ==
|
||||
dependencies:
|
||||
"@apidevtools/json-schema-ref-parser" "^15.3.3"
|
||||
"@redocly/openapi-core" "^2.25.2"
|
||||
@@ -7959,10 +7959,10 @@ docusaurus-plugin-openapi-docs@^5.1.2:
|
||||
swagger2openapi "^7.0.8"
|
||||
xml-formatter "^3.6.6"
|
||||
|
||||
docusaurus-theme-openapi-docs@^5.1.2:
|
||||
version "5.1.2"
|
||||
resolved "https://registry.yarnpkg.com/docusaurus-theme-openapi-docs/-/docusaurus-theme-openapi-docs-5.1.2.tgz#8591e3be971920c5eb347b9aab4bac77db5c7c31"
|
||||
integrity sha512-uJx+a4qHmpOnl+e7YzsPJSga6d6TLGEVZZPtI7KkzC/PgG7bS8E4P8hknvWqmAEahxhLWEb8izIA3up/0g9RwA==
|
||||
docusaurus-theme-openapi-docs@^5.1.3:
|
||||
version "5.1.3"
|
||||
resolved "https://registry.yarnpkg.com/docusaurus-theme-openapi-docs/-/docusaurus-theme-openapi-docs-5.1.3.tgz#e23644a63785352abbc76e42760c0dfdff3669e1"
|
||||
integrity sha512-npbD1QahtjAEmrOet/86i5fTmcJX4/rPhVT+c0qKjm7StUNbyqjwchSVBQuU1rB69T51JOA9TpT/y6QcB9Xjvw==
|
||||
dependencies:
|
||||
"@hookform/error-message" "^2.0.1"
|
||||
"@reduxjs/toolkit" "^2.8.2"
|
||||
@@ -7973,7 +7973,7 @@ docusaurus-theme-openapi-docs@^5.1.2:
|
||||
crypto-js "^4.2.0"
|
||||
file-saver "^2.0.5"
|
||||
lodash "^4.17.21"
|
||||
pako "^2.1.0"
|
||||
pako "^3.0.1"
|
||||
path-browserify "^1.0.1"
|
||||
postman-code-generators "^2.0.0"
|
||||
postman-collection "^5.0.2"
|
||||
@@ -7988,7 +7988,7 @@ docusaurus-theme-openapi-docs@^5.1.2:
|
||||
rehype-raw "^7.0.0"
|
||||
remark-gfm "4.0.1"
|
||||
sass "^1.89.2"
|
||||
sass-loader "^16.0.5"
|
||||
sass-loader "^17.0.0"
|
||||
unist-util-visit "^5.0.0"
|
||||
url "^0.11.4"
|
||||
xml-formatter "^3.6.6"
|
||||
@@ -8048,9 +8048,9 @@ domhandler@^5.0.2, domhandler@^5.0.3:
|
||||
domelementtype "^2.3.0"
|
||||
|
||||
dompurify@^3.3.3, dompurify@^3.4.12:
|
||||
version "3.4.12"
|
||||
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.4.12.tgz#6fa2265e9bbdce882c4ace4107626051b448ffa8"
|
||||
integrity sha512-zQvGet8Z2sWbQhCmfFz/T5QWH2oBmjnqK3qvOjaqaNLrLEF912WamU+ohnTp0TCep/MFVHpdJuCZEdFOdTnEFg==
|
||||
version "3.4.13"
|
||||
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.4.13.tgz#fc28949d59f92d62e28a3a764bcbeee35897a1be"
|
||||
integrity sha512-2vmYIoqjze2d+kakP8S/nS5shfsl587kzwEjcGlTdiksUVgFHnFCsLYDVj/JNqJVOQZGSYBTmuycv0PodwmnMQ==
|
||||
optionalDependencies:
|
||||
"@types/trusted-types" "^2.0.7"
|
||||
|
||||
@@ -10949,9 +10949,9 @@ merge2@^1.3.0, merge2@^1.4.1:
|
||||
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
|
||||
|
||||
mermaid@>=11.6.0:
|
||||
version "11.16.0"
|
||||
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-11.16.0.tgz#dc946bc84bde9d093ba14940d49df1d9f7d8c32f"
|
||||
integrity sha512-Zvm3kbstgdpvIJPPItlL7fppIZ3kibvc1oZIGxdvk9t6UFz6flv+Jw7FtRGKwfcI8OckmH04LqG6LlS6X4B1pA==
|
||||
version "11.16.1"
|
||||
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-11.16.1.tgz#57ae2342f6c45b967113b04c9258430bdd057ee8"
|
||||
integrity sha512-TQsq6u22fAn3rek5VOubrhKPo1g5hwC3FXUN9hiyupTckcYiGuuKGkNQrKYwGJkXUxZdojwRG46gsSCFZMDp4g==
|
||||
dependencies:
|
||||
"@braintree/sanitize-url" "^7.1.2"
|
||||
"@iconify/utils" "^3.0.2"
|
||||
@@ -11737,9 +11737,9 @@ mz@^2.7.0:
|
||||
thenify-all "^1.0.0"
|
||||
|
||||
nanoid@^3.3.16:
|
||||
version "3.3.16"
|
||||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.16.tgz#a04d8ec4b1f10009d2d533947aefe4293737816c"
|
||||
integrity sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==
|
||||
version "3.3.18"
|
||||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.18.tgz#f66a2de1199ffde0fcf21c8a5f13106b1c081913"
|
||||
integrity sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==
|
||||
|
||||
natural-compare@^1.4.0:
|
||||
version "1.4.0"
|
||||
@@ -12290,10 +12290,10 @@ package-manager-detector@^1.3.0:
|
||||
resolved "https://registry.yarnpkg.com/package-manager-detector/-/package-manager-detector-1.7.0.tgz#0a6d6d3856627b8ac9331f95fc891ea81247aafd"
|
||||
integrity sha512-xg1eHpwYL/D/HEdWw2goFZP6vV0FH7W+PZ5rFkGjdIDLtxq7EkzBUeT3m+lndYCt8wKbmofUu1MUdMCXkCk9ZQ==
|
||||
|
||||
pako@^2.1.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/pako/-/pako-2.2.0.tgz#246b9d4c841a8d308e484c0d03786651b143e63a"
|
||||
integrity sha512-zJq6RP/5q+TO2OpFV3FHzlPnFjmkb7Nc99a5SNjJE+uu/PkpChs+NIZSSzbBoD+6kjiISXjfYdwj1ZRQ81dz/w==
|
||||
pako@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/pako/-/pako-3.0.1.tgz#3156f8fa86e3cc2ae5a36369475b14d4f05696ce"
|
||||
integrity sha512-GupotUUI0mlhugKjUs4bjOwLt3nrehy9Ys2dxC0GtgVef5cnKggkDMmf2bq2poCCuVXopWPmqsc9VDT2iJUy+w==
|
||||
|
||||
param-case@^3.0.4:
|
||||
version "3.0.4"
|
||||
@@ -14182,12 +14182,10 @@ safe-regex-test@^1.1.0:
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
||||
|
||||
sass-loader@^16.0.5:
|
||||
version "16.0.8"
|
||||
resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-16.0.8.tgz#b7eef3b7947b32e2988dd760a2f7f0d547838e6b"
|
||||
integrity sha512-hcov4ZwZJIGbEuyNr9EmiTmZueyrxSToE6GOzoZnq5JM7ecRO7ttyvilPn+VmRsqiP16+VYZzVnGZj/hzZgKBA==
|
||||
dependencies:
|
||||
neo-async "^2.6.2"
|
||||
sass-loader@^17.0.0:
|
||||
version "17.0.0"
|
||||
resolved "https://registry.yarnpkg.com/sass-loader/-/sass-loader-17.0.0.tgz#8f4f8864d834c1abb18f0f3d2bc653bbf29dde2a"
|
||||
integrity sha512-0Ybm8ohBQ9LcrycVrFQp/KQBNX5a3Wda9/smS0mE/xLffzEnwvV8nykOzrbiSWNzTE3IB/jiXx8O4QmDPG2+Gw==
|
||||
|
||||
sass@^1.89.2:
|
||||
version "1.101.0"
|
||||
|
||||
@@ -68,19 +68,19 @@ dependencies = [
|
||||
# not just a connection-pool quirk. Needs dedicated investigation, not a
|
||||
# driver-compat-prep bump; revisit alongside the actual SQLAlchemy 2.0
|
||||
# core bump (discussion #40273, step 6).
|
||||
"flask-sqlalchemy>=2.5.1, <3.0",
|
||||
"flask-sqlalchemy>=2.5.1, <4.0",
|
||||
"flask-wtf>=1.3.0, <2.0",
|
||||
"geopy",
|
||||
"greenlet<=3.5.4, >=3.5.4",
|
||||
"gunicorn>=26.0.0, <27; sys_platform != 'win32'",
|
||||
"hashids>=1.3.1, <2",
|
||||
# holidays>=0.45 required for security fix
|
||||
"holidays>=0.99, <1",
|
||||
"holidays>=0.101, <1",
|
||||
"humanize",
|
||||
"isodate",
|
||||
"jsonpath-ng>=1.8.0, <2",
|
||||
"Mako>=1.2.2",
|
||||
"markdown>=3.10.2",
|
||||
"markdown>=3.10.3",
|
||||
# marshmallow 4 compatibility: see superset/marshmallow_compatibility.py for a
|
||||
# Flask-AppBuilder workaround. Tracking issue:
|
||||
# https://github.com/apache/superset/issues/33162
|
||||
@@ -88,7 +88,7 @@ dependencies = [
|
||||
"marshmallow-union>=0.1.15.post1",
|
||||
"msgpack>=1.2.0, <1.3",
|
||||
"nh3>=0.3.5, <0.4",
|
||||
"numpy>1.23.5, <2.3",
|
||||
"numpy>=1.23.5, <2.5",
|
||||
"packaging",
|
||||
# --------------------------
|
||||
# pandas and related (wanting pandas[performance] without numba as it's 100+MB and not needed)
|
||||
@@ -108,10 +108,10 @@ dependencies = [
|
||||
"pyarrow>=24.0.0, <26", # before upgrading pyarrow, check that all db dependencies support this, see e.g. https://github.com/apache/superset/pull/34693
|
||||
"pyyaml>=6.0.3, <7.0.0",
|
||||
"PyJWT>=2.4.0, <3.0",
|
||||
"redis>=5.0.0, <9.0",
|
||||
"redis>=8.1.0, <9.0",
|
||||
"rison>=2.0.1, <3.0",
|
||||
"selenium>=4.46.0, <5.0",
|
||||
"shillelagh[gsheetsapi]>=1.4.4, <2.0",
|
||||
"shillelagh[gsheetsapi]>=1.4.5, <2.0",
|
||||
"sshtunnel>=0.4.0, <0.5",
|
||||
"simplejson>=4.1.1",
|
||||
"slack_sdk>=3.43.0, <4",
|
||||
@@ -131,7 +131,7 @@ dependencies = [
|
||||
|
||||
[project.optional-dependencies]
|
||||
|
||||
athena = ["pyathena[pandas]>=3.35.2, <4"]
|
||||
athena = ["pyathena[pandas]>=3.35.4, <4"]
|
||||
# No SQLAlchemy 2.0 support anywhere in this dialect's ecosystem today: our
|
||||
# own preset-io/sqlalchemy-aurora-data-api fork is dead since 2021, and the
|
||||
# more active community fork (cloud-utils/sqlalchemy-aurora-data-api) has an
|
||||
@@ -143,7 +143,7 @@ bigquery = [
|
||||
# 1.17.1 is likely the final release: googleapis/python-bigquery-sqlalchemy
|
||||
# was archived 2026-05-16. Both 1.17.0 and 1.17.1 support SQLAlchemy 1.4/2.0.
|
||||
"sqlalchemy-bigquery>=1.17.1",
|
||||
"google-cloud-bigquery>=3.42.2",
|
||||
"google-cloud-bigquery>=3.42.3",
|
||||
]
|
||||
clickhouse = ["clickhouse-connect>=1.6.0, <2.0"]
|
||||
cockroachdb = ["cockroachdb>=0.3.5, <0.4"]
|
||||
@@ -204,7 +204,7 @@ fastmcp = [
|
||||
firebird = ["sqlalchemy-firebird>=0.8.0, <2.0.0"]
|
||||
firebolt = ["firebolt-sqlalchemy>=1.1.2, <2"]
|
||||
gevent = ["gevent>=26.7.0"]
|
||||
gsheets = ["shillelagh[gsheetsapi]>=1.4.4, <2"]
|
||||
gsheets = ["shillelagh[gsheetsapi]>=1.4.5, <2"]
|
||||
hana = ["hdbcli==2.29.25", "sqlalchemy_hana==3.0.3"]
|
||||
hive = [
|
||||
"pyhive[hive_pure_sasl]>=0.7.0",
|
||||
@@ -234,7 +234,7 @@ ocient = [
|
||||
oracle = ["oracledb>=4.0.2, <5"]
|
||||
parseable = ["sqlalchemy-parseable>=0.1.6,<0.2.0"]
|
||||
pinot = ["pinotdb>=5.0.0, <10.0.0"]
|
||||
playwright = ["playwright>=1.61.0, <2"]
|
||||
playwright = ["playwright>=1.62.0, <2"]
|
||||
postgres = ["psycopg2-binary==2.9.12"]
|
||||
presto = ["pyhive[presto]>=0.6.5"]
|
||||
trino = ["trino>=0.338.0"]
|
||||
@@ -248,8 +248,8 @@ redshift = ["sqlalchemy-redshift>=0.8.1, <0.9"]
|
||||
# and 2.0 (version numbers don't track SQLAlchemy compat monotonically); pin
|
||||
# to the newest 1.4-only release for now. Bump to >=2.0.0 in lockstep with
|
||||
# Superset's own SQLAlchemy 2.0 core bump (discussion #40273), not before.
|
||||
risingwave = ["sqlalchemy-risingwave>=1.4.1, <2.0.0"]
|
||||
shillelagh = ["shillelagh[all]>=1.4.4, <2"]
|
||||
risingwave = ["sqlalchemy-risingwave>=1.4.1, <3.0.0"]
|
||||
shillelagh = ["shillelagh[all]>=1.4.5, <2"]
|
||||
singlestore = ["sqlalchemy-singlestoredb>=1.2.1, <2"]
|
||||
snowflake = ["snowflake-sqlalchemy>=1.11.0, <2"]
|
||||
sqlite = ["syntaqlite>=0.7.0,<0.8.0"]
|
||||
@@ -262,11 +262,11 @@ tdengine = [
|
||||
"taospy>=2.8.10",
|
||||
"taos-ws-py>=0.7.0"
|
||||
]
|
||||
teradata = ["teradatasql>=20.0.0.63"]
|
||||
teradata = ["teradatasql>=20.0.0.64"]
|
||||
thumbnails = [] # deprecated, will be removed in 7.0
|
||||
vertica = ["sqlalchemy-vertica-python>= 0.6.3, < 0.7"]
|
||||
netezza = ["nzalchemy>= 11.1.2, < 11.2"]
|
||||
starrocks = ["starrocks>=1.3.3, <2"]
|
||||
starrocks = ["starrocks>=1.3.4, <2"]
|
||||
doris = ["pydoris>=1.2.0, <2.0.0"]
|
||||
oceanbase = ["oceanbase_py>=0.0.1.2"]
|
||||
ydb = ["ydb-sqlalchemy>=0.1.22", "ydb-sqlglot-plugin>=0.2.8"]
|
||||
@@ -286,7 +286,7 @@ development = [
|
||||
"progress>=1.6.1,<2",
|
||||
"psutil",
|
||||
"pyfakefs",
|
||||
"pyinstrument>=5.1.2,<6",
|
||||
"pyinstrument>=5.1.3,<6",
|
||||
"pylint",
|
||||
"pytest<10.0.0", # cap below the next major until validated; the earlier <8 pin (current_app proxy timing) no longer reproduces
|
||||
"pytest-asyncio",
|
||||
@@ -535,6 +535,11 @@ authorized_licenses = [
|
||||
# Seems ok, might need legal review
|
||||
# https://github.com/urschrei/pypolyline/blob/master/LICENSE.md
|
||||
polyline = "2"
|
||||
# NumPy 2.x reports a combined SPDX license expression covering vendored
|
||||
# code (BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0), all of which
|
||||
# are permissive OSI-approved licenses; the package itself remains
|
||||
# BSD-3-Clause. https://github.com/numpy/numpy/blob/main/LICENSE.txt
|
||||
numpy = "2"
|
||||
# --------------------------------------------------------------
|
||||
|
||||
# TODO REMOVE THESE DEPS FROM CODEBASE
|
||||
|
||||
@@ -178,7 +178,7 @@ h11==0.16.0
|
||||
# via wsproto
|
||||
hashids==1.3.1
|
||||
# via apache-superset (pyproject.toml)
|
||||
holidays==0.100
|
||||
holidays==0.102
|
||||
# via apache-superset (pyproject.toml)
|
||||
humanize==4.12.3
|
||||
# via apache-superset (pyproject.toml)
|
||||
@@ -219,7 +219,7 @@ mako==1.3.12
|
||||
# -r requirements/base.in
|
||||
# apache-superset (pyproject.toml)
|
||||
# alembic
|
||||
markdown==3.10.2
|
||||
markdown==3.10.3
|
||||
# via apache-superset (pyproject.toml)
|
||||
markdown-it-py==3.0.0
|
||||
# via rich
|
||||
@@ -251,7 +251,7 @@ nh3==0.3.6
|
||||
# via apache-superset (pyproject.toml)
|
||||
numexpr==2.10.2
|
||||
# via -r requirements/base.in
|
||||
numpy==1.26.4
|
||||
numpy==2.4.6
|
||||
# via
|
||||
# apache-superset (pyproject.toml)
|
||||
# bottleneck
|
||||
@@ -357,7 +357,7 @@ pyyaml==6.0.3
|
||||
# via
|
||||
# apache-superset (pyproject.toml)
|
||||
# apispec
|
||||
redis==8.0.1
|
||||
redis==8.1.0
|
||||
# via apache-superset (pyproject.toml)
|
||||
referencing==0.36.2
|
||||
# via
|
||||
@@ -384,7 +384,7 @@ selenium==4.46.0
|
||||
# via apache-superset (pyproject.toml)
|
||||
setuptools==80.9.0
|
||||
# via -r requirements/base.in
|
||||
shillelagh==1.4.4
|
||||
shillelagh==1.4.5
|
||||
# via apache-superset (pyproject.toml)
|
||||
simplejson==4.1.1
|
||||
# via apache-superset (pyproject.toml)
|
||||
|
||||
@@ -363,7 +363,7 @@ google-auth-oauthlib==1.2.1
|
||||
# via
|
||||
# pandas-gbq
|
||||
# pydata-google-auth
|
||||
google-cloud-bigquery==3.42.2
|
||||
google-cloud-bigquery==3.43.0
|
||||
# via
|
||||
# apache-superset
|
||||
# pandas-gbq
|
||||
@@ -408,7 +408,7 @@ hashids==1.3.1
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
holidays==0.100
|
||||
holidays==0.102
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
@@ -521,7 +521,7 @@ mako==1.3.12
|
||||
# -c requirements/base-constraint.txt
|
||||
# alembic
|
||||
# apache-superset
|
||||
markdown==3.10.2
|
||||
markdown==3.10.3
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
@@ -581,7 +581,7 @@ nh3==0.3.6
|
||||
# apache-superset
|
||||
nodeenv==1.8.0
|
||||
# via pre-commit
|
||||
numpy==1.26.4
|
||||
numpy==2.4.6
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
@@ -776,7 +776,7 @@ pygments==2.20.0
|
||||
# rich
|
||||
pyhive==0.7.0
|
||||
# via apache-superset
|
||||
pyinstrument==5.1.2
|
||||
pyinstrument==5.1.3
|
||||
# via apache-superset
|
||||
pyjwt==2.13.0
|
||||
# via
|
||||
@@ -874,7 +874,7 @@ pyyaml==6.0.3
|
||||
# fastmcp-slim
|
||||
# jsonschema-path
|
||||
# pre-commit
|
||||
redis==8.0.1
|
||||
redis==8.1.0
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
@@ -948,7 +948,7 @@ setuptools==80.9.0
|
||||
# pydata-google-auth
|
||||
# zope-event
|
||||
# zope-interface
|
||||
shillelagh==1.4.4
|
||||
shillelagh==1.4.5
|
||||
# via
|
||||
# -c requirements/base-constraint.txt
|
||||
# apache-superset
|
||||
|
||||
@@ -1,82 +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 { SAMPLE_DASHBOARD_1 } from 'cypress/utils/urls';
|
||||
import { drag } from 'cypress/utils';
|
||||
import { interceptGet } from './utils';
|
||||
import { interceptFiltering as interceptCharts } from '../explore/utils';
|
||||
|
||||
function editDashboard() {
|
||||
cy.getBySel('edit-dashboard-button').click();
|
||||
}
|
||||
|
||||
function dragComponent(
|
||||
component = 'Unicode Cloud',
|
||||
target = 'card-title',
|
||||
withFiltering = true,
|
||||
) {
|
||||
if (withFiltering) {
|
||||
cy.getBySel('dashboard-charts-filter-search-input').type(component, {
|
||||
force: true,
|
||||
});
|
||||
cy.wait('@filtering');
|
||||
}
|
||||
cy.wait(500);
|
||||
drag(`[data-test="${target}"]`, component).to(
|
||||
'[data-test="grid-content"] [data-test="dragdroppable-object"]',
|
||||
);
|
||||
}
|
||||
|
||||
function visitEdit(sampleDashboard = SAMPLE_DASHBOARD_1) {
|
||||
interceptCharts();
|
||||
interceptGet();
|
||||
|
||||
if (sampleDashboard === SAMPLE_DASHBOARD_1) {
|
||||
cy.createSampleDashboards([0]);
|
||||
}
|
||||
|
||||
cy.visit(sampleDashboard);
|
||||
cy.wait('@get');
|
||||
editDashboard();
|
||||
cy.get('.grid-container').should('exist');
|
||||
cy.wait('@filtering');
|
||||
cy.wait(500);
|
||||
}
|
||||
|
||||
describe('Dashboard edit', () => {
|
||||
describe('Components', () => {
|
||||
beforeEach(() => {
|
||||
visitEdit();
|
||||
});
|
||||
|
||||
it('should add charts', () => {
|
||||
cy.get('body').then($body => {
|
||||
if ($body.find('.ant-modal-wrap').length > 0) {
|
||||
cy.get('body').type('{esc}', { force: true });
|
||||
cy.wait(1000);
|
||||
cy.get('.ant-modal-close').click({ force: true });
|
||||
cy.wait(500);
|
||||
}
|
||||
});
|
||||
cy.get('input[type="checkbox"]').scrollIntoView();
|
||||
cy.get('input[type="checkbox"]').click({ force: true });
|
||||
dragComponent();
|
||||
cy.getBySel('dashboard-component-chart-holder').should('have.length', 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -138,6 +138,7 @@ export function prepareDashboardFilters(
|
||||
chart_customization_config: [],
|
||||
timed_refresh_immune_slices: [],
|
||||
expanded_slices: {},
|
||||
expand_all_slices: false,
|
||||
refresh_frequency: 0,
|
||||
color_scheme: '',
|
||||
label_colors: {},
|
||||
|
||||
@@ -79,34 +79,6 @@ export function waitForChartLoad(chart: ChartSpec) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag an element and drop it to another element.
|
||||
* Usage:
|
||||
* drag(source).to(target);
|
||||
*/
|
||||
export function drag(selector: string, content: string | number | RegExp) {
|
||||
const dataTransfer = { data: {} };
|
||||
return {
|
||||
to(target: string | Cypress.Chainable) {
|
||||
cy.get('.dragdroppable')
|
||||
.contains(selector, content)
|
||||
.trigger('mousedown', { which: 1, force: true });
|
||||
cy.get('.dragdroppable')
|
||||
.contains(selector, content)
|
||||
.trigger('dragstart', { dataTransfer, force: true });
|
||||
cy.get('.dragdroppable')
|
||||
.contains(selector, content)
|
||||
.trigger('drag', { force: true });
|
||||
|
||||
(typeof target === 'string' ? cy.get(target) : target)
|
||||
.trigger('dragover', { dataTransfer, force: true })
|
||||
.trigger('drop', { dataTransfer, force: true })
|
||||
.trigger('dragend', { dataTransfer, force: true })
|
||||
.trigger('mouseup', { which: 1, force: true });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function resize(selector: string) {
|
||||
return {
|
||||
to(cordX: number, cordY: number) {
|
||||
|
||||
@@ -65,7 +65,6 @@
|
||||
"ensure-oxc": "echo 'OXC linter is ready' && npx oxlint --version",
|
||||
"lint-stats": "node ./scripts/oxlint-metrics-uploader.js",
|
||||
"plugins:build": "node ./scripts/build.js",
|
||||
"plugins:build-assets": "node ./scripts/copyAssets.js",
|
||||
"plugins:create-conventional-version": "npm run prune && lerna version --conventional-commits --create-release github --no-private --yes --tag-version-prefix=\"plugins-and-packages-v\"",
|
||||
"plugins:create-minor-version": "npm run prune && lerna version minor --no-private --yes --tag-version-prefix=\"plugins-and-packages-v\"",
|
||||
"plugins:create-patch-version": "npm run prune && lerna version patch --no-private --yes --tag-version-prefix=\"plugins-and-packages-v\"",
|
||||
@@ -87,7 +86,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"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -128,24 +127,22 @@
|
||||
"@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-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/switchboard": "file:./packages/superset-ui-switchboard",
|
||||
"@types/d3-format": "^3.0.1",
|
||||
@@ -169,8 +166,6 @@
|
||||
"dom-to-image-more": "^3.10.2",
|
||||
"dom-to-pdf": "^0.3.2",
|
||||
"echarts": "^6.1.0",
|
||||
"fast-glob": "^3.3.2",
|
||||
"fs-extra": "^11.4.0",
|
||||
"fuse.js": "^7.5.0",
|
||||
"geolib": "^3.3.14",
|
||||
"geostyler": "^18.6.0",
|
||||
@@ -178,7 +173,7 @@
|
||||
"geostyler-openlayers-parser": "^5.7.1",
|
||||
"geostyler-style": "11.0.2",
|
||||
"geostyler-wfs-parser": "^3.0.1",
|
||||
"google-auth-library": "^10.9.1",
|
||||
"google-auth-library": "^11.0.0",
|
||||
"immer": "^11.1.15",
|
||||
"interweave": "^13.1.1",
|
||||
"jquery": "^4.0.0",
|
||||
@@ -188,7 +183,7 @@
|
||||
"lodash": "^4.18.1",
|
||||
"lodash-es": "^4.18.1",
|
||||
"mapbox-gl": "^3.27.0",
|
||||
"markdown-to-jsx": "^9.9.0",
|
||||
"markdown-to-jsx": "^9.10.1",
|
||||
"match-sorter": "^8.3.0",
|
||||
"memoize-one": "^6.0.0",
|
||||
"mousetrap": "^1.6.5",
|
||||
@@ -205,7 +200,7 @@
|
||||
"react-dnd-html5-backend": "^11.1.3",
|
||||
"react-dom": "^18.3.0",
|
||||
"react-google-recaptcha": "^3.1.0",
|
||||
"react-intersection-observer": "^10.1.0",
|
||||
"react-intersection-observer": "^11.0.0",
|
||||
"react-json-tree": "^0.20.0",
|
||||
"react-lines-ellipsis": "^0.16.1",
|
||||
"react-loadable": "^5.5.0",
|
||||
@@ -218,7 +213,7 @@
|
||||
"react-table": "^7.8.0",
|
||||
"react-transition-group": "^4.4.5",
|
||||
"react-virtualized-auto-sizer": "^1.0.26",
|
||||
"react-window": "^1.8.10",
|
||||
"react-window": "^2.3.0",
|
||||
"redux": "^4.2.1",
|
||||
"redux-localstorage": "^0.4.1",
|
||||
"redux-thunk": "^2.1.0",
|
||||
@@ -257,7 +252,7 @@
|
||||
"@emotion/jest": "^11.14.2",
|
||||
"@formatjs/intl-durationformat": "^0.10.18",
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
||||
"@playwright/test": "^1.61.1",
|
||||
"@playwright/test": "^1.62.1",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
|
||||
"@storybook/addon-docs": "10.5.5",
|
||||
"@storybook/addon-links": "10.5.5",
|
||||
@@ -286,7 +281,6 @@
|
||||
"@types/react-redux": "^7.1.10",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@types/react-transition-group": "^4.4.12",
|
||||
"@types/react-window": "^1.8.8",
|
||||
"@types/redux-localstorage": "^1.0.8",
|
||||
"@types/redux-mock-store": "^1.0.6",
|
||||
"@types/rison": "0.1.0",
|
||||
@@ -298,7 +292,7 @@
|
||||
"babel-loader": "^10.1.1",
|
||||
"babel-plugin-dynamic-import-node": "^2.3.3",
|
||||
"babel-plugin-jsx-remove-data-test-id": "^3.0.0",
|
||||
"baseline-browser-mapping": "^2.11.7",
|
||||
"baseline-browser-mapping": "^2.11.8",
|
||||
"cheerio": "1.2.0",
|
||||
"concurrently": "^10.0.4",
|
||||
"copy-webpack-plugin": "^14.0.0",
|
||||
@@ -310,7 +304,7 @@
|
||||
"eslint-plugin-i18n-strings": "file:eslint-rules/eslint-plugin-i18n-strings",
|
||||
"eslint-plugin-icons": "file:eslint-rules/eslint-plugin-icons",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jest-dom": "^5.6.0",
|
||||
"eslint-plugin-jest-dom": "^5.7.0",
|
||||
"eslint-plugin-lodash": "^8.0.0",
|
||||
"eslint-plugin-no-only-tests": "^3.4.0",
|
||||
"eslint-plugin-react-prefer-function-component": "^5.0.0",
|
||||
@@ -329,7 +323,7 @@
|
||||
"jest-websocket-mock": "^2.5.0",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
"jsdom": "^30.0.1",
|
||||
"lerna": "^9.0.4",
|
||||
"lerna": "^10.0.0",
|
||||
"lightningcss": "^1.33.0",
|
||||
"mini-css-extract-plugin": "^2.10.2",
|
||||
"minimizer-webpack-plugin": "^5.6.1",
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
import { dirname, join } from 'path';
|
||||
// @ts-ignore -- yeoman-test type resolution differs between local and Docker environments
|
||||
import helpers from 'yeoman-test';
|
||||
// @ts-ignore -- fs-extra/esm has no type declarations
|
||||
import { copySync } from 'fs-extra/esm';
|
||||
import { cpSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import pluginChartModule from '../generators/plugin-chart';
|
||||
|
||||
@@ -31,9 +30,10 @@ test('generator-superset:plugin-chart:creates files', async () => {
|
||||
.onTargetDirectory((dir: string) => {
|
||||
// `dir` is the path to the new temporary directory
|
||||
const generatorDirname = dirname(fileURLToPath(import.meta.url));
|
||||
copySync(
|
||||
cpSync(
|
||||
join(generatorDirname, '../generators/plugin-chart/templates'),
|
||||
join(dir, 'unknown/templates'),
|
||||
{ recursive: true },
|
||||
);
|
||||
})
|
||||
.withPrompts({
|
||||
|
||||
@@ -109,7 +109,6 @@
|
||||
"@types/lodash": "^4.17.24",
|
||||
"@types/react": "*",
|
||||
"@types/react-loadable": "*",
|
||||
"@types/react-window": "^1.8.8",
|
||||
"@types/tinycolor2": "*",
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
|
||||
@@ -36,6 +36,7 @@ import type {
|
||||
QueryResponse,
|
||||
TimeFormatter,
|
||||
} from '@superset-ui/core';
|
||||
import { type RGBColor } from '@superset-ui/core/components';
|
||||
import { GenericDataType } from '@apache-superset/core/common';
|
||||
import { sharedControls, sharedControlComponents } from './shared-controls';
|
||||
|
||||
@@ -494,7 +495,7 @@ export type ConditionalFormattingConfig = {
|
||||
targetValueLeft?: number;
|
||||
targetValueRight?: number;
|
||||
column?: string;
|
||||
colorScheme?: string;
|
||||
colorScheme?: RGBColor | string;
|
||||
toAllRow?: boolean;
|
||||
toTextColor?: boolean;
|
||||
useGradient?: boolean;
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* 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 { ensureIsArray, getMetricLabel } from '@superset-ui/core';
|
||||
import type { QueryFormMetric, QueryFormOrderBy } from '@superset-ui/core';
|
||||
|
||||
export interface BuildSortMetricOrderbyConfig {
|
||||
/** The query's already-resolved metrics list. */
|
||||
metrics: QueryFormMetric[];
|
||||
/** The raw `timeseries_limit_metric` form-data value (single or multi). */
|
||||
timeseriesLimitMetric?: QueryFormMetric | QueryFormMetric[] | null;
|
||||
order_desc?: boolean;
|
||||
/**
|
||||
* Falls back to the first selected metric when no sort metric is set.
|
||||
* Charts ported from a legacy viz whose query_obj always had a sort
|
||||
* metric (defaulting to the first one) should set this; charts whose
|
||||
* legacy query_obj left ordering absent without one should not.
|
||||
*/
|
||||
fallbackToFirstMetric?: boolean;
|
||||
/**
|
||||
* When true, only order when `order_desc` is set (matching legacy vizzes
|
||||
* whose query_obj left the result unordered unless the operator asked
|
||||
* for descending). When false, always order (ascending unless
|
||||
* order_desc), matching legacy vizzes that ordered unconditionally.
|
||||
*/
|
||||
orderOnlyWhenDesc?: boolean;
|
||||
}
|
||||
|
||||
export interface SortMetricOrderby {
|
||||
/** `metrics`, with the sort metric appended if it wasn't already selected. */
|
||||
metrics: QueryFormMetric[];
|
||||
orderby: QueryFormOrderBy[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a chart's sort metric and builds the corresponding query_obj
|
||||
* `orderby`, appending the sort metric to `metrics` if it isn't already
|
||||
* selected (so its value is present in the result to sort by). Several
|
||||
* charts ported from the legacy chart-data pipeline share this exact
|
||||
* shape with only the fallback/gating policy differing per their own
|
||||
* legacy `query_obj` behavior -- see `fallbackToFirstMetric` and
|
||||
* `orderOnlyWhenDesc`.
|
||||
*/
|
||||
export function buildSortMetricOrderby({
|
||||
metrics,
|
||||
timeseriesLimitMetric,
|
||||
order_desc: orderDesc,
|
||||
fallbackToFirstMetric = false,
|
||||
orderOnlyWhenDesc = false,
|
||||
}: BuildSortMetricOrderbyConfig): SortMetricOrderby {
|
||||
const sortByMetric =
|
||||
ensureIsArray(timeseriesLimitMetric)[0] ??
|
||||
(fallbackToFirstMetric ? metrics[0] : undefined);
|
||||
|
||||
if (!sortByMetric) {
|
||||
return { metrics, orderby: [] };
|
||||
}
|
||||
|
||||
const sortByLabel = getMetricLabel(sortByMetric);
|
||||
const nextMetrics = metrics.some(
|
||||
metric => getMetricLabel(metric) === sortByLabel,
|
||||
)
|
||||
? metrics
|
||||
: [...metrics, sortByMetric];
|
||||
|
||||
const shouldOrder = orderOnlyWhenDesc ? Boolean(orderDesc) : true;
|
||||
|
||||
return {
|
||||
metrics: nextMetrics,
|
||||
orderby: shouldOrder ? [[sortByMetric, !orderDesc]] : [],
|
||||
};
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
import memoizeOne from 'memoize-one';
|
||||
import { isString, isBoolean } from 'lodash-es';
|
||||
import { isBlank } from '@apache-superset/core/utils';
|
||||
import { addAlpha, DataRecord } from '@superset-ui/core';
|
||||
import { addAlpha, DataRecord, rgbaToHex } from '@superset-ui/core';
|
||||
import tinycolor from 'tinycolor2';
|
||||
import {
|
||||
ColorFormatters,
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
ConditionalFormattingConfig,
|
||||
MultipleValueComparators,
|
||||
ResolvedColorFormatterResult,
|
||||
ColorSchemeEnum,
|
||||
} from '../types';
|
||||
|
||||
export const round = (num: number, precision = 0) =>
|
||||
@@ -71,6 +72,9 @@ export const getOpacity = (
|
||||
);
|
||||
};
|
||||
|
||||
const isSpecialColor = (value: unknown): value is ColorSchemeEnum =>
|
||||
Object.values(ColorSchemeEnum).includes(value as ColorSchemeEnum);
|
||||
|
||||
export const getColorFunction = (
|
||||
{
|
||||
operator,
|
||||
@@ -270,19 +274,51 @@ export const getColorFunction = (
|
||||
if (compareResult === false) return undefined;
|
||||
const { cutoffValue, extremeValue } = compareResult;
|
||||
|
||||
// If useGradient is explicitly false, return solid color
|
||||
if (useGradient === false) {
|
||||
if (typeof colorScheme === 'string') {
|
||||
if (isSpecialColor(colorScheme)) {
|
||||
return colorScheme;
|
||||
}
|
||||
|
||||
if (
|
||||
useGradient === false ||
|
||||
(useGradient === undefined && colorScheme.length === 9)
|
||||
) {
|
||||
if (alpha === false) {
|
||||
return colorScheme.length === 9
|
||||
? colorScheme.slice(0, 7)
|
||||
: colorScheme;
|
||||
}
|
||||
return colorScheme;
|
||||
}
|
||||
|
||||
const cleanHex =
|
||||
colorScheme.length === 9 ? colorScheme.slice(0, 7) : colorScheme;
|
||||
|
||||
if (alpha === undefined || alpha) {
|
||||
return addAlpha(
|
||||
cleanHex,
|
||||
getOpacity(value, cutoffValue, extremeValue, minOpacity, maxOpacity),
|
||||
);
|
||||
}
|
||||
return colorScheme;
|
||||
}
|
||||
// If useGradient is explicitly false, return solid color
|
||||
if (useGradient === false || useGradient === undefined) {
|
||||
if (alpha === false) {
|
||||
return rgbaToHex({ ...colorScheme, a: 1 });
|
||||
}
|
||||
return rgbaToHex(colorScheme);
|
||||
}
|
||||
|
||||
const baseHexColor = rgbaToHex({ ...colorScheme, a: 1 });
|
||||
// Otherwise apply gradient (default behavior for backward compatibility)
|
||||
if (alpha === undefined || alpha) {
|
||||
return addAlpha(
|
||||
colorScheme,
|
||||
baseHexColor,
|
||||
getOpacity(value, cutoffValue, extremeValue, minOpacity, maxOpacity),
|
||||
);
|
||||
}
|
||||
return colorScheme;
|
||||
return baseHexColor;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -30,3 +30,4 @@ export * from './getTemporalColumns';
|
||||
export * from './displayTimeRelatedControls';
|
||||
export * from './colorControls';
|
||||
export * from './metricColumnFilter';
|
||||
export * from './buildSortMetricOrderby';
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* 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 { buildSortMetricOrderby } from '../../src';
|
||||
|
||||
test('is a no-op when there is no sort metric and no fallback', () => {
|
||||
const result = buildSortMetricOrderby({
|
||||
metrics: ['sum__num'],
|
||||
timeseriesLimitMetric: undefined,
|
||||
});
|
||||
expect(result).toEqual({ metrics: ['sum__num'], orderby: [] });
|
||||
});
|
||||
|
||||
test('falls back to the first metric when configured to', () => {
|
||||
const result = buildSortMetricOrderby({
|
||||
metrics: ['sum__num', 'avg__num'],
|
||||
timeseriesLimitMetric: undefined,
|
||||
fallbackToFirstMetric: true,
|
||||
});
|
||||
expect(result.metrics).toEqual(['sum__num', 'avg__num']);
|
||||
expect(result.orderby).toEqual([['sum__num', true]]);
|
||||
});
|
||||
|
||||
test('appends the sort metric when it is not already selected', () => {
|
||||
const result = buildSortMetricOrderby({
|
||||
metrics: ['sum__num'],
|
||||
timeseriesLimitMetric: 'count',
|
||||
});
|
||||
expect(result.metrics).toEqual(['sum__num', 'count']);
|
||||
});
|
||||
|
||||
test('does not duplicate the sort metric when already selected', () => {
|
||||
const result = buildSortMetricOrderby({
|
||||
metrics: ['sum__num', 'count'],
|
||||
timeseriesLimitMetric: 'count',
|
||||
});
|
||||
expect(result.metrics).toEqual(['sum__num', 'count']);
|
||||
});
|
||||
|
||||
test('unconditional ordering (orderOnlyWhenDesc: false) always orders, flipping direction', () => {
|
||||
const ascending = buildSortMetricOrderby({
|
||||
metrics: ['sum__num'],
|
||||
timeseriesLimitMetric: 'count',
|
||||
order_desc: false,
|
||||
});
|
||||
expect(ascending.orderby).toEqual([['count', true]]);
|
||||
|
||||
const descending = buildSortMetricOrderby({
|
||||
metrics: ['sum__num'],
|
||||
timeseriesLimitMetric: 'count',
|
||||
order_desc: true,
|
||||
});
|
||||
expect(descending.orderby).toEqual([['count', false]]);
|
||||
});
|
||||
|
||||
test('gated ordering (orderOnlyWhenDesc: true) only orders when order_desc is set', () => {
|
||||
const withoutDesc = buildSortMetricOrderby({
|
||||
metrics: ['sum__num'],
|
||||
timeseriesLimitMetric: 'count',
|
||||
orderOnlyWhenDesc: true,
|
||||
});
|
||||
expect(withoutDesc.metrics).toEqual(['sum__num', 'count']);
|
||||
expect(withoutDesc.orderby).toEqual([]);
|
||||
|
||||
const withDesc = buildSortMetricOrderby({
|
||||
metrics: ['sum__num'],
|
||||
timeseriesLimitMetric: 'count',
|
||||
order_desc: true,
|
||||
orderOnlyWhenDesc: true,
|
||||
});
|
||||
expect(withDesc.orderby).toEqual([['count', false]]);
|
||||
});
|
||||
|
||||
test('resolves a multi-value timeseriesLimitMetric to its first entry', () => {
|
||||
const result = buildSortMetricOrderby({
|
||||
metrics: ['sum__num'],
|
||||
timeseriesLimitMetric: ['count', 'avg__num'],
|
||||
});
|
||||
expect(result.metrics).toEqual(['sum__num', 'count']);
|
||||
expect(result.orderby).toEqual([['count', true]]);
|
||||
});
|
||||
@@ -952,3 +952,167 @@ test('correct column boolean config', () => {
|
||||
expect(colorFormatters[3].getColorFromValue(true)).toEqual('#FF0000FF');
|
||||
expect(colorFormatters[3].getColorFromValue(false)).toEqual('#FF0000FF');
|
||||
});
|
||||
|
||||
test('should return hex color when colorScheme is an RGB object', () => {
|
||||
const colorFunction = getColorFunction(
|
||||
{
|
||||
operator: Comparator.None,
|
||||
colorScheme: { r: 255, g: 128, b: 0, a: 1 },
|
||||
column: 'name',
|
||||
},
|
||||
strValues,
|
||||
);
|
||||
expect(colorFunction('Diana')).toEqual('#ff8000');
|
||||
expect(colorFunction('Carlos')).toEqual('#ff8000');
|
||||
expect(colorFunction('Brian')).toEqual('#ff8000');
|
||||
});
|
||||
|
||||
test('should return token name as-is when colorScheme is a string token', () => {
|
||||
const colorFunction = getColorFunction(
|
||||
{
|
||||
operator: Comparator.None,
|
||||
colorScheme: 'Green',
|
||||
column: 'name',
|
||||
},
|
||||
strValues,
|
||||
);
|
||||
expect(colorFunction('Diana')).toEqual('Green');
|
||||
expect(colorFunction('Carlos')).toEqual('Green');
|
||||
expect(colorFunction('Brian')).toEqual('Green');
|
||||
});
|
||||
|
||||
test('should return solid hex color when useGradient is false or true', () => {
|
||||
const columnConfig = [
|
||||
{
|
||||
operator: Comparator.GreaterThan,
|
||||
targetValue: 50,
|
||||
colorScheme: { r: 0, g: 47, b: 255, a: 1 },
|
||||
column: 'count',
|
||||
useGradient: false,
|
||||
},
|
||||
{
|
||||
operator: Comparator.GreaterThan,
|
||||
targetValue: 50,
|
||||
colorScheme: { r: 255, g: 166, b: 0, a: 1 },
|
||||
column: 'count',
|
||||
useGradient: true,
|
||||
},
|
||||
];
|
||||
const colorFormatters = getColorFormatters(columnConfig, mockData);
|
||||
expect(colorFormatters.length).toEqual(2);
|
||||
|
||||
// First formatter with useGradient: false should return solid color
|
||||
expect(colorFormatters[0].column).toEqual('count');
|
||||
expect(colorFormatters[0].getColorFromValue(100)).toEqual('#002fff');
|
||||
|
||||
// Second formatter with useGradient: true should return gradient color
|
||||
expect(colorFormatters[1].column).toEqual('count');
|
||||
expect(colorFormatters[1].getColorFromValue(100)).toEqual('#ffa600FF');
|
||||
});
|
||||
|
||||
test('should return hex color without alpha for GreaterThan operator with RGB colorScheme', () => {
|
||||
const config = {
|
||||
operator: Comparator.GreaterThan,
|
||||
targetValue: 50,
|
||||
colorScheme: { r: 255, g: 0, b: 0, a: 1 },
|
||||
useGradient: true,
|
||||
};
|
||||
|
||||
const columnValues = [10, 50, 100];
|
||||
|
||||
const alpha = false;
|
||||
const colorFunction = getColorFunction(config, columnValues, alpha);
|
||||
|
||||
expect(colorFunction(100)).toEqual('#ff0000');
|
||||
});
|
||||
|
||||
test('should preserve alpha from colorScheme when useGradient is false', () => {
|
||||
const config = {
|
||||
operator: Comparator.None,
|
||||
colorScheme: { r: 255, g: 0, b: 0, a: 0.5 },
|
||||
useGradient: false,
|
||||
};
|
||||
|
||||
const colorFunction = getColorFunction(config, [10, 20, 30]);
|
||||
const result = colorFunction(20);
|
||||
|
||||
expect(result).not.toBe('#ff0000');
|
||||
expect(result).not.toBe('rgb(255, 0, 0)');
|
||||
});
|
||||
|
||||
test('should force opaque color when useGradient is false but alpha is explicitly false', () => {
|
||||
const config = {
|
||||
operator: Comparator.None,
|
||||
colorScheme: { r: 255, g: 0, b: 0, a: 0.5 },
|
||||
useGradient: false,
|
||||
};
|
||||
|
||||
const colorFunction = getColorFunction(config, [10, 20, 30], false);
|
||||
const result = colorFunction(20);
|
||||
|
||||
expect(result).toBe('#ff0000');
|
||||
});
|
||||
|
||||
test('should return colorScheme as-is when alpha is false and length is 7', () => {
|
||||
const colorFunction = getColorFunction(
|
||||
{
|
||||
operator: Comparator.GreaterThan,
|
||||
targetValue: 50,
|
||||
colorScheme: '#FF0000',
|
||||
useGradient: false,
|
||||
column: 'count',
|
||||
},
|
||||
countValues,
|
||||
false,
|
||||
);
|
||||
|
||||
expect(colorFunction(100)).toEqual('#FF0000');
|
||||
});
|
||||
|
||||
test('should preserve alpha when alpha is undefined and colorScheme has 9 chars', () => {
|
||||
const colorFunction = getColorFunction(
|
||||
{
|
||||
operator: Comparator.GreaterThan,
|
||||
targetValue: 50,
|
||||
colorScheme: '#FF000080',
|
||||
useGradient: false,
|
||||
column: 'count',
|
||||
},
|
||||
countValues,
|
||||
);
|
||||
|
||||
expect(colorFunction(100)).toEqual('#FF000080');
|
||||
});
|
||||
|
||||
test('should preserve alpha when alpha is true and colorScheme has 9 chars', () => {
|
||||
const colorFunction = getColorFunction(
|
||||
{
|
||||
operator: Comparator.GreaterThan,
|
||||
targetValue: 50,
|
||||
colorScheme: '#FF000080',
|
||||
useGradient: false,
|
||||
column: 'count',
|
||||
},
|
||||
countValues,
|
||||
true,
|
||||
);
|
||||
|
||||
expect(colorFunction(100)).toEqual('#FF000080');
|
||||
});
|
||||
|
||||
test('should strip alpha channel when alpha is false and colorScheme has 9 chars', () => {
|
||||
const colorFunction = getColorFunction(
|
||||
{
|
||||
operator: Comparator.GreaterThan,
|
||||
targetValue: 50,
|
||||
colorScheme: '#FF000080',
|
||||
useGradient: false,
|
||||
column: 'count',
|
||||
},
|
||||
countValues,
|
||||
false,
|
||||
);
|
||||
|
||||
expect(colorFunction(100)).toEqual('#FF0000');
|
||||
expect(colorFunction(100)).toHaveLength(7);
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
"d3-time": "^3.1.0",
|
||||
"d3-time-format": "^4.1.0",
|
||||
"dayjs": "^1.11.21",
|
||||
"dompurify": "^3.4.12",
|
||||
"dompurify": "^3.4.13",
|
||||
"fetch-retry": "^6.0.0",
|
||||
"handlebars": "^4.7.9",
|
||||
"jed": "^1.1.1",
|
||||
@@ -123,7 +123,6 @@
|
||||
"@testing-library/user-event": "*",
|
||||
"@types/react": "*",
|
||||
"@types/react-loadable": "*",
|
||||
"@types/react-window": "^1.8.8",
|
||||
"@types/tinycolor2": "*",
|
||||
"antd": "^6.0.0",
|
||||
"nanoid": "*",
|
||||
|
||||
@@ -104,30 +104,19 @@ 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: buildQuery(formData),
|
||||
...options,
|
||||
};
|
||||
|
||||
return this.client
|
||||
.post(requestConfig)
|
||||
.then(response =>
|
||||
Array.isArray(response.json) ? response.json : [response.json],
|
||||
);
|
||||
return this.client.post(requestConfig).then(response => {
|
||||
const { result } = response.json as { result?: QueryData[] };
|
||||
|
||||
return Array.isArray(result) ? result : [response.json as QueryData];
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(new Error(`Unknown chart type: ${visType}`));
|
||||
|
||||
@@ -21,7 +21,6 @@ import { render, waitFor, configure, act } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
import StatefulChart from './StatefulChart';
|
||||
import getChartControlPanelRegistry from '../registries/ChartControlPanelRegistrySingleton';
|
||||
import getChartMetadataRegistry from '../registries/ChartMetadataRegistrySingleton';
|
||||
import getChartBuildQueryRegistry from '../registries/ChartBuildQueryRegistrySingleton';
|
||||
|
||||
// Configure testing library to use data-test attribute
|
||||
@@ -29,7 +28,6 @@ configure({ testIdAttribute: 'data-test' });
|
||||
|
||||
// Mock the registries
|
||||
jest.mock('../registries/ChartControlPanelRegistrySingleton');
|
||||
jest.mock('../registries/ChartMetadataRegistrySingleton');
|
||||
jest.mock('../registries/ChartBuildQueryRegistrySingleton');
|
||||
jest.mock('../clients/ChartClient');
|
||||
|
||||
@@ -67,12 +65,6 @@ beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
||||
// Setup default registry mocks
|
||||
jest.mocked(getChartMetadataRegistry).mockReturnValue({
|
||||
get: jest.fn().mockReturnValue({
|
||||
useLegacyApi: false,
|
||||
}),
|
||||
} as unknown as ReturnType<typeof getChartMetadataRegistry>);
|
||||
|
||||
jest.mocked(getChartBuildQueryRegistry).mockReturnValue({
|
||||
get: jest.fn().mockResolvedValue(null),
|
||||
} as unknown as ReturnType<typeof getChartBuildQueryRegistry>);
|
||||
@@ -746,11 +738,10 @@ test('resolves async (202) responses via the injected handleAsyncChartData hook'
|
||||
await waitFor(() => {
|
||||
expect(handleAsyncChartData).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
// Delegates the raw response + job metadata (and useLegacyApi + abort signal)
|
||||
// Delegates the raw response + job metadata (and abort signal)
|
||||
expect(handleAsyncChartData).toHaveBeenCalledWith(
|
||||
{ status: 202 },
|
||||
asyncJob,
|
||||
false,
|
||||
expect.any(AbortSignal),
|
||||
);
|
||||
// Chart renders once the async data resolves
|
||||
@@ -798,43 +789,6 @@ test('renders synchronous (200) responses that include a response object', async
|
||||
expect(mockChartClient.client.post).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('wraps the legacy async body as { result: [body] } for the async handler', async () => {
|
||||
const legacyBody = { job_id: 'j1', channel_id: 'c1', status: 'running' };
|
||||
mockChartClient.client.post.mockResolvedValue({
|
||||
response: { status: 202 } as Response,
|
||||
json: legacyBody,
|
||||
});
|
||||
// Force the legacy API path for this viz type
|
||||
jest.mocked(getChartMetadataRegistry).mockReturnValue({
|
||||
get: jest.fn().mockReturnValue({ useLegacyApi: true }),
|
||||
} as unknown as ReturnType<typeof getChartMetadataRegistry>);
|
||||
const handleAsyncChartData = jest
|
||||
.fn()
|
||||
.mockResolvedValue([{ data: 'legacy result' }]);
|
||||
|
||||
const { getByTestId } = render(
|
||||
<StatefulChart
|
||||
formData={mockFormData}
|
||||
chartType="test_chart"
|
||||
hooks={{ handleAsyncChartData }}
|
||||
/>,
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(handleAsyncChartData).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
// Legacy body must be wrapped to match the V1 response signature
|
||||
expect(handleAsyncChartData).toHaveBeenCalledWith(
|
||||
{ status: 202 },
|
||||
{ result: [legacyBody] },
|
||||
true,
|
||||
expect.any(AbortSignal),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(getByTestId('super-chart')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
test('does not apply a superseded async response over a newer one', async () => {
|
||||
mockChartClient.client.post.mockResolvedValue({
|
||||
response: { status: 202 } as Response,
|
||||
@@ -1024,7 +978,7 @@ test('passes an abort signal to the async handler and aborts it on unmount', asy
|
||||
response: { status: 202 } as Response,
|
||||
json: { job_id: 'j', channel_id: 'c' },
|
||||
});
|
||||
// Typed with a rest param so mock.calls is indexable (the 4th arg is the signal)
|
||||
// Typed with a rest param so mock.calls is indexable (the 3rd arg is the signal)
|
||||
const handleAsyncChartData = jest.fn(
|
||||
(..._args: unknown[]) => new Promise<never>(() => {}), // never resolves
|
||||
);
|
||||
@@ -1040,7 +994,7 @@ test('passes an abort signal to the async handler and aborts it on unmount', asy
|
||||
await waitFor(() => {
|
||||
expect(handleAsyncChartData).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
const signal = handleAsyncChartData.mock.calls[0][3] as AbortSignal;
|
||||
const signal = handleAsyncChartData.mock.calls[0][2] as AbortSignal;
|
||||
expect(signal).toBeInstanceOf(AbortSignal);
|
||||
expect(signal.aborted).toBe(false);
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import {
|
||||
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';
|
||||
|
||||
@@ -281,9 +280,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;
|
||||
@@ -295,31 +291,20 @@ 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: controller.signal,
|
||||
...(timeout && { timeout: timeout * 1000 }),
|
||||
};
|
||||
|
||||
if (useLegacyApi) {
|
||||
requestConfig.postPayload = {
|
||||
form_data: {
|
||||
...finalFormData,
|
||||
...(force && { force: true }),
|
||||
},
|
||||
};
|
||||
} else {
|
||||
requestConfig.jsonPayload = {
|
||||
jsonPayload: {
|
||||
...queryContext,
|
||||
...(force && { force: true }),
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const clientResponse =
|
||||
await chartClientRef.current!.client.post(requestConfig);
|
||||
@@ -347,18 +332,10 @@ export default function StatefulChart(props: StatefulChartProps) {
|
||||
'the async handler or disable GLOBAL_ASYNC_QUERIES for this chart.',
|
||||
);
|
||||
}
|
||||
// The async handler (handleChartDataResponse) expects the V1 chart data
|
||||
// response signature. The legacy endpoint returns a flat body, so wrap
|
||||
// it as { result: [body] } exactly like legacyChartDataRequest does for
|
||||
// the standard chart path; the V1 body is already correctly shaped.
|
||||
const asyncPayload = useLegacyApi
|
||||
? ({ result: [clientResponse.json] } as JsonObject)
|
||||
: (clientResponse.json as JsonObject);
|
||||
responseData = ensureIsArray(
|
||||
await hooks.handleAsyncChartData(
|
||||
rawResponse,
|
||||
asyncPayload,
|
||||
useLegacyApi,
|
||||
clientResponse.json as JsonObject,
|
||||
controller.signal,
|
||||
),
|
||||
);
|
||||
@@ -374,10 +351,8 @@ export default function StatefulChart(props: StatefulChartProps) {
|
||||
: [clientResponse.json]
|
||||
) as JsonObject[];
|
||||
|
||||
// Handle the nested result structure from the new API
|
||||
responseData = (
|
||||
!useLegacyApi && rows[0]?.result ? rows[0].result : rows
|
||||
) as QueryData[];
|
||||
// Handle the nested result structure from the API
|
||||
responseData = (rows[0]?.result ? rows[0].result : rows) as QueryData[];
|
||||
}
|
||||
|
||||
// Don't pair this request's data with newer props or fire a stale onLoad
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -75,7 +75,6 @@ type Hooks = {
|
||||
handleAsyncChartData?: (
|
||||
response: Response,
|
||||
json: JsonObject,
|
||||
useLegacyApi?: boolean,
|
||||
signal?: AbortSignal,
|
||||
) => Promise<QueryData[]> | QueryData[];
|
||||
} & PlainObject;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import tinycolor from 'tinycolor2';
|
||||
import { type RGBColor } from '@superset-ui/core/components';
|
||||
|
||||
const rgbRegex = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/;
|
||||
export function getContrastingColor(color: string, thresholds = 186) {
|
||||
@@ -120,3 +121,45 @@ export function rgbToHex(red: number, green: number, blue: number) {
|
||||
|
||||
return `#${r}${g}${b}`;
|
||||
}
|
||||
|
||||
export function rgbaToHex(rgb: RGBColor): string {
|
||||
const { r, g, b, a = 1 } = rgb;
|
||||
const clampChannel = (value: number) =>
|
||||
Math.min(255, Math.max(0, Math.round(value)));
|
||||
const clampAlpha = (value: number) => Math.min(1, Math.max(0, value));
|
||||
const toHex = (value: number) => {
|
||||
const hex = value.toString(16);
|
||||
return hex.length === 1 ? `0${hex}` : hex;
|
||||
};
|
||||
const hexColor = `#${toHex(clampChannel(r))}${toHex(clampChannel(g))}${toHex(clampChannel(b))}`;
|
||||
const clampedAlpha = clampAlpha(a);
|
||||
if (clampedAlpha !== 1) {
|
||||
return `${hexColor}${toHex(Math.round(clampedAlpha * 255))}`;
|
||||
}
|
||||
return hexColor;
|
||||
}
|
||||
|
||||
export const forceHexAlpha = (color: string | RGBColor): string => {
|
||||
if (typeof color === 'object' && color !== null) {
|
||||
return rgbaToHex({ ...color, a: 0.6 });
|
||||
}
|
||||
|
||||
let hex = color.startsWith('#') ? color : `#${color}`;
|
||||
|
||||
// Expand shorthand hex (#rgb, #rgba) to full length before appending or
|
||||
// replacing the alpha channel, otherwise the result is not a valid 6- or
|
||||
// 8-digit CSS hex color.
|
||||
if (hex.length === 4 || hex.length === 5) {
|
||||
hex = `#${hex
|
||||
.slice(1)
|
||||
.split('')
|
||||
.map(char => char + char)
|
||||
.join('')}`;
|
||||
}
|
||||
|
||||
if (hex.length === 9) {
|
||||
return `${hex.slice(0, -2)}99`;
|
||||
}
|
||||
|
||||
return `${hex}99`;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* 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 { render, screen, waitFor } from '@superset-ui/core/spec';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { Table } from './index';
|
||||
|
||||
// These tests exercise VirtualTable's react-window v2 `Grid` wiring
|
||||
// (`cellComponent`/`cellProps`/`gridRef`), which previously had no direct
|
||||
// coverage - `Table.test.tsx` only exercises the non-virtualized code path.
|
||||
|
||||
interface BasicData {
|
||||
columnName: string;
|
||||
columnType: string;
|
||||
}
|
||||
|
||||
const testData: BasicData[] = [
|
||||
{ columnName: 'Number', columnType: 'Numerical' },
|
||||
{ columnName: 'String', columnType: 'Physical' },
|
||||
{ columnName: 'Date', columnType: 'Virtual' },
|
||||
];
|
||||
|
||||
const testColumns: ColumnsType<BasicData> = [
|
||||
{
|
||||
title: 'Column Name',
|
||||
dataIndex: 'columnName',
|
||||
key: 'columnName',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: 'Column Type',
|
||||
dataIndex: 'columnType',
|
||||
key: 'columnType',
|
||||
width: 150,
|
||||
},
|
||||
];
|
||||
|
||||
test('virtualized table renders headers and row content through the react-window Grid', async () => {
|
||||
render(
|
||||
<Table
|
||||
columns={testColumns}
|
||||
data={testData}
|
||||
virtualize
|
||||
height={200}
|
||||
usePagination={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
await waitFor(() =>
|
||||
testColumns.forEach(column =>
|
||||
expect(
|
||||
screen
|
||||
.getAllByText(column.title as string)
|
||||
.find(el => el.closest('th')),
|
||||
).toBeInTheDocument(),
|
||||
),
|
||||
);
|
||||
|
||||
testData.forEach(row => {
|
||||
expect(screen.getByText(row.columnName)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
test('virtualized table cells keep the DOM hooks other code (cypress, downloadAsImage) relies on', async () => {
|
||||
const { container } = render(
|
||||
<Table
|
||||
columns={testColumns}
|
||||
data={testData}
|
||||
virtualize
|
||||
height={200}
|
||||
usePagination={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector('.virtual-grid')).toBeInTheDocument();
|
||||
expect(
|
||||
container.querySelectorAll('.virtual-table-cell').length,
|
||||
).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
test('cell render functions receive their row data via cellProps rather than a stale closure', async () => {
|
||||
const columnsWithRender: ColumnsType<BasicData> = [
|
||||
{
|
||||
title: 'Column Name',
|
||||
dataIndex: 'columnName',
|
||||
key: 'columnName',
|
||||
width: 150,
|
||||
render: (value: string) => `rendered:${value}`,
|
||||
},
|
||||
];
|
||||
|
||||
render(
|
||||
<Table
|
||||
columns={columnsWithRender}
|
||||
data={testData}
|
||||
virtualize
|
||||
height={200}
|
||||
usePagination={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('rendered:Number')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -24,10 +24,14 @@ import {
|
||||
} from 'antd/es/table';
|
||||
import classNames from 'classnames';
|
||||
import { useResizeDetector } from 'react-resize-detector';
|
||||
import { useEffect, useRef, useState, useCallback, CSSProperties } from 'react';
|
||||
import { VariableSizeGrid as Grid } from 'react-window';
|
||||
import { useRef, useState, useCallback, type UIEvent } from 'react';
|
||||
import {
|
||||
Grid,
|
||||
type CellComponentProps,
|
||||
type GridImperativeAPI,
|
||||
} from 'react-window';
|
||||
import { safeHtmlSpan } from '@superset-ui/core';
|
||||
import { useTheme, styled } from '@apache-superset/core/theme';
|
||||
import { useTheme, styled, SupersetTheme } from '@apache-superset/core/theme';
|
||||
|
||||
import { TableSize, ETableAction } from './index';
|
||||
|
||||
@@ -71,6 +75,59 @@ const StyledTable = styled(AntTable)(
|
||||
const SMALL = 39;
|
||||
const MIDDLE = 47;
|
||||
|
||||
interface VirtualGridCellProps {
|
||||
mergedColumns: AntTableProps<any>['columns'];
|
||||
rawData: readonly object[];
|
||||
cellSize: number;
|
||||
allowHTML: boolean;
|
||||
theme: SupersetTheme;
|
||||
}
|
||||
|
||||
// Rendered via `cellComponent`, so it must be a stable reference (module scope)
|
||||
// rather than defined inline on every render of the enclosing table -
|
||||
// otherwise react-window would treat it as a new component type each render
|
||||
// and remount every cell. All the data it needs is threaded through
|
||||
// `cellProps` instead of being closed over.
|
||||
const VirtualGridCell = ({
|
||||
columnIndex,
|
||||
rowIndex,
|
||||
style,
|
||||
mergedColumns,
|
||||
rawData,
|
||||
cellSize,
|
||||
allowHTML,
|
||||
theme,
|
||||
}: CellComponentProps<VirtualGridCellProps>) => {
|
||||
const data: any = rawData?.[rowIndex];
|
||||
// Set default content
|
||||
let content = data?.[(mergedColumns as any)?.[columnIndex]?.dataIndex];
|
||||
// Check if the column has a render function
|
||||
const render = mergedColumns?.[columnIndex]?.render;
|
||||
if (typeof render === 'function') {
|
||||
// Use render function to generate formatted content using column's render function
|
||||
content = render(content, data, rowIndex);
|
||||
}
|
||||
|
||||
if (allowHTML && typeof content === 'string') {
|
||||
content = safeHtmlSpan(content);
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledCell
|
||||
className={classNames('virtual-table-cell', {
|
||||
'virtual-table-cell-last':
|
||||
columnIndex === (mergedColumns?.length ?? 0) - 1,
|
||||
})}
|
||||
style={style}
|
||||
title={typeof content === 'string' ? content : undefined}
|
||||
theme={theme}
|
||||
height={cellSize}
|
||||
>
|
||||
{content}
|
||||
</StyledCell>
|
||||
);
|
||||
};
|
||||
|
||||
const VirtualTable = <RecordType extends object>(
|
||||
props: VirtualTableProps<RecordType>,
|
||||
) => {
|
||||
@@ -126,19 +183,15 @@ const VirtualTable = <RecordType extends object>(
|
||||
(lastColumn.width as number) + Math.floor(tableWidth - totalWidth);
|
||||
}
|
||||
|
||||
const gridRef = useRef<any>();
|
||||
const gridRef = useRef<GridImperativeAPI>(null);
|
||||
const [connectObject] = useState<any>(() => {
|
||||
const obj = {};
|
||||
Object.defineProperty(obj, 'scrollLeft', {
|
||||
get: () => {
|
||||
if (gridRef.current) {
|
||||
return gridRef.current?.state?.scrollLeft;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
get: () => gridRef.current?.element?.scrollLeft ?? 0,
|
||||
set: (scrollLeft: number) => {
|
||||
if (gridRef.current) {
|
||||
gridRef.current.scrollTo({ scrollLeft });
|
||||
const element = gridRef.current?.element;
|
||||
if (element) {
|
||||
element.scrollLeft = scrollLeft;
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -146,14 +199,11 @@ const VirtualTable = <RecordType extends object>(
|
||||
return obj;
|
||||
});
|
||||
|
||||
const resetVirtualGrid = () => {
|
||||
gridRef.current?.resetAfterIndices({
|
||||
columnIndex: 0,
|
||||
shouldForceUpdate: true,
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => resetVirtualGrid, [tableWidth, columns, size]);
|
||||
// No manual cache-reset is needed here (react-window v2 has no
|
||||
// `resetAfterIndices`-style API): `columnWidth` below is a fresh inline
|
||||
// closure over `mergedColumns` on every render, so react-window's internal
|
||||
// size cache - which is invalidated whenever the `columnWidth`/`rowHeight`
|
||||
// function reference changes - recomputes automatically.
|
||||
|
||||
/*
|
||||
* antd Table has a runtime error when it tries to fire the onChange event triggered from a pageChange
|
||||
@@ -166,7 +216,10 @@ const VirtualTable = <RecordType extends object>(
|
||||
* We intentionally leave horizontal scroll where it was so user can focus on
|
||||
* specific range of columns as they page through data
|
||||
*/
|
||||
gridRef.current?.scrollTo?.({ scrollTop: 0 });
|
||||
const element = gridRef.current?.element;
|
||||
if (element) {
|
||||
element.scrollTop = 0;
|
||||
}
|
||||
|
||||
onChange?.(
|
||||
{
|
||||
@@ -192,61 +245,31 @@ const VirtualTable = <RecordType extends object>(
|
||||
const cellSize = size === TableSize.Middle ? MIDDLE : SMALL;
|
||||
return (
|
||||
<Grid
|
||||
ref={gridRef}
|
||||
gridRef={gridRef}
|
||||
className="virtual-grid"
|
||||
columnCount={mergedColumns.length}
|
||||
columnWidth={(index: number) => {
|
||||
const { width = DEFAULT_COL_WIDTH } = mergedColumns[index];
|
||||
return width as number;
|
||||
}}
|
||||
height={height || (scroll!.y as number)}
|
||||
rowCount={rawData.length}
|
||||
rowHeight={() => cellSize}
|
||||
width={tableWidth}
|
||||
onScroll={({ scrollLeft }: { scrollLeft: number }) => {
|
||||
onScroll({ scrollLeft });
|
||||
style={{
|
||||
height: height || (scroll!.y as number),
|
||||
width: tableWidth,
|
||||
}}
|
||||
>
|
||||
{({
|
||||
columnIndex,
|
||||
rowIndex,
|
||||
style,
|
||||
}: {
|
||||
columnIndex: number;
|
||||
rowIndex: number;
|
||||
style: CSSProperties;
|
||||
}) => {
|
||||
const data: any = rawData?.[rowIndex];
|
||||
// Set default content
|
||||
let content =
|
||||
data?.[(mergedColumns as any)?.[columnIndex]?.dataIndex];
|
||||
// Check if the column has a render function
|
||||
const render = mergedColumns[columnIndex]?.render;
|
||||
if (typeof render === 'function') {
|
||||
// Use render function to generate formatted content using column's render function
|
||||
content = render(content, data, rowIndex);
|
||||
}
|
||||
|
||||
if (allowHTML && typeof content === 'string') {
|
||||
content = safeHtmlSpan(content);
|
||||
}
|
||||
|
||||
return (
|
||||
<StyledCell
|
||||
className={classNames('virtual-table-cell', {
|
||||
'virtual-table-cell-last':
|
||||
columnIndex === mergedColumns.length - 1,
|
||||
})}
|
||||
style={style}
|
||||
title={typeof content === 'string' ? content : undefined}
|
||||
theme={theme}
|
||||
height={cellSize}
|
||||
>
|
||||
{content}
|
||||
</StyledCell>
|
||||
);
|
||||
cellComponent={VirtualGridCell}
|
||||
cellProps={{
|
||||
mergedColumns,
|
||||
rawData,
|
||||
cellSize,
|
||||
allowHTML,
|
||||
theme,
|
||||
}}
|
||||
</Grid>
|
||||
onScroll={(event: UIEvent<HTMLDivElement>) => {
|
||||
onScroll({ scrollLeft: event.currentTarget.scrollLeft });
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
DEFAULT_DECK_MULTI_MAX_SLICES,
|
||||
getBootstrapDataFromDocument,
|
||||
getDeckMultiMaxSlices,
|
||||
getDefaultMapRenderer,
|
||||
getMapProviderMapStyle,
|
||||
getMapboxApiKeyFromBootstrap,
|
||||
@@ -58,6 +60,16 @@ test('Mapbox key helpers report absence and presence from bootstrap data', () =>
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test('deck.gl multi-slice cap falls back to the default when unset', () => {
|
||||
expect(getDeckMultiMaxSlices({ common: { conf: {} } })).toBe(
|
||||
DEFAULT_DECK_MULTI_MAX_SLICES,
|
||||
);
|
||||
expect(getDeckMultiMaxSlices(undefined)).toBe(DEFAULT_DECK_MULTI_MAX_SLICES);
|
||||
expect(
|
||||
getDeckMultiMaxSlices({ common: { conf: { DECK_MULTI_MAX_SLICES: 5 } } }),
|
||||
).toBe(5);
|
||||
});
|
||||
|
||||
test('bootstrap data helper parses document data safely', () => {
|
||||
document.body.innerHTML = `<div id="app" data-bootstrap='${JSON.stringify({
|
||||
common: { conf: { MAPBOX_API_KEY: 'pk.document' } },
|
||||
|
||||
@@ -83,10 +83,13 @@ type BootstrapData = {
|
||||
conf?: {
|
||||
DEFAULT_MAP_RENDERER?: unknown;
|
||||
MAPBOX_API_KEY?: unknown;
|
||||
DECK_MULTI_MAX_SLICES?: unknown;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const DEFAULT_DECK_MULTI_MAX_SLICES = 50;
|
||||
|
||||
export function getBootstrapDataFromDocument(): unknown {
|
||||
/* istanbul ignore if -- a missing document only occurs in SSR/worker
|
||||
contexts, which Jest cannot simulate: jsdom pins `document` as a
|
||||
@@ -118,6 +121,16 @@ export function hasMapboxApiKey(
|
||||
return getMapboxApiKeyFromBootstrap(bootstrapData).trim().length > 0;
|
||||
}
|
||||
|
||||
export function getDeckMultiMaxSlices(
|
||||
bootstrapData: unknown = getBootstrapDataFromDocument(),
|
||||
): number {
|
||||
const maxSlices = (bootstrapData as BootstrapData | undefined)?.common?.conf
|
||||
?.DECK_MULTI_MAX_SLICES;
|
||||
return typeof maxSlices === 'number' && Number.isFinite(maxSlices)
|
||||
? maxSlices
|
||||
: DEFAULT_DECK_MULTI_MAX_SLICES;
|
||||
}
|
||||
|
||||
export function getDefaultMapRenderer(
|
||||
bootstrapData: unknown = getBootstrapDataFromDocument(),
|
||||
): MapProvider {
|
||||
|
||||
@@ -122,7 +122,7 @@ describe('ChartClient', () => {
|
||||
});
|
||||
|
||||
describe('.loadQueryData(formData, options)', () => {
|
||||
test('returns a promise of query data for known chart type', () => {
|
||||
test('returns a promise of query data for known chart type', async () => {
|
||||
getChartMetadataRegistry().registerValue(
|
||||
VizType.WordCloud,
|
||||
new ChartMetadata({ name: 'Word Cloud', thumbnail: '' }),
|
||||
@@ -132,14 +132,18 @@ describe('ChartClient', () => {
|
||||
VizType.WordCloud,
|
||||
(formData: QueryFormData) => buildQueryContext(formData),
|
||||
);
|
||||
fetchMock.post('glob:*/api/v1/chart/data', [
|
||||
{
|
||||
field1: 'abc',
|
||||
field2: 'def',
|
||||
},
|
||||
]);
|
||||
// The real /api/v1/chart/data endpoint wraps its results in
|
||||
// `{ result: [...] }`, not a bare array.
|
||||
fetchMock.post('glob:*/api/v1/chart/data', {
|
||||
result: [
|
||||
{
|
||||
field1: 'abc',
|
||||
field2: 'def',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return expect(
|
||||
await expect(
|
||||
chartClient.loadQueryData({
|
||||
granularity: 'minute',
|
||||
viz_type: VizType.WordCloud,
|
||||
@@ -151,6 +155,16 @@ describe('ChartClient', () => {
|
||||
field2: 'def',
|
||||
},
|
||||
]);
|
||||
|
||||
// The query context fields must be posted at the top level of the
|
||||
// request body -- the endpoint's schema does not expect them nested
|
||||
// under a `query_context` key.
|
||||
const calls = fetchMock.callHistory.calls('glob:*/api/v1/chart/data');
|
||||
const requestBody = JSON.parse(
|
||||
(calls[0].options as RequestInit).body as string,
|
||||
);
|
||||
expect(requestBody.query_context).toBeUndefined();
|
||||
expect(requestBody.datasource).toEqual({ id: 1, type: 'table' });
|
||||
});
|
||||
test('returns a promise that rejects for unknown chart type', () =>
|
||||
expect(
|
||||
@@ -160,42 +174,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)', () => {
|
||||
|
||||
@@ -22,6 +22,8 @@ import {
|
||||
addAlpha,
|
||||
hexToRgb,
|
||||
rgbToHex,
|
||||
rgbaToHex,
|
||||
forceHexAlpha,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
describe('color utils', () => {
|
||||
@@ -106,4 +108,51 @@ describe('color utils', () => {
|
||||
expect(rgbToHex(0, 0, 0)).toBe('#000000');
|
||||
});
|
||||
});
|
||||
describe('rgbaToHex', () => {
|
||||
test('omits the alpha channel for opaque colors', () => {
|
||||
expect(rgbaToHex({ r: 255, g: 0, b: 0 })).toBe('#ff0000');
|
||||
expect(rgbaToHex({ r: 255, g: 0, b: 0, a: 1 })).toBe('#ff0000');
|
||||
});
|
||||
test('appends the alpha channel for translucent colors', () => {
|
||||
expect(rgbaToHex({ r: 0, g: 150, b: 0, a: 0.2 })).toBe('#00960033');
|
||||
expect(rgbaToHex({ r: 0, g: 0, b: 0, a: 0.5 })).toBe('#00000080');
|
||||
});
|
||||
test('fully transparent colors keep an explicit 00 alpha', () => {
|
||||
expect(rgbaToHex({ r: 255, g: 255, b: 255, a: 0 })).toBe('#ffffff00');
|
||||
});
|
||||
test('zero-pads single-digit channels', () => {
|
||||
expect(rgbaToHex({ r: 1, g: 2, b: 3 })).toBe('#010203');
|
||||
});
|
||||
test('rounds fractional channel values', () => {
|
||||
expect(rgbaToHex({ r: 254.6, g: 0.4, b: 0 })).toBe('#ff0000');
|
||||
});
|
||||
test('clamps out-of-range channel and alpha values', () => {
|
||||
expect(rgbaToHex({ r: 300, g: -10, b: 0 })).toBe('#ff0000');
|
||||
expect(rgbaToHex({ r: 0, g: 0, b: 0, a: 1.5 })).toBe('#000000');
|
||||
expect(rgbaToHex({ r: 0, g: 0, b: 0, a: -0.5 })).toBe('#00000000');
|
||||
});
|
||||
});
|
||||
describe('forceHexAlpha', () => {
|
||||
test('appends 60% alpha to a 6-digit hex string', () => {
|
||||
expect(forceHexAlpha('#ff0000')).toBe('#ff000099');
|
||||
});
|
||||
test('adds the # prefix when missing', () => {
|
||||
expect(forceHexAlpha('ff0000')).toBe('#ff000099');
|
||||
});
|
||||
test('replaces the existing alpha on an 8-digit hex string', () => {
|
||||
expect(forceHexAlpha('#ff000033')).toBe('#ff000099');
|
||||
});
|
||||
test('converts an RGBColor object using 60% alpha', () => {
|
||||
expect(forceHexAlpha({ r: 255, g: 0, b: 0 })).toBe('#ff000099');
|
||||
});
|
||||
test('overrides the alpha of a translucent RGBColor object', () => {
|
||||
expect(forceHexAlpha({ r: 0, g: 150, b: 0, a: 0.2 })).toBe('#00960099');
|
||||
});
|
||||
test('expands a shorthand 3-digit hex string before adding alpha', () => {
|
||||
expect(forceHexAlpha('#fff')).toBe('#ffffff99');
|
||||
});
|
||||
test('expands a shorthand 4-digit hex string before replacing alpha', () => {
|
||||
expect(forceHexAlpha('#ff03')).toBe('#ffff0099');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* 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 { Locator, Page } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Unconditional pause between drag events, letting react-dnd's HTML5 backend
|
||||
* commit its monitor state before the next event fires. Deliberately not in
|
||||
* `TIMEOUT`: that object holds wait *ceilings* (a wait may finish sooner),
|
||||
* whereas this is a fixed sleep that always costs what it says.
|
||||
*/
|
||||
const REACT_DND_SETTLE_MS = 50;
|
||||
|
||||
/**
|
||||
* Drives an HTML5 drag-and-drop using synthetic native drag events.
|
||||
*
|
||||
* The dashboard grid uses react-dnd with the HTML5 backend
|
||||
* (`react-dnd-html5-backend`), which listens for native `dragstart` /
|
||||
* `dragenter` / `dragover` / `drop` events rather than the mouse events that
|
||||
* Playwright's built-in `locator.dragTo()` produces. To trigger it we dispatch
|
||||
* the native drag sequence ourselves, threading a single shared `DataTransfer`
|
||||
* object through every event so react-dnd's monitor sees a consistent payload.
|
||||
*
|
||||
* Mirrors the synthetic-event sequence used by the deprecated Cypress `drag`
|
||||
* helper (cypress-base/cypress/utils/index.ts).
|
||||
*
|
||||
* @param page - Playwright page (used to mint the shared DataTransfer)
|
||||
* @param source - The draggable element (or a descendant; drag events bubble)
|
||||
* @param target - The drop target element
|
||||
*/
|
||||
export async function html5DragAndDrop(
|
||||
page: Page,
|
||||
source: Locator,
|
||||
target: Locator,
|
||||
): Promise<void> {
|
||||
// Note: we intentionally do not scrollIntoView the source. The chart card list
|
||||
// is virtualized, so a separate scroll action can detach the element between
|
||||
// resolution and use; dispatchEvent only requires the node to be attached.
|
||||
|
||||
// A single DataTransfer shared across every event in the sequence: react-dnd's
|
||||
// HTML5 backend reads/writes drag state through it, so reusing one handle is
|
||||
// what makes the monitor treat this as one coherent drag.
|
||||
const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
|
||||
|
||||
await source.dispatchEvent('dragstart', { dataTransfer });
|
||||
// react-dnd's HTML5 backend commits monitor state (the active drag source) on a
|
||||
// microtask after dragstart; a short settle avoids a race where dragover/drop
|
||||
// fire before the backend considers a drag to be in progress.
|
||||
await page.waitForTimeout(REACT_DND_SETTLE_MS);
|
||||
// dragenter must precede dragover for react-dnd to register the hover target.
|
||||
await target.dispatchEvent('dragenter', { dataTransfer });
|
||||
await target.dispatchEvent('dragover', { dataTransfer });
|
||||
await page.waitForTimeout(REACT_DND_SETTLE_MS);
|
||||
await target.dispatchEvent('drop', { dataTransfer });
|
||||
await source.dispatchEvent('dragend', { dataTransfer });
|
||||
|
||||
await dataTransfer.dispose();
|
||||
}
|
||||
@@ -17,12 +17,29 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { Page, Download, Locator } from '@playwright/test';
|
||||
import { Menu } from '../components/core';
|
||||
import { Page, Download, Locator, expect } from '@playwright/test';
|
||||
import { Button, Input, Menu, Tabs } from '../components/core';
|
||||
import { DashboardFilterBar } from '../components/dashboard';
|
||||
import { gotoWithRetry } from '../helpers/navigation';
|
||||
import { html5DragAndDrop } from '../helpers/dnd';
|
||||
import { TIMEOUT } from '../utils/constants';
|
||||
|
||||
/** Tabs of the dashboard builder side pane, by their rendered label. */
|
||||
type BuilderTab = 'Charts' | 'Layout elements';
|
||||
|
||||
/**
|
||||
* Built-in draggable layout elements, by their rendered label (see
|
||||
* `src/dashboard/components/gridComponents/new/`). Extension-provided elements
|
||||
* carry dynamic names and are not covered here.
|
||||
*/
|
||||
type LayoutElementLabel =
|
||||
| 'Tabs'
|
||||
| 'Row'
|
||||
| 'Column'
|
||||
| 'Header'
|
||||
| 'Text / Markdown'
|
||||
| 'Divider';
|
||||
|
||||
/**
|
||||
* Dashboard Page object for interacting with dashboards.
|
||||
*/
|
||||
@@ -32,9 +49,28 @@ export class DashboardPage {
|
||||
|
||||
private static readonly SELECTORS = {
|
||||
DASHBOARD_HEADER: '[data-test="dashboard-header-container"]',
|
||||
CHART_GRID_COMPONENT: '[data-test="chart-grid-component"]',
|
||||
// `:visible` so the locator empties out as loaders hide; see
|
||||
// waitForLoadersToSettle.
|
||||
LOADING_INDICATOR: '[aria-label="Loading"]:visible',
|
||||
DASHBOARD_MENU_TRIGGER: '[data-test="actions-trigger"]',
|
||||
// The header-actions-menu is the data-test for the dropdown menu content
|
||||
HEADER_ACTIONS_MENU: '[data-test="header-actions-menu"]',
|
||||
EDIT_BUTTON: '[data-test="edit-dashboard-button"]',
|
||||
BUILDER_PANE: '[data-test="dashboard-builder-sidepane"]',
|
||||
CHARTS_SEARCH: '[data-test="dashboard-charts-filter-search-input"]',
|
||||
CHART_CARD: '[data-test="chart-card"]',
|
||||
EMPTY_DROPTARGET: '[data-test="grid-content"] .empty-droptarget',
|
||||
NEW_COMPONENT: '[data-test="new-component"]',
|
||||
CHART_HOLDER: '[data-test="dashboard-component-chart-holder"]',
|
||||
GRID_CONTENT: '[data-test="grid-content"]',
|
||||
DELETE_COMPONENT: '[data-test="dashboard-delete-component-button"]',
|
||||
MARKDOWN_EDITOR: '[data-test="dashboard-markdown-editor"]',
|
||||
EDITABLE_TITLE: '[data-test="editable-title-input"]',
|
||||
// Ace exposes no data-test hooks; these are its own stable DOM classes.
|
||||
ACE_CONTENT: '.ace_content',
|
||||
ACE_TEXT_INPUT: '.ace_text-input',
|
||||
RESIZE_HANDLE_BOTTOM: '.resizable-container-handle--bottom',
|
||||
} as const;
|
||||
|
||||
constructor(page: Page) {
|
||||
@@ -60,12 +96,16 @@ export class DashboardPage {
|
||||
|
||||
/**
|
||||
* Wait for the dashboard header to be visible.
|
||||
*
|
||||
* The header container renders well before the grid does, so this only
|
||||
* establishes that the dashboard route mounted — pair it with
|
||||
* {@link waitForChartsToLoad} before asserting on chart content.
|
||||
*/
|
||||
async waitForLoad(options?: { timeout?: number }): Promise<void> {
|
||||
const timeout = options?.timeout ?? TIMEOUT.PAGE_LOAD;
|
||||
await this.page.waitForSelector(DashboardPage.SELECTORS.DASHBOARD_HEADER, {
|
||||
timeout,
|
||||
});
|
||||
await this.page
|
||||
.locator(DashboardPage.SELECTORS.DASHBOARD_HEADER)
|
||||
.waitFor({ state: 'visible', timeout });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,37 +113,80 @@ export class DashboardPage {
|
||||
*/
|
||||
getChart(chartId: number): Locator {
|
||||
return this.page.locator(
|
||||
`[data-test="chart-grid-component"][data-test-chart-id="${chartId}"]`,
|
||||
`${DashboardPage.SELECTORS.CHART_GRID_COMPONENT}[data-test-chart-id="${chartId}"]`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for all charts on the dashboard to finish loading.
|
||||
* Waits until no loading indicators are visible on the page.
|
||||
* Wait for the dashboard's charts to mount and finish loading.
|
||||
*
|
||||
* Waiting only for loading indicators to clear is not enough: the grid mounts
|
||||
* its spinners after the header renders, so a "no visible loader" check
|
||||
* called straight after {@link waitForLoad} passes instantly against a
|
||||
* dashboard that has not started rendering anything. Waiting for at least one
|
||||
* chart grid component first makes the absence of loaders mean "charts
|
||||
* finished" rather than "charts have not begun".
|
||||
*
|
||||
* Only for dashboards that have charts — on an empty one this waits out
|
||||
* `timeout` rather than returning. Use {@link waitForGridToLoad} there.
|
||||
*/
|
||||
async waitForChartsToLoad(options?: { timeout?: number }): Promise<void> {
|
||||
const timeout = options?.timeout ?? TIMEOUT.API_RESPONSE;
|
||||
|
||||
// Use browser-context evaluation to check visibility directly.
|
||||
// Loading indicators ([aria-label="Loading"]) may persist in the DOM as hidden
|
||||
// elements after charts finish loading. This checks that none are currently visible,
|
||||
// returning immediately when charts are already loaded (no timeout penalty).
|
||||
await this.page.waitForFunction(
|
||||
() => {
|
||||
const loaders = document.querySelectorAll('[aria-label="Loading"]');
|
||||
if (loaders.length === 0) return true;
|
||||
return Array.from(loaders).every(el => {
|
||||
const style = getComputedStyle(el);
|
||||
return (
|
||||
style.display === 'none' ||
|
||||
style.visibility === 'hidden' ||
|
||||
style.opacity === '0'
|
||||
);
|
||||
});
|
||||
},
|
||||
undefined,
|
||||
{ timeout },
|
||||
);
|
||||
await this.page
|
||||
.locator(DashboardPage.SELECTORS.CHART_GRID_COMPONENT)
|
||||
.first()
|
||||
.waitFor({ state: 'attached', timeout });
|
||||
|
||||
await this.waitForLoadersToSettle(timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the dashboard grid to mount and any loading indicators to clear.
|
||||
*
|
||||
* The counterpart to {@link waitForChartsToLoad} for a dashboard with no
|
||||
* charts on it: the grid container renders whatever the grid holds, so it
|
||||
* gives the "the page got past the header" evidence that a chart component
|
||||
* cannot. Prefer {@link waitForChartsToLoad} whenever charts are expected —
|
||||
* this cannot tell a grid that rendered empty from one whose charts have not
|
||||
* begun rendering.
|
||||
*/
|
||||
async waitForGridToLoad(options?: { timeout?: number }): Promise<void> {
|
||||
const timeout = options?.timeout ?? TIMEOUT.API_RESPONSE;
|
||||
|
||||
// Attached rather than visible: an empty grid collapses to zero height,
|
||||
// which Playwright counts as not visible.
|
||||
await this.page
|
||||
.locator(DashboardPage.SELECTORS.GRID_CONTENT)
|
||||
.first()
|
||||
.waitFor({ state: 'attached', timeout });
|
||||
|
||||
await this.waitForLoadersToSettle(timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve once no loading indicator is visible.
|
||||
*
|
||||
* Loading indicators persist in the DOM as hidden elements after charts
|
||||
* finish, so this waits for none to be *visible* rather than for none to
|
||||
* exist. The `:visible` engine resolves to zero elements when they are all
|
||||
* hidden, which is what `detached` then matches — and it returns immediately
|
||||
* when they are already settled, with no timeout penalty.
|
||||
*
|
||||
* Deliberately not a `getComputedStyle` check in an evaluated function:
|
||||
* `display` does not inherit, so a loader inside a `display: none` ancestor
|
||||
* computes to its own `display: block` and reads as visible, hanging the wait
|
||||
* until the timeout. Playwright's visibility check accounts for ancestors.
|
||||
*
|
||||
* Loader absence is also the state of a dashboard that has not started
|
||||
* rendering, which is why every caller pairs this with a wait for the content
|
||||
* it expects.
|
||||
*/
|
||||
private async waitForLoadersToSettle(timeout: number): Promise<void> {
|
||||
await this.page
|
||||
.locator(DashboardPage.SELECTORS.LOADING_INDICATOR)
|
||||
.first()
|
||||
.waitFor({ state: 'detached', timeout });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,14 +219,13 @@ export class DashboardPage {
|
||||
* Open the dashboard header actions menu (three-dot menu)
|
||||
*/
|
||||
async openHeaderActionsMenu(): Promise<void> {
|
||||
await this.page.click(DashboardPage.SELECTORS.DASHBOARD_MENU_TRIGGER);
|
||||
await this.page
|
||||
.locator(DashboardPage.SELECTORS.DASHBOARD_MENU_TRIGGER)
|
||||
.click();
|
||||
// Wait for the dropdown menu to appear
|
||||
await this.page.waitForSelector(
|
||||
DashboardPage.SELECTORS.HEADER_ACTIONS_MENU,
|
||||
{
|
||||
state: 'visible',
|
||||
},
|
||||
);
|
||||
await this.page
|
||||
.locator(DashboardPage.SELECTORS.HEADER_ACTIONS_MENU)
|
||||
.waitFor({ state: 'visible' });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,4 +260,198 @@ export class DashboardPage {
|
||||
await menu.selectSubmenuItem('Download', optionText);
|
||||
return downloadPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter dashboard edit mode and wait for the builder side pane to appear.
|
||||
*/
|
||||
async enterEditMode(): Promise<void> {
|
||||
const editButton = new Button(
|
||||
this.page,
|
||||
DashboardPage.SELECTORS.EDIT_BUTTON,
|
||||
);
|
||||
await editButton.click();
|
||||
await this.page
|
||||
.locator(DashboardPage.SELECTORS.BUILDER_PANE)
|
||||
.waitFor({ state: 'visible' });
|
||||
}
|
||||
|
||||
/**
|
||||
* The builder side pane's tab bar (Charts / Layout elements).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Switch the builder side pane to one of its tabs.
|
||||
* @param tab - 'Charts' (existing slices) or 'Layout elements' (new components)
|
||||
*/
|
||||
private async openBuilderTab(tab: BuilderTab): Promise<void> {
|
||||
// Scoped to `.ant-tabs` because that is the root the shared Tabs component
|
||||
// expects.
|
||||
const builderTabs = new Tabs(
|
||||
this.page,
|
||||
this.page
|
||||
.locator(`${DashboardPage.SELECTORS.BUILDER_PANE} .ant-tabs`)
|
||||
.first(),
|
||||
);
|
||||
await builderTabs.clickTab(tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locator for chart-holder components currently placed on the grid.
|
||||
* Markdown components are chart holders too — use
|
||||
* {@link getMarkdownEditors} when the assertion must exclude them.
|
||||
*/
|
||||
getChartHolders(): Locator {
|
||||
return this.page.locator(DashboardPage.SELECTORS.CHART_HOLDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag an existing chart from the Charts pane onto the dashboard grid.
|
||||
* Requires edit mode to be active.
|
||||
* @param sliceName - The slice name to search for and drag
|
||||
*/
|
||||
async addChartByName(sliceName: string): Promise<void> {
|
||||
await this.openBuilderTab('Charts');
|
||||
const search = new Input(this.page, DashboardPage.SELECTORS.CHARTS_SEARCH);
|
||||
await search.fill(sliceName);
|
||||
const card = this.page
|
||||
.locator(DashboardPage.SELECTORS.CHART_CARD)
|
||||
.filter({ hasText: sliceName })
|
||||
.first();
|
||||
await card.waitFor({ state: 'visible' });
|
||||
await html5DragAndDrop(this.page, card, this.dropTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag a new Layout element (by its label) onto the dashboard grid.
|
||||
* Requires edit mode to be active.
|
||||
* @param label - The new-component label, e.g. 'Text / Markdown'
|
||||
*/
|
||||
async addLayoutElement(label: LayoutElementLabel): Promise<void> {
|
||||
await this.openBuilderTab('Layout elements');
|
||||
const source = this.page
|
||||
.locator(DashboardPage.SELECTORS.NEW_COMPONENT)
|
||||
.filter({ hasText: label })
|
||||
.first();
|
||||
await source.waitFor({ state: 'visible' });
|
||||
await html5DragAndDrop(this.page, source, this.dropTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* The grid's empty drop target, which the grid renders while in edit mode.
|
||||
*
|
||||
* Only resolves while the grid is still empty. Dropping a second component
|
||||
* needs a target relative to the already-placed one, not this.
|
||||
*/
|
||||
private dropTarget(): Locator {
|
||||
return this.page.locator(DashboardPage.SELECTORS.EMPTY_DROPTARGET).first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hover the first placed chart-holder and click its delete button (edit mode).
|
||||
*/
|
||||
async deleteChartHolder(): Promise<void> {
|
||||
const holder = this.getChartHolders().first();
|
||||
await holder.hover();
|
||||
const deleteButton = new Button(
|
||||
this.page,
|
||||
holder.locator(DashboardPage.SELECTORS.DELETE_COMPONENT),
|
||||
);
|
||||
await deleteButton.click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Locator for markdown editor components on the grid.
|
||||
*/
|
||||
getMarkdownEditors(): Locator {
|
||||
return this.page.locator(DashboardPage.SELECTORS.MARKDOWN_EDITOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* The rendered ace document inside a markdown component. Present only once
|
||||
* the component has entered its editing state.
|
||||
*
|
||||
* Exposed as a locator rather than routed through the `AceEditor` component:
|
||||
* that component reads and writes through `ace.edit(...)` in page context,
|
||||
* which both bypasses the real keystroke path under test and gives up
|
||||
* web-first retries on assertions.
|
||||
*
|
||||
* @param markdownEditor - A locator from {@link getMarkdownEditors}
|
||||
*/
|
||||
getMarkdownAceContent(markdownEditor: Locator): Locator {
|
||||
return markdownEditor.locator(DashboardPage.SELECTORS.ACE_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ace's hidden textarea inside a markdown component — the element that
|
||||
* receives keystrokes.
|
||||
*
|
||||
* @param markdownEditor - A locator from {@link getMarkdownEditors}
|
||||
*/
|
||||
getMarkdownAceInput(markdownEditor: Locator): Locator {
|
||||
return markdownEditor.locator(DashboardPage.SELECTORS.ACE_TEXT_INPUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click the dashboard title, moving focus off whichever grid component holds
|
||||
* it. Committing a markdown edit needs a click on some other element, and the
|
||||
* title is the one that is always present regardless of what is on the grid.
|
||||
*
|
||||
* In edit mode the click focuses the title's input. That is a state change,
|
||||
* not a no-op — but it edits nothing on its own, so it leaves the component
|
||||
* under test untouched.
|
||||
*/
|
||||
async blurToDashboardTitle(): Promise<void> {
|
||||
await this.page
|
||||
.locator(DashboardPage.SELECTORS.EDITABLE_TITLE)
|
||||
.first()
|
||||
.click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag a grid component's bottom resize handle down by `deltaY` pixels.
|
||||
* Requires edit mode. Uses the mouse because the resize handle is driven by
|
||||
* `react-resizable`, which tracks real pointer movement.
|
||||
*
|
||||
* @param component - The grid component to resize
|
||||
* @param deltaY - Pixels to drag downwards (positive grows the component)
|
||||
* @returns The component's height before and after the drag
|
||||
*/
|
||||
async resizeComponent(
|
||||
component: Locator,
|
||||
deltaY: number,
|
||||
): Promise<{ heightBefore: number; heightAfter: number }> {
|
||||
const boxBefore = await component.boundingBox();
|
||||
if (!boxBefore) {
|
||||
throw new Error('Cannot resize a component that is not visible');
|
||||
}
|
||||
|
||||
const handle = component
|
||||
.locator(DashboardPage.SELECTORS.RESIZE_HANDLE_BOTTOM)
|
||||
.last();
|
||||
const handleBox = await handle.boundingBox();
|
||||
if (!handleBox) {
|
||||
throw new Error('Resize handle is not visible');
|
||||
}
|
||||
|
||||
const startX = handleBox.x + handleBox.width / 2;
|
||||
const startY = handleBox.y + handleBox.height / 2;
|
||||
await this.page.mouse.move(startX, startY);
|
||||
await this.page.mouse.down();
|
||||
// Multiple steps so react-resizable sees a drag rather than a teleport.
|
||||
await this.page.mouse.move(startX, startY + deltaY, { steps: 10 });
|
||||
await this.page.mouse.up();
|
||||
|
||||
await expect
|
||||
.poll(async () => (await component.boundingBox())?.height, {
|
||||
message: 'Component height did not change after resize',
|
||||
})
|
||||
.not.toBe(boxBefore.height);
|
||||
|
||||
const boxAfter = await component.boundingBox();
|
||||
if (!boxAfter) {
|
||||
throw new Error('Component disappeared during resize');
|
||||
}
|
||||
|
||||
return { heightBefore: boxBefore.height, heightAfter: boxAfter.height };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,13 @@ import {
|
||||
buildSingleRowDashboardLayout,
|
||||
} from '../../helpers/api/dashboard';
|
||||
import { getDatasetByName } from '../../helpers/api/dataset';
|
||||
import { extractIdFromResponse } from '../../helpers/api/assertions';
|
||||
import { DashboardPage } from '../../pages/DashboardPage';
|
||||
import { TIMEOUT } from '../../utils/constants';
|
||||
import {
|
||||
buildFilterJsonMetadata,
|
||||
buildSelectFilter,
|
||||
} from './dashboard-test-helpers';
|
||||
|
||||
const DATASET_NAME = 'birth_names';
|
||||
const FILTER_COLUMN = 'gender';
|
||||
@@ -59,12 +64,10 @@ testWithAssets(
|
||||
params: JSON.stringify(chartParams),
|
||||
});
|
||||
expect(chartResp.ok()).toBe(true);
|
||||
const chart = await chartResp.json();
|
||||
const chartId: number = chart.id ?? chart.result?.id;
|
||||
const chartId = await extractIdFromResponse(chartResp);
|
||||
testAssets.trackChart(chartId);
|
||||
|
||||
// Create dashboard with chart in position_json and a native filter in json_metadata
|
||||
const filterId = `NATIVE_FILTER-${Math.random().toString(36).slice(2, 10)}`;
|
||||
const positionJson = buildSingleRowDashboardLayout([
|
||||
{
|
||||
id: chartId,
|
||||
@@ -74,39 +77,17 @@ testWithAssets(
|
||||
},
|
||||
]);
|
||||
|
||||
const jsonMetadata = {
|
||||
native_filter_configuration: [
|
||||
{
|
||||
id: filterId,
|
||||
name: 'Gender',
|
||||
filterType: 'filter_select',
|
||||
type: 'NATIVE_FILTER',
|
||||
targets: [
|
||||
{
|
||||
datasetId,
|
||||
column: { name: FILTER_COLUMN },
|
||||
},
|
||||
],
|
||||
controlValues: {
|
||||
multiSelect: false,
|
||||
enableEmptyFilter: false,
|
||||
defaultToFirstItem: false,
|
||||
inverseSelection: false,
|
||||
searchAllOptions: false,
|
||||
},
|
||||
defaultDataMask: { filterState: {}, extraFormData: {} },
|
||||
cascadeParentIds: [],
|
||||
scope: { rootPath: ['ROOT_ID'], excluded: [] },
|
||||
const jsonMetadata = buildFilterJsonMetadata({
|
||||
chartsInScope: [chartId],
|
||||
nativeFilters: [
|
||||
buildSelectFilter({
|
||||
datasetId,
|
||||
column: FILTER_COLUMN,
|
||||
chartsInScope: [chartId],
|
||||
},
|
||||
name: 'Gender',
|
||||
}),
|
||||
],
|
||||
chart_configuration: {},
|
||||
cross_filters_enabled: false,
|
||||
global_chart_configuration: {
|
||||
scope: { rootPath: ['ROOT_ID'], excluded: [] },
|
||||
chartsInScope: [chartId],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const dashResp = await apiPostDashboard(page, {
|
||||
dashboard_title: `clear_all_repro_${Date.now()}`,
|
||||
@@ -115,8 +96,7 @@ testWithAssets(
|
||||
json_metadata: JSON.stringify(jsonMetadata),
|
||||
});
|
||||
expect(dashResp.ok()).toBe(true);
|
||||
const dashBody = await dashResp.json();
|
||||
const dashboardId: number = dashBody.result?.id ?? dashBody.id;
|
||||
const dashboardId = await extractIdFromResponse(dashResp);
|
||||
testAssets.trackDashboard(dashboardId);
|
||||
|
||||
// Associate chart with the dashboard so it actually renders
|
||||
|
||||
@@ -62,6 +62,8 @@ interface TestDashboardResult {
|
||||
interface CreateTestDashboardOptions {
|
||||
/** Prefix for generated name (default: 'test_dashboard') */
|
||||
prefix?: string;
|
||||
/** Publish the dashboard on creation (default: false, the API default) */
|
||||
published?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,6 +88,8 @@ export async function createTestDashboard(
|
||||
|
||||
const response = await apiPostDashboard(page, {
|
||||
dashboard_title: name,
|
||||
// Serialized as JSON, which drops undefined — no need to omit the key.
|
||||
published: options?.published,
|
||||
});
|
||||
|
||||
if (!response.ok()) {
|
||||
@@ -106,6 +110,113 @@ export async function createTestDashboard(
|
||||
return { id, name };
|
||||
}
|
||||
|
||||
/** Scope covering the whole dashboard — every filter built here is unscoped. */
|
||||
const ROOT_SCOPE = { rootPath: ['ROOT_ID'], excluded: [] };
|
||||
|
||||
interface DataMask {
|
||||
filterState: Record<string, unknown>;
|
||||
extraFormData: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface NativeFilterConfig {
|
||||
id: string;
|
||||
name: string;
|
||||
filterType: string;
|
||||
type: string;
|
||||
targets: Array<{ datasetId: number; column: { name: string } }>;
|
||||
controlValues: Record<string, boolean>;
|
||||
defaultDataMask: DataMask;
|
||||
cascadeParentIds: string[];
|
||||
scope: typeof ROOT_SCOPE;
|
||||
chartsInScope: number[];
|
||||
}
|
||||
|
||||
interface SelectFilterOptions {
|
||||
/** Dataset backing the filtered column. */
|
||||
datasetId: number;
|
||||
/** Column the filter targets. */
|
||||
column: string;
|
||||
/** Charts the filter applies to. */
|
||||
chartsInScope: number[];
|
||||
/** Label shown in the filter bar (default: the column name). */
|
||||
name?: string;
|
||||
/**
|
||||
* Value preselected when the dashboard loads. Omit for a filter that starts
|
||||
* unset — the distinction is load-bearing: a preselected filter is applied to
|
||||
* the initial chart-data request, an unset one is not.
|
||||
*/
|
||||
defaultValue?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds one `filter_select` native filter for a dashboard's `json_metadata`.
|
||||
* The filter id is generated here because no test needs to know it — filters are
|
||||
* addressed through the filter bar UI, not by id.
|
||||
*/
|
||||
export function buildSelectFilter(
|
||||
options: SelectFilterOptions,
|
||||
): NativeFilterConfig {
|
||||
const { datasetId, column, chartsInScope, name, defaultValue } = options;
|
||||
return {
|
||||
id: `NATIVE_FILTER-${Math.random().toString(36).slice(2, 10)}`,
|
||||
name: name ?? column,
|
||||
filterType: 'filter_select',
|
||||
type: 'NATIVE_FILTER',
|
||||
targets: [{ datasetId, column: { name: column } }],
|
||||
controlValues: {
|
||||
multiSelect: false,
|
||||
enableEmptyFilter: false,
|
||||
defaultToFirstItem: false,
|
||||
inverseSelection: false,
|
||||
searchAllOptions: false,
|
||||
},
|
||||
defaultDataMask:
|
||||
defaultValue === undefined
|
||||
? { filterState: {}, extraFormData: {} }
|
||||
: {
|
||||
filterState: { value: [defaultValue] },
|
||||
extraFormData: {
|
||||
filters: [{ col: column, op: 'IN', val: [defaultValue] }],
|
||||
},
|
||||
},
|
||||
cascadeParentIds: [],
|
||||
scope: ROOT_SCOPE,
|
||||
chartsInScope,
|
||||
};
|
||||
}
|
||||
|
||||
interface FilterMetadataOptions {
|
||||
/** Charts the dashboard's global filter scope covers. */
|
||||
chartsInScope: number[];
|
||||
nativeFilters: NativeFilterConfig[];
|
||||
/**
|
||||
* Display Controls, serialized as-is. Kept untyped and pass-through: only one
|
||||
* spec builds them, so a second builder would be speculative.
|
||||
*/
|
||||
chartCustomizations?: Record<string, unknown>[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the `json_metadata` envelope a filtered dashboard needs. Cross-filters
|
||||
* are off so a click on one chart cannot perturb another test's assertions.
|
||||
*/
|
||||
export function buildFilterJsonMetadata(
|
||||
options: FilterMetadataOptions,
|
||||
): Record<string, unknown> {
|
||||
return {
|
||||
native_filter_configuration: options.nativeFilters,
|
||||
...(options.chartCustomizations && {
|
||||
chart_customization_config: options.chartCustomizations,
|
||||
}),
|
||||
chart_configuration: {},
|
||||
cross_filters_enabled: false,
|
||||
global_chart_configuration: {
|
||||
scope: ROOT_SCOPE,
|
||||
chartsInScope: options.chartsInScope,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export interface DashboardChartSpec {
|
||||
/** Sent as the chart's top-level `viz_type` and injected into its params. */
|
||||
viz_type: string;
|
||||
|
||||
@@ -30,7 +30,12 @@ import {
|
||||
buildSingleRowDashboardLayout,
|
||||
} from '../../helpers/api/dashboard';
|
||||
import { getDatasetByName } from '../../helpers/api/dataset';
|
||||
import { extractIdFromResponse } from '../../helpers/api/assertions';
|
||||
import { DashboardPage } from '../../pages/DashboardPage';
|
||||
import {
|
||||
buildFilterJsonMetadata,
|
||||
buildSelectFilter,
|
||||
} from './dashboard-test-helpers';
|
||||
|
||||
// Record video regardless of pass/fail (before/after clips).
|
||||
testWithAssets.use({ video: 'on' });
|
||||
@@ -72,8 +77,7 @@ testWithAssets(
|
||||
params: JSON.stringify(chartParams),
|
||||
});
|
||||
expect(chartResp.ok()).toBe(true);
|
||||
const chart = await chartResp.json();
|
||||
const chartId: number = chart.id ?? chart.result?.id;
|
||||
const chartId = await extractIdFromResponse(chartResp);
|
||||
testAssets.trackChart(chartId);
|
||||
|
||||
const positionJson = buildSingleRowDashboardLayout([
|
||||
@@ -86,33 +90,21 @@ testWithAssets(
|
||||
]);
|
||||
|
||||
// 2. json_metadata: one dashboard filter + one Display Control.
|
||||
const filterId = `NATIVE_FILTER-${Math.random().toString(36).slice(2, 10)}`;
|
||||
const customizationId = `CHART_CUSTOMIZATION-${Math.random()
|
||||
.toString(36)
|
||||
.slice(2, 10)}`;
|
||||
|
||||
const jsonMetadata = {
|
||||
native_filter_configuration: [
|
||||
{
|
||||
id: filterId,
|
||||
name: 'Gender',
|
||||
filterType: 'filter_select',
|
||||
type: 'NATIVE_FILTER',
|
||||
targets: [{ datasetId, column: { name: FILTER_COLUMN } }],
|
||||
controlValues: {
|
||||
multiSelect: false,
|
||||
enableEmptyFilter: false,
|
||||
defaultToFirstItem: false,
|
||||
inverseSelection: false,
|
||||
searchAllOptions: false,
|
||||
},
|
||||
defaultDataMask: { filterState: {}, extraFormData: {} },
|
||||
cascadeParentIds: [],
|
||||
scope: { rootPath: ['ROOT_ID'], excluded: [] },
|
||||
const jsonMetadata = buildFilterJsonMetadata({
|
||||
chartsInScope: [chartId],
|
||||
nativeFilters: [
|
||||
buildSelectFilter({
|
||||
datasetId,
|
||||
column: FILTER_COLUMN,
|
||||
chartsInScope: [chartId],
|
||||
},
|
||||
name: 'Gender',
|
||||
}),
|
||||
],
|
||||
chart_customization_config: [
|
||||
chartCustomizations: [
|
||||
{
|
||||
id: customizationId,
|
||||
type: 'CHART_CUSTOMIZATION',
|
||||
@@ -127,13 +119,7 @@ testWithAssets(
|
||||
removed: false,
|
||||
},
|
||||
],
|
||||
chart_configuration: {},
|
||||
cross_filters_enabled: false,
|
||||
global_chart_configuration: {
|
||||
scope: { rootPath: ['ROOT_ID'], excluded: [] },
|
||||
chartsInScope: [chartId],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const dashResp = await apiPostDashboard(page, {
|
||||
dashboard_title: `display_control_repro_${Date.now()}`,
|
||||
@@ -142,8 +128,7 @@ testWithAssets(
|
||||
json_metadata: JSON.stringify(jsonMetadata),
|
||||
});
|
||||
expect(dashResp.ok()).toBe(true);
|
||||
const dashBody = await dashResp.json();
|
||||
const dashboardId: number = dashBody.result?.id ?? dashBody.id;
|
||||
const dashboardId = await extractIdFromResponse(dashResp);
|
||||
testAssets.trackDashboard(dashboardId);
|
||||
|
||||
const linkResp = await apiPut(page, `api/v1/chart/${chartId}`, {
|
||||
@@ -155,14 +140,22 @@ testWithAssets(
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.gotoById(dashboardId);
|
||||
await dashboardPage.waitForLoad({ timeout: 30000 });
|
||||
await dashboardPage.waitForChartsToLoad({ timeout: 8000 }).catch(() => {});
|
||||
|
||||
/**
|
||||
* Best-effort settle after each mutation. Every assertion below targets the
|
||||
* filter bar rather than chart content, so a chart that is still querying
|
||||
* must not fail the test — but giving charts a chance to finish keeps the
|
||||
* bar from being re-rendered underneath the assertions.
|
||||
*/
|
||||
const settleCharts = () =>
|
||||
dashboardPage.waitForChartsToLoad({ timeout: 8000 }).catch(() => {});
|
||||
|
||||
await settleCharts();
|
||||
const filterBar = await dashboardPage.waitForFilterBar();
|
||||
|
||||
// Both the Gender filter and the Time grain Display Control should render.
|
||||
await expect(dashboardPage.getDisplayControlsHeader()).toBeVisible();
|
||||
await expect(dashboardPage.getDisplayControl('Time grain')).toBeVisible();
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('STEP 1: Display control "Time grain" is present in the bar.');
|
||||
await shot('01-initial-bar');
|
||||
|
||||
// 4. Open the filters config modal via the settings gear.
|
||||
@@ -172,40 +165,26 @@ testWithAssets(
|
||||
// 5. Delete the "Time grain" Display Control in the modal sidebar.
|
||||
await modal.removeDisplayControl('Time grain');
|
||||
await expect(modal.getRemovedMarker()).toBeVisible();
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('STEP 2: Display control marked (Removed) in modal.');
|
||||
await shot('03-modal-removed');
|
||||
|
||||
// 6. Save the modal.
|
||||
await modal.clickSave();
|
||||
await modal.waitForHidden({ timeout: 20000 });
|
||||
await dashboardPage.waitForChartsToLoad({ timeout: 8000 }).catch(() => {});
|
||||
await settleCharts();
|
||||
await shot('04-after-save');
|
||||
|
||||
const goneAfterSave = await dashboardPage
|
||||
.getDisplayControl('Time grain')
|
||||
.isVisible()
|
||||
.catch(() => false);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
`STEP 3: After save, "Time grain" visible in bar = ${goneAfterSave}`,
|
||||
);
|
||||
|
||||
// 7. Click Apply Filters.
|
||||
await filterBar.applyIfEnabled();
|
||||
await dashboardPage.waitForChartsToLoad({ timeout: 8000 }).catch(() => {});
|
||||
await settleCharts();
|
||||
/**
|
||||
* Hold before asserting. The bug this guards against is the control coming
|
||||
* *back*, and `toHaveCount(0)` passes the instant it is absent — so without
|
||||
* a pause the assertion can sample the gap before the re-render and pass on
|
||||
* a dashboard that is about to fail. The wait is the reappearance window.
|
||||
*/
|
||||
await page.waitForTimeout(1500);
|
||||
await shot('05-after-apply');
|
||||
|
||||
const reappeared = await dashboardPage
|
||||
.getDisplayControl('Time grain')
|
||||
.isVisible()
|
||||
.catch(() => false);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
`STEP 4: After Apply Filters, "Time grain" reappeared = ${reappeared}`,
|
||||
);
|
||||
|
||||
// The deleted Display Control must stay gone.
|
||||
await expect(
|
||||
dashboardPage.getDisplayControl('Time grain'),
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dashboard edit-mode component tests — these replace the deprecated Cypress
|
||||
* spec cypress-base/cypress/e2e/dashboard/editmode.test.ts, deleted in the same
|
||||
* change. They cover the chart/markdown drag-and-drop workflows that the
|
||||
* upstream Cypress notes flagged as the one part of edit mode that genuinely
|
||||
* requires E2E coverage ("Chart drag/drop functionality requires true E2E
|
||||
* testing"). The grid uses react-dnd with the HTML5 backend, so drags are
|
||||
* driven by synthetic native drag events (see helpers/dnd.ts).
|
||||
*
|
||||
* Coverage here is a superset of the Cypress spec, which by the time of the
|
||||
* migration held a single "should add charts" test — its "Color consistency"
|
||||
* block had already been dropped upstream as permanently skipped (it read
|
||||
* per-series colors off an `.nv-legend-symbol` SVG `fill` that ECharts, which
|
||||
* renders to <canvas>, no longer produces). That color-precedence logic is
|
||||
* covered by Jest/RTL, not by E2E.
|
||||
*/
|
||||
|
||||
import {
|
||||
testWithAssets,
|
||||
expect,
|
||||
type TestAssets,
|
||||
} from '../../helpers/fixtures';
|
||||
import { apiPostChart } from '../../helpers/api/chart';
|
||||
import { getDatasetByName } from '../../helpers/api/dataset';
|
||||
import { extractIdFromResponse } from '../../helpers/api/assertions';
|
||||
import { DashboardPage } from '../../pages/DashboardPage';
|
||||
import { createTestDashboard } from './dashboard-test-helpers';
|
||||
import type { Page, TestInfo } from '@playwright/test';
|
||||
|
||||
const DATASET_NAME = 'birth_names';
|
||||
|
||||
/**
|
||||
* How long one click on the markdown component gets to bring up the ace editor
|
||||
* before the retry loop tries again, and how long the whole loop gets. The
|
||||
* per-attempt budget is deliberately short: the failure mode is a swallowed
|
||||
* click, and retrying is cheaper than waiting out the full budget once.
|
||||
*/
|
||||
const MARKDOWN_EDIT_ATTEMPT_TIMEOUT = 2000;
|
||||
const MARKDOWN_EDIT_TOTAL_TIMEOUT = 20000;
|
||||
|
||||
/** Downward drag distance for the resize assertion — several grid rows. */
|
||||
const RESIZE_DELTA_PX = 150;
|
||||
|
||||
/** Create a hermetic chart from birth_names, NOT placed on any dashboard. */
|
||||
async function createChart(
|
||||
page: Page,
|
||||
testAssets: TestAssets,
|
||||
testInfo: TestInfo,
|
||||
): Promise<string> {
|
||||
const dataset = await getDatasetByName(page, DATASET_NAME);
|
||||
if (!dataset) {
|
||||
throw new Error(`Dataset ${DATASET_NAME} not found`);
|
||||
}
|
||||
const sliceName = `edit_mode_chart_${Date.now()}_${testInfo.parallelIndex}`;
|
||||
const resp = await apiPostChart(page, {
|
||||
slice_name: sliceName,
|
||||
viz_type: 'big_number_total',
|
||||
datasource_id: dataset.id,
|
||||
datasource_type: 'table',
|
||||
params: JSON.stringify({
|
||||
datasource: `${dataset.id}__table`,
|
||||
viz_type: 'big_number_total',
|
||||
metric: 'count',
|
||||
}),
|
||||
});
|
||||
expect(resp.ok()).toBe(true);
|
||||
testAssets.trackChart(await extractIdFromResponse(resp));
|
||||
return sliceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the empty published dashboard every test in this file starts from,
|
||||
* open it, and enter edit mode. Returns the page object positioned on the
|
||||
* builder, ready for a drag.
|
||||
*/
|
||||
async function openEmptyDashboardInEditMode(
|
||||
page: Page,
|
||||
testAssets: TestAssets,
|
||||
testInfo: TestInfo,
|
||||
): Promise<DashboardPage> {
|
||||
const { id } = await createTestDashboard(page, testAssets, testInfo, {
|
||||
prefix: 'edit_mode',
|
||||
published: true,
|
||||
});
|
||||
|
||||
const dashboard = new DashboardPage(page);
|
||||
await dashboard.gotoById(id);
|
||||
await dashboard.waitForLoad();
|
||||
await dashboard.enterEditMode();
|
||||
return dashboard;
|
||||
}
|
||||
|
||||
testWithAssets(
|
||||
'edit mode: add a chart to the dashboard via drag-and-drop',
|
||||
async ({ page, testAssets }, testInfo) => {
|
||||
const sliceName = await createChart(page, testAssets, testInfo);
|
||||
const dashboard = await openEmptyDashboardInEditMode(
|
||||
page,
|
||||
testAssets,
|
||||
testInfo,
|
||||
);
|
||||
|
||||
await expect(dashboard.getChartHolders()).toHaveCount(0);
|
||||
await dashboard.addChartByName(sliceName);
|
||||
await expect(dashboard.getChartHolders()).toHaveCount(1);
|
||||
},
|
||||
);
|
||||
|
||||
testWithAssets(
|
||||
'edit mode: remove an added chart from the dashboard',
|
||||
async ({ page, testAssets }, testInfo) => {
|
||||
const sliceName = await createChart(page, testAssets, testInfo);
|
||||
const dashboard = await openEmptyDashboardInEditMode(
|
||||
page,
|
||||
testAssets,
|
||||
testInfo,
|
||||
);
|
||||
|
||||
await dashboard.addChartByName(sliceName);
|
||||
await expect(dashboard.getChartHolders()).toHaveCount(1);
|
||||
|
||||
await dashboard.deleteChartHolder();
|
||||
await expect(dashboard.getChartHolders()).toHaveCount(0);
|
||||
},
|
||||
);
|
||||
|
||||
testWithAssets(
|
||||
'edit mode: add a markdown component via drag-and-drop',
|
||||
async ({ page, testAssets }, testInfo) => {
|
||||
// Heaviest edit-mode flow (drag + ace edit + commit + mouse resize); give it
|
||||
// extra headroom so it stays reliable when the suite runs in parallel.
|
||||
testWithAssets.slow();
|
||||
const dashboard = await openEmptyDashboardInEditMode(
|
||||
page,
|
||||
testAssets,
|
||||
testInfo,
|
||||
);
|
||||
|
||||
await dashboard.addLayoutElement('Text / Markdown');
|
||||
const editor = dashboard.getMarkdownEditors().first();
|
||||
await expect(editor).toBeVisible();
|
||||
|
||||
// Enter edit mode by focusing the component. The markdown enters edit on a
|
||||
// document-level focus handler attached after mount, so a single early click
|
||||
// can be missed under load; retry until the ace editor appears. Click the
|
||||
// rendered "Header 1" heading element specifically (never the trailing
|
||||
// hyperlink in the default content), so a stray click can't navigate away.
|
||||
const aceContent = dashboard.getMarkdownAceContent(editor);
|
||||
const heading = editor.locator('h1', { hasText: 'Header 1' });
|
||||
await expect(async () => {
|
||||
if (await aceContent.isVisible()) return;
|
||||
await heading.click();
|
||||
await expect(aceContent).toBeVisible({
|
||||
timeout: MARKDOWN_EDIT_ATTEMPT_TIMEOUT,
|
||||
});
|
||||
}).toPass({ timeout: MARKDOWN_EDIT_TOTAL_TIMEOUT });
|
||||
await expect(aceContent).toContainText('Header 1');
|
||||
await expect(aceContent).toContainText('markdown formatting');
|
||||
|
||||
// Replace the content and confirm the edit is reflected.
|
||||
const aceInput = dashboard.getMarkdownAceInput(editor);
|
||||
await aceInput.press('ControlOrMeta+a');
|
||||
await aceInput.press('Delete');
|
||||
await aceInput.pressSequentially('Test resize');
|
||||
await expect(aceContent).toContainText('Test resize');
|
||||
|
||||
// Commit by clicking outside the component. Ace unmounting is what proves
|
||||
// the component left its editing state — the wrapper contains "Test resize"
|
||||
// either way, since ace holds that text before the click too.
|
||||
await dashboard.blurToDashboardTitle();
|
||||
await expect(aceContent).toBeHidden();
|
||||
await expect(editor).toContainText('Test resize');
|
||||
|
||||
// Resize via the bottom handle and confirm the component grew taller.
|
||||
const { heightBefore, heightAfter } = await dashboard.resizeComponent(
|
||||
editor,
|
||||
RESIZE_DELTA_PX,
|
||||
);
|
||||
expect(heightAfter).toBeGreaterThan(heightBefore);
|
||||
},
|
||||
);
|
||||
@@ -39,26 +39,26 @@ import {
|
||||
apiPostDashboard,
|
||||
buildSingleRowDashboardLayout,
|
||||
} from '../../helpers/api/dashboard';
|
||||
import { getDatasetByName } from '../../helpers/api/dataset';
|
||||
import { extractIdFromResponse } from '../../helpers/api/assertions';
|
||||
import { DashboardPage } from '../../pages/DashboardPage';
|
||||
import {
|
||||
buildFilterJsonMetadata,
|
||||
buildSelectFilter,
|
||||
} from './dashboard-test-helpers';
|
||||
|
||||
const DATASET_NAME = 'birth_names';
|
||||
const FILTER_COLUMN = 'gender';
|
||||
const FILTER_VALUE = 'boy';
|
||||
|
||||
async function findDatasetIdByName(page: any, name: string): Promise<number> {
|
||||
const query = `(filters:!((col:table_name,opr:eq,value:'${name}')))`;
|
||||
const resp = await page.request.get(`api/v1/dataset/?q=${query}`);
|
||||
const body = await resp.json();
|
||||
if (!body.result?.length) {
|
||||
throw new Error(`Dataset ${name} not found`);
|
||||
}
|
||||
return body.result[0].id;
|
||||
}
|
||||
|
||||
testWithAssets(
|
||||
'Mixed chart applies dashboard filter to both queries (#29519)',
|
||||
async ({ page, testAssets }) => {
|
||||
const datasetId = await findDatasetIdByName(page, DATASET_NAME);
|
||||
const dataset = await getDatasetByName(page, DATASET_NAME);
|
||||
if (!dataset) {
|
||||
throw new Error(`Dataset ${DATASET_NAME} not found`);
|
||||
}
|
||||
const datasetId = dataset.id;
|
||||
|
||||
const chartParams = {
|
||||
datasource: `${datasetId}__table`,
|
||||
@@ -86,10 +86,9 @@ testWithAssets(
|
||||
params: JSON.stringify(chartParams),
|
||||
});
|
||||
expect(chartResp.ok()).toBe(true);
|
||||
const chartId: number = (await chartResp.json()).id;
|
||||
const chartId = await extractIdFromResponse(chartResp);
|
||||
testAssets.trackChart(chartId);
|
||||
|
||||
const filterId = `NATIVE_FILTER-${Math.random().toString(36).slice(2, 10)}`;
|
||||
const positionJson = buildSingleRowDashboardLayout([
|
||||
{
|
||||
id: chartId,
|
||||
@@ -98,39 +97,20 @@ testWithAssets(
|
||||
height: 60,
|
||||
},
|
||||
]);
|
||||
const jsonMetadata = {
|
||||
native_filter_configuration: [
|
||||
{
|
||||
id: filterId,
|
||||
name: 'Gender',
|
||||
filterType: 'filter_select',
|
||||
type: 'NATIVE_FILTER',
|
||||
targets: [{ datasetId, column: { name: FILTER_COLUMN } }],
|
||||
controlValues: {
|
||||
multiSelect: false,
|
||||
enableEmptyFilter: false,
|
||||
defaultToFirstItem: false,
|
||||
inverseSelection: false,
|
||||
searchAllOptions: false,
|
||||
},
|
||||
defaultDataMask: {
|
||||
filterState: { value: [FILTER_VALUE] },
|
||||
extraFormData: {
|
||||
filters: [{ col: FILTER_COLUMN, op: 'IN', val: [FILTER_VALUE] }],
|
||||
},
|
||||
},
|
||||
cascadeParentIds: [],
|
||||
scope: { rootPath: ['ROOT_ID'], excluded: [] },
|
||||
// Preselect the filter value so it is already applied on the dashboard's
|
||||
// first chart-data request — that request is what the assertions inspect.
|
||||
const jsonMetadata = buildFilterJsonMetadata({
|
||||
chartsInScope: [chartId],
|
||||
nativeFilters: [
|
||||
buildSelectFilter({
|
||||
datasetId,
|
||||
column: FILTER_COLUMN,
|
||||
chartsInScope: [chartId],
|
||||
},
|
||||
name: 'Gender',
|
||||
defaultValue: FILTER_VALUE,
|
||||
}),
|
||||
],
|
||||
chart_configuration: {},
|
||||
cross_filters_enabled: false,
|
||||
global_chart_configuration: {
|
||||
scope: { rootPath: ['ROOT_ID'], excluded: [] },
|
||||
chartsInScope: [chartId],
|
||||
},
|
||||
};
|
||||
});
|
||||
const dashResp = await apiPostDashboard(page, {
|
||||
dashboard_title: `mixed_filter_repro_${Date.now()}`,
|
||||
published: true,
|
||||
@@ -138,8 +118,7 @@ testWithAssets(
|
||||
json_metadata: JSON.stringify(jsonMetadata),
|
||||
});
|
||||
expect(dashResp.ok()).toBe(true);
|
||||
const dashBody = await dashResp.json();
|
||||
const dashboardId: number = dashBody.result?.id ?? dashBody.id;
|
||||
const dashboardId = await extractIdFromResponse(dashResp);
|
||||
testAssets.trackDashboard(dashboardId);
|
||||
|
||||
await apiPut(page, `api/v1/chart/${chartId}`, {
|
||||
|
||||
@@ -128,16 +128,15 @@ test('non-admin user can view a themed dashboard without 403 or infinite spinner
|
||||
|
||||
// --- NON-ADMIN USER PHASE (page has no cached auth via test.use) ---
|
||||
|
||||
// 4. Instrument network: track any /api/v1/theme/ requests and 403 responses
|
||||
// 4. Instrument network: track any /api/v1/theme/ request, with its status.
|
||||
// Recording the status rather than asserting on a separate 403-only array
|
||||
// keeps the diagnostic — a failure prints whether the calls were forbidden
|
||||
// or merely unexpected — without a second, subsumed assertion.
|
||||
const themeApiRequests: string[] = [];
|
||||
const forbiddenResponses: string[] = [];
|
||||
page.on('response', response => {
|
||||
const url = response.url();
|
||||
if (url.includes('/api/v1/theme/')) {
|
||||
themeApiRequests.push(url);
|
||||
}
|
||||
if (response.status() === 403 && url.includes('/api/v1/theme/')) {
|
||||
forbiddenResponses.push(url);
|
||||
themeApiRequests.push(`${response.status()} ${url}`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -152,14 +151,19 @@ test('non-admin user can view a themed dashboard without 403 or infinite spinner
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
await dashboardPage.gotoById(dashboardId!);
|
||||
|
||||
// 7. Assert dashboard fully loads (not stuck on infinite spinner)
|
||||
// 7. Assert dashboard fully loads (not stuck on infinite spinner).
|
||||
// The dashboard is created with no position_json, so its grid renders
|
||||
// empty — there is no chart to wait for, only the grid itself.
|
||||
await dashboardPage.waitForLoad({ timeout: TIMEOUT.PAGE_LOAD });
|
||||
await dashboardPage.waitForChartsToLoad();
|
||||
await dashboardPage.waitForGridToLoad();
|
||||
|
||||
// 8. Assert no /api/v1/theme/ requests were made (theme data comes from dashboard response)
|
||||
expect(themeApiRequests).toHaveLength(0);
|
||||
// Assert no 403 responses on /api/v1/theme/ (scoped to avoid login/unrelated 403 noise)
|
||||
expect(forbiddenResponses).toHaveLength(0);
|
||||
// 8. A non-admin must render the themed dashboard without ever calling the
|
||||
// theme API — theme data rides along on the dashboard response, and the
|
||||
// endpoint itself is admin-only, so any call here would 403 and break them.
|
||||
expect(
|
||||
themeApiRequests,
|
||||
'Non-admin dashboard load must not call the theme API',
|
||||
).toHaveLength(0);
|
||||
} finally {
|
||||
// Cleanup: delete test resources using admin context
|
||||
if (dashboardId) {
|
||||
|
||||
@@ -38,6 +38,14 @@
|
||||
*
|
||||
* NOTE: the embedded suite only runs when the embedded SDK bundle is built and
|
||||
* INCLUDE_EMBEDDED=true (CI sets both). It is skipped otherwise.
|
||||
*
|
||||
* NOTE: the embedded project runs with admin storageState, and the session
|
||||
* cookie the iframe ends up with is racy: the /embedded/<uuid> response
|
||||
* rotates it to an anonymous session while the SDK's parallel csrf and
|
||||
* guest-token fetches rewrite the admin one, so chart data requests are
|
||||
* evaluated as either admin or guest depending on which response lands last.
|
||||
* Fixture charts must therefore hold up under GUEST evaluation — see the
|
||||
* query_context note below — or the suite only passes when admin wins.
|
||||
*/
|
||||
import { test, expect, Browser, BrowserContext, Page } from '@playwright/test';
|
||||
import { createServer, IncomingMessage, ServerResponse, Server } from 'http';
|
||||
@@ -182,12 +190,43 @@ test.describe('Embedded Pivot Table collapse state (#33406)', () => {
|
||||
row_limit: 1000,
|
||||
order_desc: true,
|
||||
};
|
||||
// Charts saved through Explore always persist a query_context alongside
|
||||
// params. Store one here too: guest (embedded) requests are validated
|
||||
// against the stored chart, and a params-only chart makes the guest
|
||||
// payload look tampered (its query `columns` aren't found on the chart),
|
||||
// failing every chart data request with a 403.
|
||||
const queryContext = {
|
||||
datasource: { id: datasetId, type: 'table' },
|
||||
force: false,
|
||||
queries: [
|
||||
{
|
||||
filters: [],
|
||||
extras: { having: '', where: '' },
|
||||
applied_time_extras: {},
|
||||
columns: ['state', 'name'],
|
||||
metrics: ['count'],
|
||||
orderby: [['count', false]],
|
||||
annotation_layers: [],
|
||||
row_limit: 1000,
|
||||
series_limit: 0,
|
||||
order_desc: true,
|
||||
url_params: {},
|
||||
custom_params: {},
|
||||
custom_form_data: {},
|
||||
},
|
||||
],
|
||||
form_data: params,
|
||||
result_format: 'json',
|
||||
result_type: 'full',
|
||||
};
|
||||
const chartResp = await apiPost(setupPage, 'api/v1/chart/', {
|
||||
slice_name: `pivot_collapse_repro_${Date.now()}`,
|
||||
viz_type: 'pivot_table_v2',
|
||||
datasource_id: datasetId,
|
||||
datasource_type: 'table',
|
||||
params: JSON.stringify(params),
|
||||
query_context: JSON.stringify(queryContext),
|
||||
query_context_generation: true,
|
||||
});
|
||||
chartId = (await chartResp.json()).id;
|
||||
|
||||
|
||||
@@ -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,61 +0,0 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [0.20.0](https://github.com/apache/superset/compare/v2021.41.0...v0.20.0) (2024-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **Dashboard:** Color inconsistency on refreshes and conflicts ([#27439](https://github.com/apache/superset/issues/27439)) ([313ee59](https://github.com/apache/superset/commit/313ee596f5435894f857d72be7269d5070c8c964))
|
||||
- **explore:** make SORT-Descending visible if Sort-by has value ([#17726](https://github.com/apache/superset/issues/17726)) ([d5768ab](https://github.com/apache/superset/commit/d5768ab649a70fd4f541ad4982498f622160b220))
|
||||
|
||||
### Features
|
||||
|
||||
- apply standardized form data to tier 2 charts ([#20530](https://github.com/apache/superset/issues/20530)) ([de524bc](https://github.com/apache/superset/commit/de524bc59f011fd361dcdb7d35c2cb51f7eba442))
|
||||
- **explore:** improve UI in the control panel ([#19748](https://github.com/apache/superset/issues/19748)) ([e3a54aa](https://github.com/apache/superset/commit/e3a54aa3c15bdd0c970aa73f898288a408205c97))
|
||||
- improve color consistency (save all labels) ([#19038](https://github.com/apache/superset/issues/19038)) ([dc57508](https://github.com/apache/superset/commit/dc575080d7e43d40b1734bb8f44fdc291cb95b11))
|
||||
- update time comparison choices (again) ([#17968](https://github.com/apache/superset/issues/17968)) ([05d9cde](https://github.com/apache/superset/commit/05d9cde203b99f8c63106446f0be58668cc9f0c9))
|
||||
- update time comparison choices (again) ([#22458](https://github.com/apache/superset/issues/22458)) ([9e81c3a](https://github.com/apache/superset/commit/9e81c3a1192a18226d505178d16e1e395917a719))
|
||||
|
||||
# [0.19.0](https://github.com/apache/superset/compare/v2021.41.0...v0.19.0) (2024-09-07)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **Dashboard:** Color inconsistency on refreshes and conflicts ([#27439](https://github.com/apache/superset/issues/27439)) ([313ee59](https://github.com/apache/superset/commit/313ee596f5435894f857d72be7269d5070c8c964))
|
||||
- **explore:** make SORT-Descending visible if Sort-by has value ([#17726](https://github.com/apache/superset/issues/17726)) ([d5768ab](https://github.com/apache/superset/commit/d5768ab649a70fd4f541ad4982498f622160b220))
|
||||
|
||||
### Features
|
||||
|
||||
- apply standardized form data to tier 2 charts ([#20530](https://github.com/apache/superset/issues/20530)) ([de524bc](https://github.com/apache/superset/commit/de524bc59f011fd361dcdb7d35c2cb51f7eba442))
|
||||
- **explore:** improve UI in the control panel ([#19748](https://github.com/apache/superset/issues/19748)) ([e3a54aa](https://github.com/apache/superset/commit/e3a54aa3c15bdd0c970aa73f898288a408205c97))
|
||||
- improve color consistency (save all labels) ([#19038](https://github.com/apache/superset/issues/19038)) ([dc57508](https://github.com/apache/superset/commit/dc575080d7e43d40b1734bb8f44fdc291cb95b11))
|
||||
- update time comparison choices (again) ([#17968](https://github.com/apache/superset/issues/17968)) ([05d9cde](https://github.com/apache/superset/commit/05d9cde203b99f8c63106446f0be58668cc9f0c9))
|
||||
- update time comparison choices (again) ([#22458](https://github.com/apache/superset/issues/22458)) ([9e81c3a](https://github.com/apache/superset/commit/9e81c3a1192a18226d505178d16e1e395917a719))
|
||||
|
||||
# [0.18.0](https://github.com/apache-superset/superset-ui/compare/v0.17.87...v0.18.0) (2021-08-30)
|
||||
|
||||
**Note:** Version bump only for package @superset-ui/legacy-plugin-chart-rose
|
||||
|
||||
## [0.17.61](https://github.com/apache-superset/superset-ui/compare/v0.17.60...v0.17.61) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package @superset-ui/legacy-plugin-chart-rose
|
||||
@@ -1,52 +0,0 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## @superset-ui/legacy-plugin-chart-rose
|
||||
|
||||
[](https://www.npmjs.com/package/@superset-ui/legacy-plugin-chart-rose)
|
||||
[](https://libraries.io/npm/@superset-ui%2Flegacy-plugin-chart-rose)
|
||||
|
||||
This plugin provides Nightingale Rose Diagram for Superset.
|
||||
|
||||
### Usage
|
||||
|
||||
Configure `key`, which can be any `string`, and register the plugin. This `key` will be used to
|
||||
lookup this chart throughout the app.
|
||||
|
||||
```js
|
||||
import RoseChartPlugin from '@superset-ui/legacy-plugin-chart-rose';
|
||||
|
||||
new RoseChartPlugin().configure({ key: 'rose' }).register();
|
||||
```
|
||||
|
||||
Then use it via `SuperChart`. See
|
||||
[storybook](https://apache-superset.github.io/superset-ui-plugins/?selectedKind=plugin-chart-rose)
|
||||
for more details.
|
||||
|
||||
```js
|
||||
<SuperChart
|
||||
chartType="rose"
|
||||
width={600}
|
||||
height={600}
|
||||
formData={...}
|
||||
queriesData={[{
|
||||
data: {...},
|
||||
}]}
|
||||
/>
|
||||
```
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"name": "@superset-ui/legacy-plugin-chart-rose",
|
||||
"version": "0.20.3",
|
||||
"description": "Superset Legacy Chart - Nightingale Rose Diagram",
|
||||
"keywords": [
|
||||
"superset"
|
||||
],
|
||||
"homepage": "https://github.com/apache/superset/tree/master/superset-frontend/plugins/legacy-plugin-chart-rose#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/superset/issues"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"author": "Superset",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/superset.git",
|
||||
"directory": "superset-frontend/plugins/legacy-plugin-chart-rose"
|
||||
},
|
||||
"files": [
|
||||
"esm",
|
||||
"lib"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"module": "esm/index.js",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -1,87 +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 { reactify } from '@superset-ui/core';
|
||||
import { styled, css } from '@apache-superset/core/theme';
|
||||
import { Global } from '@emotion/react';
|
||||
import Component from './Rose';
|
||||
|
||||
// Type-erase the render function to allow flexible prop spreading in the wrapper.
|
||||
// The Rose render function has typed props, but the wrapper passes props via spread
|
||||
// which TypeScript cannot verify at compile time. Props are validated at runtime.
|
||||
const ReactComponent = reactify(
|
||||
Component as unknown as (
|
||||
container: HTMLDivElement,
|
||||
props: Record<string, unknown>,
|
||||
) => void,
|
||||
);
|
||||
|
||||
interface RoseWrapperProps {
|
||||
className?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
const Rose = ({ className, ...otherProps }: RoseWrapperProps) => (
|
||||
<div className={className}>
|
||||
<Global
|
||||
styles={theme => css`
|
||||
.tooltip {
|
||||
line-height: 1;
|
||||
padding: ${theme.sizeUnit * 3}px;
|
||||
background: ${theme.colorBgElevated};
|
||||
color: ${theme.colorText};
|
||||
border-radius: 4px;
|
||||
pointer-events: none;
|
||||
z-index: 1000;
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
}
|
||||
`}
|
||||
/>
|
||||
<ReactComponent {...otherProps} />
|
||||
</div>
|
||||
);
|
||||
|
||||
export default styled(Rose)`
|
||||
${({ theme }) => `
|
||||
.superset-legacy-chart-rose path {
|
||||
transition: fill-opacity 180ms linear;
|
||||
stroke: ${theme.colorBorder};
|
||||
stroke-width: 1px;
|
||||
stroke-opacity: 1;
|
||||
fill-opacity: 0.75;
|
||||
}
|
||||
|
||||
.superset-legacy-chart-rose text {
|
||||
font-size: ${theme.fontSizeSM}px;
|
||||
font-family: ${theme.fontFamily};
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.superset-legacy-chart-rose .clickable path {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.superset-legacy-chart-rose .hover path {
|
||||
fill-opacity: 1;
|
||||
}
|
||||
|
||||
.nv-legend .nv-series {
|
||||
cursor: pointer;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
@@ -1,697 +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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
/* oxlint-disable no-use-before-define: ["error", { "functions": false }] */
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
/* eslint-disable react/sort-prop-types */
|
||||
import d3 from 'd3';
|
||||
import PropTypes from 'prop-types';
|
||||
import nv from 'nvd3-fork';
|
||||
import {
|
||||
getTimeFormatter,
|
||||
getNumberFormatter,
|
||||
CategoricalColorNamespace,
|
||||
sanitizeHtml,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
interface RoseDataEntry {
|
||||
key: string[];
|
||||
name: string;
|
||||
time: number;
|
||||
value: number;
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface RoseData {
|
||||
[timestamp: string]: RoseDataEntry[];
|
||||
}
|
||||
|
||||
interface ArcDatum {
|
||||
startAngle: number;
|
||||
endAngle: number;
|
||||
innerRadius: number;
|
||||
outerRadius: number;
|
||||
name?: string;
|
||||
arcId?: number;
|
||||
val?: number;
|
||||
time?: number;
|
||||
percent?: number;
|
||||
}
|
||||
|
||||
interface RoseProps {
|
||||
data: RoseData;
|
||||
width: number;
|
||||
height: number;
|
||||
colorScheme: string;
|
||||
dateTimeFormat: string;
|
||||
numberFormat: string;
|
||||
useRichTooltip: boolean;
|
||||
useAreaProportions: boolean;
|
||||
sliceId: number;
|
||||
}
|
||||
|
||||
const propTypes = {
|
||||
// Data is an object hashed by numeric value, perhaps timestamp
|
||||
data: PropTypes.objectOf(
|
||||
PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
key: PropTypes.arrayOf(PropTypes.string),
|
||||
name: PropTypes.arrayOf(PropTypes.string),
|
||||
time: PropTypes.number,
|
||||
value: PropTypes.number,
|
||||
}),
|
||||
),
|
||||
),
|
||||
width: PropTypes.number,
|
||||
height: PropTypes.number,
|
||||
dateTimeFormat: PropTypes.string,
|
||||
numberFormat: PropTypes.string,
|
||||
useRichTooltip: PropTypes.bool,
|
||||
useAreaProportions: PropTypes.bool,
|
||||
colorScheme: PropTypes.string,
|
||||
};
|
||||
|
||||
function copyArc(d: ArcDatum): ArcDatum {
|
||||
return {
|
||||
startAngle: d.startAngle,
|
||||
endAngle: d.endAngle,
|
||||
innerRadius: d.innerRadius,
|
||||
outerRadius: d.outerRadius,
|
||||
};
|
||||
}
|
||||
|
||||
function sortValues(a: RoseDataEntry, b: RoseDataEntry): number {
|
||||
if (a.value === b.value) {
|
||||
return a.name > b.name ? 1 : -1;
|
||||
}
|
||||
|
||||
return b.value - a.value;
|
||||
}
|
||||
|
||||
function Rose(element: HTMLElement, props: RoseProps): void {
|
||||
const {
|
||||
data,
|
||||
width,
|
||||
height,
|
||||
colorScheme,
|
||||
dateTimeFormat,
|
||||
numberFormat,
|
||||
useRichTooltip,
|
||||
useAreaProportions,
|
||||
sliceId,
|
||||
} = props;
|
||||
|
||||
const div = d3.select(element);
|
||||
div.classed('superset-legacy-chart-rose', true);
|
||||
|
||||
const datum = data;
|
||||
const times = Object.keys(datum)
|
||||
.map(t => parseInt(t, 10))
|
||||
.sort((a, b) => a - b);
|
||||
const numGrains = times.length;
|
||||
const numGroups = datum[times[0]].length;
|
||||
const format = getNumberFormatter(numberFormat);
|
||||
const timeFormat = getTimeFormatter(dateTimeFormat);
|
||||
const colorFn = CategoricalColorNamespace.getScale(colorScheme);
|
||||
|
||||
d3.select('.nvtooltip').remove();
|
||||
div.selectAll('*').remove();
|
||||
|
||||
const arc = d3.svg.arc();
|
||||
const legend = nv.models.legend();
|
||||
const tooltip = nv.models.tooltip();
|
||||
const state = { disabled: datum[times[0]].map(() => false) };
|
||||
|
||||
const svg = div.append('svg').attr('width', width).attr('height', height);
|
||||
|
||||
const g = svg.append('g').attr('class', 'rose').append('g');
|
||||
|
||||
const legendWrap = g.append('g').attr('class', 'legendWrap');
|
||||
|
||||
function legendData(adatum: RoseData) {
|
||||
return adatum[times[0]].map((v: RoseDataEntry, i: number) => ({
|
||||
disabled: state.disabled[i],
|
||||
// Keep the raw name as `key` so it matches the value used for arc
|
||||
// fills (colorFn is called with d.name on arcs and d.key on the
|
||||
// legend). nvd3-fork's legend renders `key` via .text(), so the
|
||||
// raw value is escaped at the DOM sink.
|
||||
key: v.name,
|
||||
}));
|
||||
}
|
||||
|
||||
function tooltipData(d: ArcDatum, i: number, adatum: RoseData) {
|
||||
const timeIndex = Math.floor(d.arcId / numGroups);
|
||||
// nvd3-fork's nv.models.tooltip renders the `key` strings via .html(),
|
||||
// so any HTML in user-controlled column values would execute. Pass the
|
||||
// keys through sanitizeHtml to strip dangerous markup while preserving
|
||||
// legitimate text content.
|
||||
const series = useRichTooltip
|
||||
? adatum[times[timeIndex]]
|
||||
.filter(v => !state.disabled[v.id % numGroups])
|
||||
.map(v => ({
|
||||
key: sanitizeHtml(v.name),
|
||||
value: v.value,
|
||||
color: colorFn(v.name, sliceId),
|
||||
highlight: v.id === d.arcId,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
key: sanitizeHtml(d.name),
|
||||
value: d.val,
|
||||
color: colorFn(d.name, sliceId),
|
||||
},
|
||||
];
|
||||
|
||||
return {
|
||||
key: 'Date',
|
||||
value: d.time,
|
||||
series,
|
||||
};
|
||||
}
|
||||
|
||||
legend.width(width).color(d => colorFn(d.key, sliceId));
|
||||
legendWrap.datum(legendData(datum)).call(legend);
|
||||
|
||||
tooltip.headerFormatter(timeFormat).valueFormatter(format);
|
||||
tooltip.classes('tooltip');
|
||||
|
||||
// Compute max radius, which the largest value will occupy
|
||||
const roseHeight = height - legend.height();
|
||||
const margin = { top: legend.height() };
|
||||
const edgeMargin = 35; // space between outermost radius and slice edge
|
||||
const maxRadius = Math.min(width, roseHeight) / 2 - edgeMargin;
|
||||
const labelThreshold = 0.05;
|
||||
const gro = 8; // mouseover radius growth in pixels
|
||||
const mini = 0.075;
|
||||
|
||||
const centerTranslate = `translate(${width / 2},${
|
||||
roseHeight / 2 + margin.top
|
||||
})`;
|
||||
const roseWrap = g
|
||||
.append('g')
|
||||
.attr('transform', centerTranslate)
|
||||
.attr('class', 'roseWrap');
|
||||
|
||||
const labelsWrap = g
|
||||
.append('g')
|
||||
.attr('transform', centerTranslate)
|
||||
.attr('class', 'labelsWrap');
|
||||
|
||||
const groupLabelsWrap = g
|
||||
.append('g')
|
||||
.attr('transform', centerTranslate)
|
||||
.attr('class', 'groupLabelsWrap');
|
||||
|
||||
// Compute inner and outer angles for each data point
|
||||
function computeArcStates(adatum: RoseData) {
|
||||
// Find the max sum of values across all time
|
||||
let maxSum = 0;
|
||||
let grain = 0;
|
||||
const sums = [];
|
||||
for (const t of times) {
|
||||
const sum = datum[t].reduce(
|
||||
(a, v, i) => a + (state.disabled[i] ? 0 : v.value),
|
||||
0,
|
||||
);
|
||||
maxSum = sum > maxSum ? sum : maxSum;
|
||||
sums[grain] = sum;
|
||||
grain += 1;
|
||||
}
|
||||
|
||||
// Compute angle occupied by each time grain
|
||||
const dtheta = (Math.PI * 2) / numGrains;
|
||||
const angles = [];
|
||||
for (let i = 0; i <= numGrains; i += 1) {
|
||||
angles.push(dtheta * i - Math.PI / 2);
|
||||
}
|
||||
|
||||
// Compute proportion
|
||||
const P = maxRadius / maxSum;
|
||||
const Q = P * maxRadius;
|
||||
const computeOuterRadius = (value: number, innerRadius: number): number =>
|
||||
useAreaProportions
|
||||
? Math.sqrt(Q * value + innerRadius * innerRadius)
|
||||
: P * value + innerRadius;
|
||||
|
||||
const arcSt = {
|
||||
data: [],
|
||||
extend: {},
|
||||
push: {},
|
||||
pieStart: {},
|
||||
pie: {},
|
||||
pieOver: {},
|
||||
mini: {},
|
||||
labels: [],
|
||||
groupLabels: [],
|
||||
};
|
||||
let arcId = 0;
|
||||
for (let i = 0; i < numGrains; i += 1) {
|
||||
const t = times[i];
|
||||
const startAngle = angles[i];
|
||||
const endAngle = angles[i + 1];
|
||||
const G = (2 * Math.PI) / sums[i];
|
||||
let innerRadius = 0;
|
||||
let outerRadius;
|
||||
let pieStartAngle = 0;
|
||||
let pieEndAngle;
|
||||
for (const v of adatum[t]) {
|
||||
const val = state.disabled[arcId % numGroups] ? 0 : v.value;
|
||||
const { name, time } = v;
|
||||
v.id = arcId;
|
||||
outerRadius = computeOuterRadius(val, innerRadius);
|
||||
arcSt.data.push({
|
||||
startAngle,
|
||||
endAngle,
|
||||
innerRadius,
|
||||
outerRadius,
|
||||
name,
|
||||
arcId,
|
||||
val,
|
||||
time,
|
||||
});
|
||||
arcSt.extend[arcId] = {
|
||||
startAngle,
|
||||
endAngle,
|
||||
innerRadius,
|
||||
name,
|
||||
outerRadius: outerRadius + gro,
|
||||
};
|
||||
arcSt.push[arcId] = {
|
||||
startAngle,
|
||||
endAngle,
|
||||
innerRadius: innerRadius + gro,
|
||||
outerRadius: outerRadius + gro,
|
||||
};
|
||||
arcSt.pieStart[arcId] = {
|
||||
startAngle,
|
||||
endAngle,
|
||||
innerRadius: mini * maxRadius,
|
||||
outerRadius: maxRadius,
|
||||
};
|
||||
arcSt.mini[arcId] = {
|
||||
startAngle,
|
||||
endAngle,
|
||||
innerRadius: innerRadius * mini,
|
||||
outerRadius: outerRadius * mini,
|
||||
};
|
||||
arcId += 1;
|
||||
innerRadius = outerRadius;
|
||||
}
|
||||
const labelArc = { ...arcSt.data[i * numGroups] };
|
||||
labelArc.outerRadius = maxRadius + 20;
|
||||
labelArc.innerRadius = maxRadius + 15;
|
||||
arcSt.labels.push(labelArc);
|
||||
for (const v of adatum[t].concat().sort(sortValues)) {
|
||||
const val = state.disabled[v.id % numGroups] ? 0 : v.value;
|
||||
pieEndAngle = G * val + pieStartAngle;
|
||||
arcSt.pie[v.id] = {
|
||||
startAngle: pieStartAngle,
|
||||
endAngle: pieEndAngle,
|
||||
innerRadius: maxRadius * mini,
|
||||
outerRadius: maxRadius,
|
||||
percent: v.value / sums[i],
|
||||
};
|
||||
arcSt.pieOver[v.id] = {
|
||||
startAngle: pieStartAngle,
|
||||
endAngle: pieEndAngle,
|
||||
innerRadius: maxRadius * mini,
|
||||
outerRadius: maxRadius + gro,
|
||||
};
|
||||
pieStartAngle = pieEndAngle;
|
||||
}
|
||||
}
|
||||
arcSt.groupLabels = arcSt.data.slice(0, numGroups);
|
||||
|
||||
return arcSt;
|
||||
}
|
||||
|
||||
let arcSt = computeArcStates(datum);
|
||||
|
||||
function tween(target: ArcDatum, resFunc: (d: ArcDatum) => string) {
|
||||
return function doTween(d: ArcDatum) {
|
||||
const interpolate = d3.interpolate(copyArc(d), copyArc(target));
|
||||
|
||||
return (t: number) => resFunc(Object.assign(d, interpolate(t)));
|
||||
};
|
||||
}
|
||||
|
||||
function arcTween(target: ArcDatum) {
|
||||
return tween(target, (d: ArcDatum) => arc(d));
|
||||
}
|
||||
|
||||
function translateTween(target: ArcDatum) {
|
||||
return tween(target, (d: ArcDatum) => `translate(${arc.centroid(d)})`);
|
||||
}
|
||||
|
||||
// Grab the ID range of segments stand between
|
||||
// this segment and the edge of the circle
|
||||
const segmentsToEdgeCache: Record<number, [number, number]> = {};
|
||||
function getSegmentsToEdge(arcId: number): [number, number] {
|
||||
if (segmentsToEdgeCache[arcId]) {
|
||||
return segmentsToEdgeCache[arcId];
|
||||
}
|
||||
const timeIndex = Math.floor(arcId / numGroups);
|
||||
segmentsToEdgeCache[arcId] = [arcId + 1, numGroups * (timeIndex + 1) - 1];
|
||||
|
||||
return segmentsToEdgeCache[arcId];
|
||||
}
|
||||
|
||||
// Get the IDs of all segments in a timeIndex
|
||||
const segmentsInTimeCache: Record<number, [number, number]> = {};
|
||||
function getSegmentsInTime(arcId: number): [number, number] {
|
||||
if (segmentsInTimeCache[arcId]) {
|
||||
return segmentsInTimeCache[arcId];
|
||||
}
|
||||
const timeIndex = Math.floor(arcId / numGroups);
|
||||
segmentsInTimeCache[arcId] = [
|
||||
timeIndex * numGroups,
|
||||
(timeIndex + 1) * numGroups - 1,
|
||||
];
|
||||
|
||||
return segmentsInTimeCache[arcId];
|
||||
}
|
||||
|
||||
let clickId = -1;
|
||||
let inTransition = false;
|
||||
const ae = roseWrap
|
||||
.selectAll('g')
|
||||
.data(JSON.parse(JSON.stringify(arcSt.data))) // deep copy data state
|
||||
.enter()
|
||||
.append('g')
|
||||
.attr('class', 'segment')
|
||||
.classed('clickable', true);
|
||||
|
||||
const labels = labelsWrap
|
||||
.selectAll('g')
|
||||
.data(JSON.parse(JSON.stringify(arcSt.labels)))
|
||||
.enter()
|
||||
.append('g')
|
||||
.attr('class', 'roseLabel')
|
||||
.attr('transform', d => `translate(${arc.centroid(d)})`);
|
||||
|
||||
labels
|
||||
.append('text')
|
||||
.style('text-anchor', 'middle')
|
||||
.style('fill', '#000')
|
||||
.text(d => timeFormat(d.time));
|
||||
|
||||
const groupLabels = groupLabelsWrap
|
||||
.selectAll('g')
|
||||
.data(JSON.parse(JSON.stringify(arcSt.groupLabels)))
|
||||
.enter()
|
||||
.append('g');
|
||||
|
||||
groupLabels
|
||||
.style('opacity', 0)
|
||||
.attr('class', 'roseGroupLabels')
|
||||
.append('text')
|
||||
.style('text-anchor', 'middle')
|
||||
.style('fill', '#000')
|
||||
.text(d => d.name);
|
||||
|
||||
const arcs = ae
|
||||
.append('path')
|
||||
.attr('class', 'arc')
|
||||
.attr('fill', d => colorFn(d.name, sliceId))
|
||||
.attr('d', arc);
|
||||
|
||||
function mousemove(): void {
|
||||
tooltip();
|
||||
}
|
||||
|
||||
function mouseover(this: Element, b: ArcDatum, i: number): void {
|
||||
tooltip.data(tooltipData(b, i, datum)).hidden(false);
|
||||
const $this = d3.select(this);
|
||||
$this.classed('hover', true);
|
||||
if (clickId < 0 && !inTransition) {
|
||||
$this
|
||||
.select('path')
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(180)
|
||||
.attrTween('d', arcTween(arcSt.extend[i]));
|
||||
const edge = getSegmentsToEdge(i);
|
||||
arcs
|
||||
.filter(d => edge[0] <= d.arcId && d.arcId <= edge[1])
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(180)
|
||||
.attrTween('d', d => arcTween(arcSt.push[d.arcId])(d));
|
||||
} else if (!inTransition) {
|
||||
const segments = getSegmentsInTime(clickId);
|
||||
if (segments[0] <= b.arcId && b.arcId <= segments[1]) {
|
||||
$this
|
||||
.select('path')
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(180)
|
||||
.attrTween('d', arcTween(arcSt.pieOver[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mouseout(this: Element, b: ArcDatum, i: number): void {
|
||||
tooltip.hidden(true);
|
||||
const $this = d3.select(this);
|
||||
$this.classed('hover', false);
|
||||
if (clickId < 0 && !inTransition) {
|
||||
$this
|
||||
.select('path')
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(180)
|
||||
.attrTween('d', arcTween(arcSt.data[i]));
|
||||
const edge = getSegmentsToEdge(i);
|
||||
arcs
|
||||
.filter(d => edge[0] <= d.arcId && d.arcId <= edge[1])
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(180)
|
||||
.attrTween('d', d => arcTween(arcSt.data[d.arcId])(d));
|
||||
} else if (!inTransition) {
|
||||
const segments = getSegmentsInTime(clickId);
|
||||
if (segments[0] <= b.arcId && b.arcId <= segments[1]) {
|
||||
$this
|
||||
.select('path')
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(180)
|
||||
.attrTween('d', arcTween(arcSt.pie[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function click(b: ArcDatum, i: number): void {
|
||||
if (inTransition) {
|
||||
return;
|
||||
}
|
||||
const delay = d3.event.altKey ? 3750 : 375;
|
||||
const segments = getSegmentsInTime(i);
|
||||
if (clickId < 0) {
|
||||
inTransition = true;
|
||||
clickId = i;
|
||||
labels
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('transform', d =>
|
||||
translateTween({
|
||||
outerRadius: 0,
|
||||
innerRadius: 0,
|
||||
startAngle: d.startAngle,
|
||||
endAngle: d.endAngle,
|
||||
})(d),
|
||||
)
|
||||
.style('opacity', 0);
|
||||
groupLabels
|
||||
.attr(
|
||||
'transform',
|
||||
`translate(${arc.centroid({
|
||||
outerRadius: maxRadius + 20,
|
||||
innerRadius: maxRadius + 15,
|
||||
startAngle: arcSt.data[i].startAngle,
|
||||
endAngle: arcSt.data[i].endAngle,
|
||||
})})`,
|
||||
)
|
||||
.interrupt()
|
||||
.transition()
|
||||
.delay(delay)
|
||||
.duration(delay)
|
||||
.attrTween('transform', d =>
|
||||
translateTween({
|
||||
outerRadius: maxRadius + 20,
|
||||
innerRadius: maxRadius + 15,
|
||||
startAngle: arcSt.pie[segments[0] + d.arcId].startAngle,
|
||||
endAngle: arcSt.pie[segments[0] + d.arcId].endAngle,
|
||||
})(d),
|
||||
)
|
||||
.style('opacity', d =>
|
||||
state.disabled[d.arcId] ||
|
||||
arcSt.pie[segments[0] + d.arcId].percent < labelThreshold
|
||||
? 0
|
||||
: 1,
|
||||
);
|
||||
ae.classed(
|
||||
'clickable',
|
||||
d => segments[0] > d.arcId || d.arcId > segments[1],
|
||||
);
|
||||
arcs
|
||||
.filter(d => segments[0] <= d.arcId && d.arcId <= segments[1])
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('d', d => arcTween(arcSt.pieStart[d.arcId])(d))
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('d', d => arcTween(arcSt.pie[d.arcId])(d))
|
||||
.each('end', () => {
|
||||
inTransition = false;
|
||||
});
|
||||
arcs
|
||||
.filter(d => segments[0] > d.arcId || d.arcId > segments[1])
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('d', d => arcTween(arcSt.mini[d.arcId])(d));
|
||||
} else if (clickId < segments[0] || segments[1] < clickId) {
|
||||
inTransition = true;
|
||||
const clickSegments = getSegmentsInTime(clickId);
|
||||
labels
|
||||
.interrupt()
|
||||
.transition()
|
||||
.delay(delay)
|
||||
.duration(delay)
|
||||
.attrTween('transform', d =>
|
||||
translateTween(arcSt.labels[d.arcId / numGroups])(d),
|
||||
)
|
||||
.style('opacity', 1);
|
||||
groupLabels
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween(
|
||||
'transform',
|
||||
translateTween({
|
||||
outerRadius: maxRadius + 20,
|
||||
innerRadius: maxRadius + 15,
|
||||
startAngle: arcSt.data[clickId].startAngle,
|
||||
endAngle: arcSt.data[clickId].endAngle,
|
||||
}),
|
||||
)
|
||||
.style('opacity', 0);
|
||||
ae.classed('clickable', true);
|
||||
arcs
|
||||
.filter(d => clickSegments[0] <= d.arcId && d.arcId <= clickSegments[1])
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('d', d => arcTween(arcSt.pieStart[d.arcId])(d))
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('d', d => arcTween(arcSt.data[d.arcId])(d))
|
||||
.each('end', () => {
|
||||
clickId = -1;
|
||||
inTransition = false;
|
||||
});
|
||||
arcs
|
||||
.filter(d => clickSegments[0] > d.arcId || d.arcId > clickSegments[1])
|
||||
.interrupt()
|
||||
.transition()
|
||||
.delay(delay)
|
||||
.duration(delay)
|
||||
.attrTween('d', d => arcTween(arcSt.data[d.arcId])(d));
|
||||
}
|
||||
}
|
||||
|
||||
ae.on('mouseover', mouseover)
|
||||
.on('mouseout', mouseout)
|
||||
.on('mousemove', mousemove)
|
||||
.on('click', click);
|
||||
|
||||
function updateActive(): void {
|
||||
const delay = d3.event.altKey ? 3000 : 300;
|
||||
legendWrap.datum(legendData(datum)).call(legend);
|
||||
const nArcSt = computeArcStates(datum);
|
||||
inTransition = true;
|
||||
if (clickId < 0) {
|
||||
arcs
|
||||
.style('opacity', 1)
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('d', d => arcTween(nArcSt.data[d.arcId])(d))
|
||||
.each('end', () => {
|
||||
inTransition = false;
|
||||
arcSt = nArcSt;
|
||||
})
|
||||
.transition()
|
||||
.duration(0)
|
||||
.style('opacity', d => (state.disabled[d.arcId % numGroups] ? 0 : 1));
|
||||
} else {
|
||||
const segments = getSegmentsInTime(clickId);
|
||||
arcs
|
||||
.style('opacity', 1)
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('d', d =>
|
||||
segments[0] <= d.arcId && d.arcId <= segments[1]
|
||||
? arcTween(nArcSt.pie[d.arcId])(d)
|
||||
: arcTween(nArcSt.mini[d.arcId])(d),
|
||||
)
|
||||
.each('end', () => {
|
||||
inTransition = false;
|
||||
arcSt = nArcSt;
|
||||
})
|
||||
.transition()
|
||||
.duration(0)
|
||||
.style('opacity', d => (state.disabled[d.arcId % numGroups] ? 0 : 1));
|
||||
groupLabels
|
||||
.interrupt()
|
||||
.transition()
|
||||
.duration(delay)
|
||||
.attrTween('transform', d =>
|
||||
translateTween({
|
||||
outerRadius: maxRadius + 20,
|
||||
innerRadius: maxRadius + 15,
|
||||
startAngle: nArcSt.pie[segments[0] + d.arcId].startAngle,
|
||||
endAngle: nArcSt.pie[segments[0] + d.arcId].endAngle,
|
||||
})(d),
|
||||
)
|
||||
.style('opacity', d =>
|
||||
state.disabled[d.arcId] ||
|
||||
arcSt.pie[segments[0] + d.arcId].percent < labelThreshold
|
||||
? 0
|
||||
: 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
legend.dispatch.on('stateChange', newState => {
|
||||
if (state.disabled !== newState.disabled) {
|
||||
state.disabled = newState.disabled;
|
||||
updateActive();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Rose.displayName = 'Rose';
|
||||
Rose.propTypes = propTypes;
|
||||
|
||||
export default Rose;
|
||||
|
Before Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 27 KiB |
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable no-magic-numbers, sort-keys */
|
||||
import { SuperChart, VizType } from '@superset-ui/core';
|
||||
import RoseChartPlugin from '@superset-ui/legacy-plugin-chart-rose';
|
||||
import data from './data';
|
||||
import { withResizableChartDemo } from '@storybook-shared';
|
||||
|
||||
new RoseChartPlugin().configure({ key: VizType.Rose }).register();
|
||||
|
||||
export default {
|
||||
title: 'Legacy Chart Plugins/legacy-plugin-chart-rose',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
colorScheme: 'd3Category10',
|
||||
numberFormat: '.3s',
|
||||
dateTimeFormat: '%Y-%m-%d',
|
||||
richTooltip: true,
|
||||
roseAreaProportion: false,
|
||||
},
|
||||
argTypes: {
|
||||
colorScheme: {
|
||||
control: 'select',
|
||||
options: [
|
||||
'supersetColors',
|
||||
'd3Category10',
|
||||
'bnbColors',
|
||||
'googleCategory20c',
|
||||
],
|
||||
},
|
||||
numberFormat: {
|
||||
control: 'select',
|
||||
options: ['SMART_NUMBER', '.2f', '.0%', '$,.2f', '.3s', ',d'],
|
||||
},
|
||||
dateTimeFormat: {
|
||||
control: 'select',
|
||||
options: ['%Y-%m-%d', '%Y-%m-%d %H:%M', '%b %d, %Y', '%d/%m/%Y'],
|
||||
},
|
||||
richTooltip: { control: 'boolean' },
|
||||
roseAreaProportion: {
|
||||
control: 'boolean',
|
||||
description:
|
||||
'When true, area is proportional to value; when false, radius is proportional',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Basic = ({
|
||||
width,
|
||||
height,
|
||||
colorScheme,
|
||||
numberFormat,
|
||||
dateTimeFormat,
|
||||
richTooltip,
|
||||
roseAreaProportion,
|
||||
}: {
|
||||
width: number;
|
||||
height: number;
|
||||
colorScheme: string;
|
||||
numberFormat: string;
|
||||
dateTimeFormat: string;
|
||||
richTooltip: boolean;
|
||||
roseAreaProportion: boolean;
|
||||
}) => (
|
||||
<SuperChart
|
||||
chartType={VizType.Rose}
|
||||
width={width}
|
||||
height={height}
|
||||
queriesData={[{ data }]}
|
||||
formData={{
|
||||
color_scheme: colorScheme,
|
||||
date_time_format: dateTimeFormat,
|
||||
number_format: numberFormat,
|
||||
rich_tooltip: richTooltip,
|
||||
rose_area_proportion: roseAreaProportion,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -1,950 +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 {
|
||||
'-157766400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: -157766400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: -157766400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 6820.0,
|
||||
name: ['David'],
|
||||
time: -157766400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: -157766400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7835.0,
|
||||
name: ['Michael'],
|
||||
time: -157766400000.0,
|
||||
},
|
||||
],
|
||||
'-126230400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: -126230400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: -126230400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 6757.0,
|
||||
name: ['David'],
|
||||
time: -126230400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: -126230400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7678.0,
|
||||
name: ['Michael'],
|
||||
time: -126230400000.0,
|
||||
},
|
||||
],
|
||||
'-94694400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: -94694400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: -94694400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 6923.0,
|
||||
name: ['David'],
|
||||
time: -94694400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: -94694400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 8132.0,
|
||||
name: ['Michael'],
|
||||
time: -94694400000.0,
|
||||
},
|
||||
],
|
||||
'-63158400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: -63158400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: -63158400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 6490.0,
|
||||
name: ['David'],
|
||||
time: -63158400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: -63158400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 8079.0,
|
||||
name: ['Michael'],
|
||||
time: -63158400000.0,
|
||||
},
|
||||
],
|
||||
'-31536000000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: -31536000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: -31536000000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 6563.0,
|
||||
name: ['David'],
|
||||
time: -31536000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: -31536000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 8245.0,
|
||||
name: ['Michael'],
|
||||
time: -31536000000.0,
|
||||
},
|
||||
],
|
||||
'0': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 0.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 0.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 6367.0,
|
||||
name: ['David'],
|
||||
time: 0.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 0.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 8186.0,
|
||||
name: ['Michael'],
|
||||
time: 0.0,
|
||||
},
|
||||
],
|
||||
'31536000000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 31536000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 31536000000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 31536000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 31536000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6825.0,
|
||||
name: ['Michael'],
|
||||
time: 31536000000.0,
|
||||
},
|
||||
],
|
||||
'63072000000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 63072000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 63072000000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 63072000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 6066.0,
|
||||
name: ['Jennifer'],
|
||||
time: 63072000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6337.0,
|
||||
name: ['Michael'],
|
||||
time: 63072000000.0,
|
||||
},
|
||||
],
|
||||
'94694400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 94694400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 94694400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 94694400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 94694400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 5877.0,
|
||||
name: ['Michael'],
|
||||
time: 94694400000.0,
|
||||
},
|
||||
],
|
||||
'126230400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 126230400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 126230400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 126230400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 5672.0,
|
||||
name: ['Jennifer'],
|
||||
time: 126230400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6058.0,
|
||||
name: ['Michael'],
|
||||
time: 126230400000.0,
|
||||
},
|
||||
],
|
||||
'157766400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 157766400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 157766400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 157766400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 157766400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6206.0,
|
||||
name: ['Michael'],
|
||||
time: 157766400000.0,
|
||||
},
|
||||
],
|
||||
'189302400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 189302400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 189302400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 189302400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 189302400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6178.0,
|
||||
name: ['Michael'],
|
||||
time: 189302400000.0,
|
||||
},
|
||||
],
|
||||
'220924800000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 220924800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 220924800000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 220924800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 220924800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6313.0,
|
||||
name: ['Michael'],
|
||||
time: 220924800000.0,
|
||||
},
|
||||
],
|
||||
'252460800000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 252460800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 252460800000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 252460800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 252460800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6489.0,
|
||||
name: ['Michael'],
|
||||
time: 252460800000.0,
|
||||
},
|
||||
],
|
||||
'283996800000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 283996800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 283996800000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 283996800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 283996800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6580.0,
|
||||
name: ['Michael'],
|
||||
time: 283996800000.0,
|
||||
},
|
||||
],
|
||||
'315532800000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 315532800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 315532800000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 315532800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 315532800000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6896.0,
|
||||
name: ['Michael'],
|
||||
time: 315532800000.0,
|
||||
},
|
||||
],
|
||||
'347155200000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 347155200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 347155200000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 347155200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 347155200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7142.0,
|
||||
name: ['Michael'],
|
||||
time: 347155200000.0,
|
||||
},
|
||||
],
|
||||
'378691200000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6093.0,
|
||||
name: ['Christopher'],
|
||||
time: 378691200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 378691200000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 378691200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 5811.0,
|
||||
name: ['Jennifer'],
|
||||
time: 378691200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7155.0,
|
||||
name: ['Michael'],
|
||||
time: 378691200000.0,
|
||||
},
|
||||
],
|
||||
'410227200000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6375.0,
|
||||
name: ['Christopher'],
|
||||
time: 410227200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 410227200000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 410227200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 5829.0,
|
||||
name: ['Jennifer'],
|
||||
time: 410227200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7386.0,
|
||||
name: ['Michael'],
|
||||
time: 410227200000.0,
|
||||
},
|
||||
],
|
||||
'441763200000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6509.0,
|
||||
name: ['Christopher'],
|
||||
time: 441763200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 441763200000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 441763200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 441763200000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7478.0,
|
||||
name: ['Michael'],
|
||||
time: 441763200000.0,
|
||||
},
|
||||
],
|
||||
'473385600000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6744.0,
|
||||
name: ['Christopher'],
|
||||
time: 473385600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 473385600000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 473385600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 473385600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7210.0,
|
||||
name: ['Michael'],
|
||||
time: 473385600000.0,
|
||||
},
|
||||
],
|
||||
'504921600000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6497.0,
|
||||
name: ['Christopher'],
|
||||
time: 504921600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 504921600000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 504921600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 504921600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7259.0,
|
||||
name: ['Michael'],
|
||||
time: 504921600000.0,
|
||||
},
|
||||
],
|
||||
'536457600000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6549.0,
|
||||
name: ['Christopher'],
|
||||
time: 536457600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 536457600000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 536457600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 536457600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7448.0,
|
||||
name: ['Michael'],
|
||||
time: 536457600000.0,
|
||||
},
|
||||
],
|
||||
'567993600000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6496.0,
|
||||
name: ['Christopher'],
|
||||
time: 567993600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 567993600000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 567993600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 567993600000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7748.0,
|
||||
name: ['Michael'],
|
||||
time: 567993600000.0,
|
||||
},
|
||||
],
|
||||
'599616000000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6526.0,
|
||||
name: ['Christopher'],
|
||||
time: 599616000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 599616000000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 599616000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 599616000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7851.0,
|
||||
name: ['Michael'],
|
||||
time: 599616000000.0,
|
||||
},
|
||||
],
|
||||
'631152000000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 6641.0,
|
||||
name: ['Christopher'],
|
||||
time: 631152000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 5760.0,
|
||||
name: ['Daniel'],
|
||||
time: 631152000000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 631152000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 631152000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 8233.0,
|
||||
name: ['Michael'],
|
||||
time: 631152000000.0,
|
||||
},
|
||||
],
|
||||
'662688000000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 5784.0,
|
||||
name: ['Christopher'],
|
||||
time: 662688000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 662688000000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 662688000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 662688000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 7579.0,
|
||||
name: ['Michael'],
|
||||
time: 662688000000.0,
|
||||
},
|
||||
],
|
||||
'694224000000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 694224000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 694224000000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 694224000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 694224000000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 6627.0,
|
||||
name: ['Michael'],
|
||||
time: 694224000000.0,
|
||||
},
|
||||
],
|
||||
'725846400000000000': [
|
||||
{
|
||||
key: ['Christopher'],
|
||||
value: 0,
|
||||
name: ['Christopher'],
|
||||
time: 725846400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Daniel'],
|
||||
value: 0,
|
||||
name: ['Daniel'],
|
||||
time: 725846400000.0,
|
||||
},
|
||||
{
|
||||
key: ['David'],
|
||||
value: 0,
|
||||
name: ['David'],
|
||||
time: 725846400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Jennifer'],
|
||||
value: 0,
|
||||
name: ['Jennifer'],
|
||||
time: 725846400000.0,
|
||||
},
|
||||
{
|
||||
key: ['Michael'],
|
||||
value: 5839.0,
|
||||
name: ['Michael'],
|
||||
time: 725846400000.0,
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
// Path Resolution: Override baseUrl to maintain correct path mappings from parent config
|
||||
// (e.g., "@apache-superset/core" -> "./packages/superset-core/src")
|
||||
"baseUrl": "../..",
|
||||
|
||||
// Directory Overrides: Parent config paths are relative to frontend root,
|
||||
// but packages need paths relative to their own directory
|
||||
"outDir": "lib",
|
||||
"rootDir": "src",
|
||||
"declarationDir": "lib"
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
|
||||
"exclude": [
|
||||
"src/**/*.js",
|
||||
"src/**/*.jsx",
|
||||
"src/**/*.test.*",
|
||||
"src/**/*.stories.*"],
|
||||
"references": [
|
||||
{ "path": "../../packages/superset-core" },
|
||||
{ "path": "../../packages/superset-ui-core" },
|
||||
{ "path": "../../packages/superset-ui-chart-controls" }
|
||||
]
|
||||
}
|
||||
@@ -1,113 +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.
|
||||
-->
|
||||
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [0.20.0](https://github.com/apache/superset/compare/v2021.41.0...v0.20.0) (2024-09-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- adding missing examples for bubble chart, bullet chart, calendar heatmap chart and country map chart in the gallery ([#22523](https://github.com/apache/superset/issues/22523)) ([839ec7c](https://github.com/apache/superset/commit/839ec7ceacc66c65928fd0ddead2b014db3d5563))
|
||||
- Adds the Deprecated label to Time-series Percent Change chart ([#30148](https://github.com/apache/superset/issues/30148)) ([5e42d7a](https://github.com/apache/superset/commit/5e42d7aed0d11c7aac91ab19088d2632e49da614))
|
||||
- **area chart legacy:** tool tip shows actual value rather than y axi… ([#23469](https://github.com/apache/superset/issues/23469)) ([db9ca20](https://github.com/apache/superset/commit/db9ca20737fecda8eee342b34d62d3b700ef3687))
|
||||
- **Dashboard:** Color inconsistency on refreshes and conflicts ([#27439](https://github.com/apache/superset/issues/27439)) ([313ee59](https://github.com/apache/superset/commit/313ee596f5435894f857d72be7269d5070c8c964))
|
||||
- **explore:** Fix chart standalone URL for report/thumbnail generation ([#20673](https://github.com/apache/superset/issues/20673)) ([84d4302](https://github.com/apache/superset/commit/84d4302628d18aa19c13cc5322e68abbc690ea4d))
|
||||
- **explore:** make SORT-Descending visible if Sort-by has value ([#17726](https://github.com/apache/superset/issues/17726)) ([d5768ab](https://github.com/apache/superset/commit/d5768ab649a70fd4f541ad4982498f622160b220))
|
||||
- **explore:** Prevent shared controls from checking feature flags outside React render ([#21315](https://github.com/apache/superset/issues/21315)) ([2285ebe](https://github.com/apache/superset/commit/2285ebe72ec4edded6d195052740b7f9f13d1f1b))
|
||||
- **legacy-chart:** corrupted raw chart data ([#24850](https://github.com/apache/superset/issues/24850)) ([1c5971d](https://github.com/apache/superset/commit/1c5971d3afb70a338444c41943ff90c3a9c03ec3))
|
||||
- Rename legacy line and area charts ([#28113](https://github.com/apache/superset/issues/28113)) ([b4c4ab7](https://github.com/apache/superset/commit/b4c4ab7790cbeb8d65ec7c1084482c21932e755b))
|
||||
- Reset sorting bar issue in Barchart ([#19371](https://github.com/apache/superset/issues/19371)) ([94e06c2](https://github.com/apache/superset/commit/94e06c2b6a1f782133bb9ef85a1d46ce7eacf9ba))
|
||||
- **storybook:** fix broken Storybook stories during development ([#29587](https://github.com/apache/superset/issues/29587)) ([462cda4](https://github.com/apache/superset/commit/462cda400baa00b3bcc4a7f8aded362ca55e18a5))
|
||||
- Tooltip of area chart shows undefined total ([#24916](https://github.com/apache/superset/issues/24916)) ([ec9e9a4](https://github.com/apache/superset/commit/ec9e9a46f2f092ce56d3ed5a8a9a3ea0214db88a))
|
||||
- warning of nth-child ([#23638](https://github.com/apache/superset/issues/23638)) ([16cc089](https://github.com/apache/superset/commit/16cc089b198dcdebc2422845aa08d18233c6b3a4))
|
||||
- Zero values on Dual Line axis bounds ([#23649](https://github.com/apache/superset/issues/23649)) ([d66e6e6](https://github.com/apache/superset/commit/d66e6e6d400db0fee35d73cd43e610cd1c491f4b))
|
||||
|
||||
### Features
|
||||
|
||||
- Adds the ECharts Bubble chart ([#22107](https://github.com/apache/superset/issues/22107)) ([c81c60c](https://github.com/apache/superset/commit/c81c60c91fbcb09dd63c05f050e18ee09ceebfd6))
|
||||
- apply standardized form data to tier 2 charts ([#20530](https://github.com/apache/superset/issues/20530)) ([de524bc](https://github.com/apache/superset/commit/de524bc59f011fd361dcdb7d35c2cb51f7eba442))
|
||||
- **chart & legend:** make to enable show legend by default ([#19927](https://github.com/apache/superset/issues/19927)) ([7b3d0f0](https://github.com/apache/superset/commit/7b3d0f040b050905f7d0901d0227f1cd6b761b56))
|
||||
- **explore:** Apply denormalization to tier 2 charts form data ([#20524](https://github.com/apache/superset/issues/20524)) ([e12ee59](https://github.com/apache/superset/commit/e12ee59b13822241dca8d8015f1222c477edd4f3))
|
||||
- **explore:** Denormalize form data in echarts, world map and nvd3 bar and line charts ([#20313](https://github.com/apache/superset/issues/20313)) ([354a899](https://github.com/apache/superset/commit/354a89950c4d001da3e107f60788cea873bd6bf6))
|
||||
- **explore:** improve UI in the control panel ([#19748](https://github.com/apache/superset/issues/19748)) ([e3a54aa](https://github.com/apache/superset/commit/e3a54aa3c15bdd0c970aa73f898288a408205c97))
|
||||
- **explore:** standardized controls for time pivot chart ([#21321](https://github.com/apache/superset/issues/21321)) ([79525df](https://github.com/apache/superset/commit/79525dfaf29b810af668e3b6c5a56cd866370d92))
|
||||
- **formatters:** Add custom d3-time-format locale ([#24263](https://github.com/apache/superset/issues/24263)) ([024cfd8](https://github.com/apache/superset/commit/024cfd86e408ec5f7ddf49a9e90908e2fb2e6b70))
|
||||
- improve color consistency (save all labels) ([#19038](https://github.com/apache/superset/issues/19038)) ([dc57508](https://github.com/apache/superset/commit/dc575080d7e43d40b1734bb8f44fdc291cb95b11))
|
||||
- **legacy-preset-chart-nvd3:** add richtooltip in nvd3 bar chart ([#17615](https://github.com/apache/superset/issues/17615)) ([72f3215](https://github.com/apache/superset/commit/72f3215ffc74ead33dba57196aeaf4e1db63fd6c))
|
||||
- Migrates Dual Line Chart to Mixed Chart ([#23910](https://github.com/apache/superset/issues/23910)) ([f5148ef](https://github.com/apache/superset/commit/f5148ef728ce649697c10fb7aa65982d7dd05638))
|
||||
- Removes the Multiple Line Charts ([#23933](https://github.com/apache/superset/issues/23933)) ([6ce8592](https://github.com/apache/superset/commit/6ce85921fc103ba0e93b437d473003e6f1b4a42b))
|
||||
- update time comparison choices (again) ([#17968](https://github.com/apache/superset/issues/17968)) ([05d9cde](https://github.com/apache/superset/commit/05d9cde203b99f8c63106446f0be58668cc9f0c9))
|
||||
- update time comparison choices (again) ([#22458](https://github.com/apache/superset/issues/22458)) ([9e81c3a](https://github.com/apache/superset/commit/9e81c3a1192a18226d505178d16e1e395917a719))
|
||||
- **viz picker:** Remove some tags, refactor Recommended section ([#27708](https://github.com/apache/superset/issues/27708)) ([c314999](https://github.com/apache/superset/commit/c3149994ac0d4392e0462421b62cd0c034142082))
|
||||
|
||||
# [0.19.0](https://github.com/apache/superset/compare/v2021.41.0...v0.19.0) (2024-09-07)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- adding missing examples for bubble chart, bullet chart, calendar heatmap chart and country map chart in the gallery ([#22523](https://github.com/apache/superset/issues/22523)) ([839ec7c](https://github.com/apache/superset/commit/839ec7ceacc66c65928fd0ddead2b014db3d5563))
|
||||
- Adds the Deprecated label to Time-series Percent Change chart ([#30148](https://github.com/apache/superset/issues/30148)) ([5e42d7a](https://github.com/apache/superset/commit/5e42d7aed0d11c7aac91ab19088d2632e49da614))
|
||||
- **area chart legacy:** tool tip shows actual value rather than y axi… ([#23469](https://github.com/apache/superset/issues/23469)) ([db9ca20](https://github.com/apache/superset/commit/db9ca20737fecda8eee342b34d62d3b700ef3687))
|
||||
- **Dashboard:** Color inconsistency on refreshes and conflicts ([#27439](https://github.com/apache/superset/issues/27439)) ([313ee59](https://github.com/apache/superset/commit/313ee596f5435894f857d72be7269d5070c8c964))
|
||||
- **explore:** Fix chart standalone URL for report/thumbnail generation ([#20673](https://github.com/apache/superset/issues/20673)) ([84d4302](https://github.com/apache/superset/commit/84d4302628d18aa19c13cc5322e68abbc690ea4d))
|
||||
- **explore:** make SORT-Descending visible if Sort-by has value ([#17726](https://github.com/apache/superset/issues/17726)) ([d5768ab](https://github.com/apache/superset/commit/d5768ab649a70fd4f541ad4982498f622160b220))
|
||||
- **explore:** Prevent shared controls from checking feature flags outside React render ([#21315](https://github.com/apache/superset/issues/21315)) ([2285ebe](https://github.com/apache/superset/commit/2285ebe72ec4edded6d195052740b7f9f13d1f1b))
|
||||
- **legacy-chart:** corrupted raw chart data ([#24850](https://github.com/apache/superset/issues/24850)) ([1c5971d](https://github.com/apache/superset/commit/1c5971d3afb70a338444c41943ff90c3a9c03ec3))
|
||||
- Rename legacy line and area charts ([#28113](https://github.com/apache/superset/issues/28113)) ([b4c4ab7](https://github.com/apache/superset/commit/b4c4ab7790cbeb8d65ec7c1084482c21932e755b))
|
||||
- Reset sorting bar issue in Barchart ([#19371](https://github.com/apache/superset/issues/19371)) ([94e06c2](https://github.com/apache/superset/commit/94e06c2b6a1f782133bb9ef85a1d46ce7eacf9ba))
|
||||
- **storybook:** fix broken Storybook stories during development ([#29587](https://github.com/apache/superset/issues/29587)) ([462cda4](https://github.com/apache/superset/commit/462cda400baa00b3bcc4a7f8aded362ca55e18a5))
|
||||
- Tooltip of area chart shows undefined total ([#24916](https://github.com/apache/superset/issues/24916)) ([ec9e9a4](https://github.com/apache/superset/commit/ec9e9a46f2f092ce56d3ed5a8a9a3ea0214db88a))
|
||||
- warning of nth-child ([#23638](https://github.com/apache/superset/issues/23638)) ([16cc089](https://github.com/apache/superset/commit/16cc089b198dcdebc2422845aa08d18233c6b3a4))
|
||||
- Zero values on Dual Line axis bounds ([#23649](https://github.com/apache/superset/issues/23649)) ([d66e6e6](https://github.com/apache/superset/commit/d66e6e6d400db0fee35d73cd43e610cd1c491f4b))
|
||||
|
||||
### Features
|
||||
|
||||
- Adds the ECharts Bubble chart ([#22107](https://github.com/apache/superset/issues/22107)) ([c81c60c](https://github.com/apache/superset/commit/c81c60c91fbcb09dd63c05f050e18ee09ceebfd6))
|
||||
- apply standardized form data to tier 2 charts ([#20530](https://github.com/apache/superset/issues/20530)) ([de524bc](https://github.com/apache/superset/commit/de524bc59f011fd361dcdb7d35c2cb51f7eba442))
|
||||
- **chart & legend:** make to enable show legend by default ([#19927](https://github.com/apache/superset/issues/19927)) ([7b3d0f0](https://github.com/apache/superset/commit/7b3d0f040b050905f7d0901d0227f1cd6b761b56))
|
||||
- **explore:** Apply denormalization to tier 2 charts form data ([#20524](https://github.com/apache/superset/issues/20524)) ([e12ee59](https://github.com/apache/superset/commit/e12ee59b13822241dca8d8015f1222c477edd4f3))
|
||||
- **explore:** Denormalize form data in echarts, world map and nvd3 bar and line charts ([#20313](https://github.com/apache/superset/issues/20313)) ([354a899](https://github.com/apache/superset/commit/354a89950c4d001da3e107f60788cea873bd6bf6))
|
||||
- **explore:** improve UI in the control panel ([#19748](https://github.com/apache/superset/issues/19748)) ([e3a54aa](https://github.com/apache/superset/commit/e3a54aa3c15bdd0c970aa73f898288a408205c97))
|
||||
- **explore:** standardized controls for time pivot chart ([#21321](https://github.com/apache/superset/issues/21321)) ([79525df](https://github.com/apache/superset/commit/79525dfaf29b810af668e3b6c5a56cd866370d92))
|
||||
- **formatters:** Add custom d3-time-format locale ([#24263](https://github.com/apache/superset/issues/24263)) ([024cfd8](https://github.com/apache/superset/commit/024cfd86e408ec5f7ddf49a9e90908e2fb2e6b70))
|
||||
- improve color consistency (save all labels) ([#19038](https://github.com/apache/superset/issues/19038)) ([dc57508](https://github.com/apache/superset/commit/dc575080d7e43d40b1734bb8f44fdc291cb95b11))
|
||||
- **legacy-preset-chart-nvd3:** add richtooltip in nvd3 bar chart ([#17615](https://github.com/apache/superset/issues/17615)) ([72f3215](https://github.com/apache/superset/commit/72f3215ffc74ead33dba57196aeaf4e1db63fd6c))
|
||||
- Migrates Dual Line Chart to Mixed Chart ([#23910](https://github.com/apache/superset/issues/23910)) ([f5148ef](https://github.com/apache/superset/commit/f5148ef728ce649697c10fb7aa65982d7dd05638))
|
||||
- Removes the Multiple Line Charts ([#23933](https://github.com/apache/superset/issues/23933)) ([6ce8592](https://github.com/apache/superset/commit/6ce85921fc103ba0e93b437d473003e6f1b4a42b))
|
||||
- update time comparison choices (again) ([#17968](https://github.com/apache/superset/issues/17968)) ([05d9cde](https://github.com/apache/superset/commit/05d9cde203b99f8c63106446f0be58668cc9f0c9))
|
||||
- update time comparison choices (again) ([#22458](https://github.com/apache/superset/issues/22458)) ([9e81c3a](https://github.com/apache/superset/commit/9e81c3a1192a18226d505178d16e1e395917a719))
|
||||
- **viz picker:** Remove some tags, refactor Recommended section ([#27708](https://github.com/apache/superset/issues/27708)) ([c314999](https://github.com/apache/superset/commit/c3149994ac0d4392e0462421b62cd0c034142082))
|
||||
|
||||
# [0.18.0](https://github.com/apache-superset/superset-ui/compare/v0.17.87...v0.18.0) (2021-08-30)
|
||||
|
||||
**Note:** Version bump only for package @superset-ui/legacy-preset-chart-nvd3
|
||||
|
||||
## [0.17.63](https://github.com/apache-superset/superset-ui/compare/v0.17.62...v0.17.63) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package @superset-ui/legacy-preset-chart-nvd3
|
||||
|
||||
## [0.17.62](https://github.com/apache-superset/superset-ui/compare/v0.17.61...v0.17.62) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package @superset-ui/legacy-preset-chart-nvd3
|
||||
|
||||
## [0.17.61](https://github.com/apache-superset/superset-ui/compare/v0.17.60...v0.17.61) (2021-07-02)
|
||||
|
||||
**Note:** Version bump only for package @superset-ui/legacy-preset-chart-nvd3
|
||||
@@ -1,64 +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.
|
||||
-->
|
||||
|
||||
## @superset-ui/legacy-preset-chart-nvd3
|
||||
|
||||
[](https://www.npmjs.com/package/@superset-ui/legacy-preset-chart-nvd3)
|
||||
[](https://libraries.io/npm/@superset-ui%2Flegacy-preset-chart-nvd3)
|
||||
|
||||
This plugin provides Big Number for Superset.
|
||||
|
||||
### Usage
|
||||
|
||||
Import the preset and register. This will register all the chart plugins under nvd3.
|
||||
|
||||
```js
|
||||
import { NVD3ChartPreset } from '@superset-ui/legacy-preset-chart-nvd3';
|
||||
|
||||
new NVD3ChartPreset().register();
|
||||
```
|
||||
|
||||
or register charts one by one. Configure `key`, which can be any `string`, and register the plugin.
|
||||
This `key` will be used to lookup this chart throughout the app.
|
||||
|
||||
```js
|
||||
import {
|
||||
AreaChartPlugin,
|
||||
LineChartPlugin,
|
||||
} from '@superset-ui/legacy-preset-chart-nvd3';
|
||||
|
||||
new AreaChartPlugin().configure({ key: 'area' }).register();
|
||||
new LineChartPlugin().configure({ key: 'line' }).register();
|
||||
```
|
||||
|
||||
Then use it via `SuperChart`. See
|
||||
[storybook](https://apache-superset.github.io/superset-ui-plugins/?selectedKind=plugin-chart-nvd3)
|
||||
for more details.
|
||||
|
||||
```js
|
||||
<SuperChart
|
||||
chartType="line"
|
||||
width={600}
|
||||
height={600}
|
||||
formData={...}
|
||||
queriesData={[{
|
||||
data: {...},
|
||||
}]}
|
||||
/>
|
||||
```
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"name": "@superset-ui/legacy-preset-chart-nvd3",
|
||||
"version": "0.20.3",
|
||||
"description": "Superset Legacy Chart - NVD3",
|
||||
"keywords": [
|
||||
"superset"
|
||||
],
|
||||
"homepage": "https://github.com/apache/superset/tree/master/superset-frontend/plugins/legacy-preset-chart-nvd3#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/superset/issues"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"author": "Superset",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/superset.git",
|
||||
"directory": "superset-frontend/packages/legacy-preset-chart-nvd3"
|
||||
},
|
||||
"files": [
|
||||
"esm",
|
||||
"lib"
|
||||
],
|
||||
"sideEffects": [
|
||||
"*.css"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"module": "esm/index.js",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"d3": "^3.5.17",
|
||||
"d3-tip": "^0.9.1",
|
||||
"dompurify": "^3.4.12",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -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,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,51 +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 } 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('KPI'),
|
||||
credits: ['http://nvd3.org'],
|
||||
description: t(
|
||||
'Showcases the progress of a single metric against a given target. The higher the fill, the closer the metric is to the target.',
|
||||
),
|
||||
exampleGallery: [{ url: example, urlDark: exampleDark }],
|
||||
name: t('Bullet Chart'),
|
||||
tags: [t('Business'), t('Legacy'), t('Report'), t('nvd3')],
|
||||
thumbnail,
|
||||
thumbnailDark,
|
||||
useLegacyApi: true,
|
||||
});
|
||||
|
||||
export default class BulletChartPlugin extends ChartPlugin {
|
||||
constructor() {
|
||||
super({
|
||||
loadChart: () => import('../ReactNVD3'),
|
||||
metadata,
|
||||
transformProps,
|
||||
controlPanel,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,87 +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 { BulletChartPlugin } from '@superset-ui/legacy-preset-chart-nvd3';
|
||||
import { dummyDatasource, withResizableChartDemo } from '@storybook-shared';
|
||||
import data from './data';
|
||||
|
||||
new BulletChartPlugin().configure({ key: VizType.Bullet }).register();
|
||||
|
||||
export default {
|
||||
title: 'Legacy Chart Plugins/legacy-preset-chart-nvd3/Bullet',
|
||||
decorators: [withResizableChartDemo],
|
||||
args: {
|
||||
ranges: '0, 50, 75, 100',
|
||||
rangeLabels: 'Low, Medium, High',
|
||||
markers: '65',
|
||||
markerLabels: 'Target',
|
||||
},
|
||||
argTypes: {
|
||||
ranges: {
|
||||
control: 'text',
|
||||
description: 'Comma-separated range values',
|
||||
},
|
||||
rangeLabels: {
|
||||
control: 'text',
|
||||
description: 'Comma-separated range labels',
|
||||
},
|
||||
markers: {
|
||||
control: 'text',
|
||||
description: 'Comma-separated marker values',
|
||||
},
|
||||
markerLabels: {
|
||||
control: 'text',
|
||||
description: 'Comma-separated marker labels',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Basic = ({
|
||||
ranges,
|
||||
rangeLabels,
|
||||
markers,
|
||||
markerLabels,
|
||||
width,
|
||||
height,
|
||||
}: {
|
||||
ranges: string;
|
||||
rangeLabels: string;
|
||||
markers: string;
|
||||
markerLabels: string;
|
||||
width: number;
|
||||
height: number;
|
||||
}) => (
|
||||
<SuperChart
|
||||
chartType={VizType.Bullet}
|
||||
width={width}
|
||||
height={height}
|
||||
datasource={dummyDatasource}
|
||||
queriesData={[{ data }]}
|
||||
formData={{
|
||||
marker_labels: markerLabels,
|
||||
marker_line_labels: '',
|
||||
marker_lines: '',
|
||||
markers,
|
||||
range_labels: rangeLabels,
|
||||
ranges,
|
||||
viz_type: VizType.Bullet,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -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,549 +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/jsx-key */
|
||||
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
import {
|
||||
ControlPanelSectionConfig,
|
||||
ControlSubSectionHeader,
|
||||
CustomControlItem,
|
||||
D3_TIME_FORMAT_OPTIONS,
|
||||
D3_FORMAT_DOCS,
|
||||
D3_FORMAT_OPTIONS,
|
||||
DEFAULT_TIME_FORMAT,
|
||||
} from '@superset-ui/chart-controls';
|
||||
|
||||
/*
|
||||
Plugins in question:
|
||||
|
||||
AreaChartPlugin,
|
||||
BarChartPlugin,
|
||||
BubbleChartPlugin,
|
||||
BulletChartPlugin,
|
||||
CompareChartPlugin,
|
||||
DistBarChartPlugin,
|
||||
DualLineChartPlugin,
|
||||
LineChartPlugin,
|
||||
LineMultiChartPlugin,
|
||||
PieChartPlugin,
|
||||
TimePivotChartPlugin,
|
||||
*/
|
||||
|
||||
export const yAxis2Format: CustomControlItem = {
|
||||
name: 'y_axis_2_format',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('Right Axis Format'),
|
||||
default: 'SMART_NUMBER',
|
||||
choices: D3_FORMAT_OPTIONS,
|
||||
description: D3_FORMAT_DOCS,
|
||||
},
|
||||
};
|
||||
|
||||
export const showMarkers: CustomControlItem = {
|
||||
name: 'show_markers',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Show Markers'),
|
||||
renderTrigger: true,
|
||||
default: false,
|
||||
description: t('Show data points as circle markers on the lines'),
|
||||
},
|
||||
};
|
||||
|
||||
export const leftMargin: CustomControlItem = {
|
||||
name: 'left_margin',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
clearable: false,
|
||||
label: t('Left Margin'),
|
||||
choices: [
|
||||
['auto', t('auto')],
|
||||
[50, '50'],
|
||||
[75, '75'],
|
||||
[100, '100'],
|
||||
[125, '125'],
|
||||
[150, '150'],
|
||||
[200, '200'],
|
||||
],
|
||||
default: 'auto',
|
||||
renderTrigger: true,
|
||||
description: t(
|
||||
'Left margin, in pixels, allowing for more room for axis labels',
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const yAxisShowMinmax: CustomControlItem = {
|
||||
name: 'y_axis_showminmax',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Y bounds'),
|
||||
renderTrigger: true,
|
||||
default: false,
|
||||
description: t('Whether to display the min and max values of the Y-axis'),
|
||||
},
|
||||
};
|
||||
|
||||
export const yAxis2ShowMinmax: CustomControlItem = {
|
||||
name: 'y_axis_2_showminmax',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Y 2 bounds'),
|
||||
renderTrigger: true,
|
||||
default: false,
|
||||
description: t('Whether to display the min and max values of the Y-axis'),
|
||||
},
|
||||
};
|
||||
|
||||
export const lineInterpolation: CustomControlItem = {
|
||||
name: 'line_interpolation',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Line Style'),
|
||||
renderTrigger: true,
|
||||
choices: [
|
||||
['linear', t('linear')],
|
||||
['basis', t('basis')],
|
||||
['cardinal', t('cardinal')],
|
||||
['monotone', t('monotone')],
|
||||
['step-before', t('step-before')],
|
||||
['step-after', t('step-after')],
|
||||
],
|
||||
default: 'linear',
|
||||
description: t('Line interpolation as defined by d3.js'),
|
||||
},
|
||||
};
|
||||
|
||||
export const showBrush: CustomControlItem = {
|
||||
name: 'show_brush',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Show Range Filter'),
|
||||
renderTrigger: true,
|
||||
clearable: false,
|
||||
default: 'auto',
|
||||
choices: [
|
||||
['yes', t('Yes')],
|
||||
['no', t('No')],
|
||||
['auto', t('Auto')],
|
||||
],
|
||||
description: t('Whether to display the time range interactive selector'),
|
||||
},
|
||||
};
|
||||
|
||||
export const showLegend: CustomControlItem = {
|
||||
name: 'show_legend',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Legend'),
|
||||
renderTrigger: true,
|
||||
default: true,
|
||||
description: t('Whether to display the legend (toggles)'),
|
||||
},
|
||||
};
|
||||
|
||||
export const showControls: CustomControlItem = {
|
||||
name: 'show_controls',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Extra Controls'),
|
||||
renderTrigger: true,
|
||||
default: false,
|
||||
description: t(
|
||||
'Whether to show extra controls or not. Extra controls ' +
|
||||
'include things like making multiBar charts stacked ' +
|
||||
'or side by side.',
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const xAxisLabel: CustomControlItem = {
|
||||
name: 'x_axis_label',
|
||||
config: {
|
||||
type: 'TextControl',
|
||||
label: t('X Axis Label'),
|
||||
renderTrigger: true,
|
||||
default: '',
|
||||
},
|
||||
};
|
||||
|
||||
export const bottomMargin: CustomControlItem = {
|
||||
name: 'bottom_margin',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
clearable: false,
|
||||
freeForm: true,
|
||||
label: t('Bottom Margin'),
|
||||
choices: [
|
||||
['auto', t('auto')],
|
||||
[50, '50'],
|
||||
[75, '75'],
|
||||
[100, '100'],
|
||||
[125, '125'],
|
||||
[150, '150'],
|
||||
[200, '200'],
|
||||
],
|
||||
default: 'auto',
|
||||
renderTrigger: true,
|
||||
description: t(
|
||||
'Bottom margin, in pixels, allowing for more room for axis labels',
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const xTicksLayout: CustomControlItem = {
|
||||
name: 'x_ticks_layout',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('X Tick Layout'),
|
||||
choices: [
|
||||
['auto', t('auto')],
|
||||
['flat', t('flat')],
|
||||
['45°', '45°'],
|
||||
['staggered', t('staggered')],
|
||||
],
|
||||
default: 'auto',
|
||||
clearable: false,
|
||||
renderTrigger: true,
|
||||
description: t('The way the ticks are laid out on the X-axis'),
|
||||
},
|
||||
};
|
||||
|
||||
export const xAxisFormat: CustomControlItem = {
|
||||
name: 'x_axis_format',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('X Axis Format'),
|
||||
renderTrigger: true,
|
||||
choices: D3_TIME_FORMAT_OPTIONS,
|
||||
default: DEFAULT_TIME_FORMAT,
|
||||
description: D3_FORMAT_DOCS,
|
||||
},
|
||||
};
|
||||
|
||||
export const yLogScale: CustomControlItem = {
|
||||
name: 'y_log_scale',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Y Log Scale'),
|
||||
default: false,
|
||||
renderTrigger: true,
|
||||
description: t('Use a log scale for the Y-axis'),
|
||||
},
|
||||
};
|
||||
|
||||
export const yAxisBounds: CustomControlItem = {
|
||||
name: 'y_axis_bounds',
|
||||
config: {
|
||||
type: 'BoundsControl',
|
||||
label: t('Y Axis Bounds'),
|
||||
renderTrigger: true,
|
||||
default: [null, null],
|
||||
description: t(
|
||||
'Bounds for the Y-axis. When left empty, the bounds are ' +
|
||||
'dynamically defined based on the min/max of the data. Note that ' +
|
||||
"this feature will only expand the axis range. It won't " +
|
||||
"narrow the data's extent.",
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const yAxis2Bounds: CustomControlItem = {
|
||||
name: 'y_axis_2_bounds',
|
||||
config: {
|
||||
type: 'BoundsControl',
|
||||
label: t('Y Axis 2 Bounds'),
|
||||
renderTrigger: true,
|
||||
default: [null, null],
|
||||
description: t(
|
||||
'Bounds for the Y-axis. When left empty, the bounds are ' +
|
||||
'dynamically defined based on the min/max of the data. Note that ' +
|
||||
"this feature will only expand the axis range. It won't " +
|
||||
"narrow the data's extent.",
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const xAxisShowMinmax: CustomControlItem = {
|
||||
name: 'x_axis_showminmax',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('X bounds'),
|
||||
renderTrigger: true,
|
||||
default: false,
|
||||
description: t('Whether to display the min and max values of the X-axis'),
|
||||
},
|
||||
};
|
||||
|
||||
export const richTooltip: CustomControlItem = {
|
||||
name: 'rich_tooltip',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Rich Tooltip'),
|
||||
renderTrigger: true,
|
||||
default: true,
|
||||
description: t(
|
||||
'The rich tooltip shows a list of all series for that point in time',
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const showBarValue: CustomControlItem = {
|
||||
name: 'show_bar_value',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Bar Values'),
|
||||
default: false,
|
||||
renderTrigger: true,
|
||||
description: t('Show the value on top of the bar'),
|
||||
},
|
||||
};
|
||||
|
||||
export const barStacked: CustomControlItem = {
|
||||
name: 'bar_stacked',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Stacked Bars'),
|
||||
renderTrigger: true,
|
||||
default: false,
|
||||
description: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const reduceXTicks: CustomControlItem = {
|
||||
name: 'reduce_x_ticks',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Reduce X ticks'),
|
||||
renderTrigger: true,
|
||||
default: false,
|
||||
description: t(
|
||||
'Reduces the number of X-axis ticks to be rendered. ' +
|
||||
'If true, the x-axis will not overflow and labels may be ' +
|
||||
'missing. If false, a minimum width will be applied ' +
|
||||
'to columns and the width may overflow into an ' +
|
||||
'horizontal scroll.',
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const yAxisLabel: CustomControlItem = {
|
||||
name: 'y_axis_label',
|
||||
config: {
|
||||
type: 'TextControl',
|
||||
label: t('Y Axis Label'),
|
||||
renderTrigger: true,
|
||||
default: '',
|
||||
},
|
||||
};
|
||||
|
||||
export const timeSeriesSection: ControlPanelSectionConfig[] = [
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
['metrics'],
|
||||
['adhoc_filters'],
|
||||
['groupby'],
|
||||
['limit'],
|
||||
['timeseries_limit_metric'],
|
||||
['order_desc'],
|
||||
[
|
||||
{
|
||||
name: 'contribution',
|
||||
config: {
|
||||
type: 'CheckboxControl',
|
||||
label: t('Contribution'),
|
||||
default: false,
|
||||
description: t('Compute the contribution to the total'),
|
||||
},
|
||||
},
|
||||
],
|
||||
['row_limit', null],
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('Advanced Analytics'),
|
||||
tabOverride: 'data',
|
||||
description: t(
|
||||
'This section contains options ' +
|
||||
'that allow for advanced analytical post processing ' +
|
||||
'of query results',
|
||||
),
|
||||
controlSetRows: [
|
||||
[
|
||||
<ControlSubSectionHeader>
|
||||
{t('Rolling Window')}
|
||||
</ControlSubSectionHeader>,
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'rolling_type',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Rolling Function'),
|
||||
default: 'None',
|
||||
choices: [
|
||||
['None', t('None')],
|
||||
['mean', t('mean')],
|
||||
['sum', t('sum')],
|
||||
['std', t('std')],
|
||||
['cumsum', t('cumsum')],
|
||||
],
|
||||
description: t(
|
||||
'Defines a rolling window function to apply, works along ' +
|
||||
'with the [Periods] text box',
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'rolling_periods',
|
||||
config: {
|
||||
type: 'TextControl',
|
||||
label: t('Periods'),
|
||||
isInt: true,
|
||||
description: t(
|
||||
'Defines the size of the rolling window function, ' +
|
||||
'relative to the time granularity selected',
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'min_periods',
|
||||
config: {
|
||||
type: 'TextControl',
|
||||
label: t('Min Periods'),
|
||||
isInt: true,
|
||||
description: t(
|
||||
'The minimum number of rolling periods required to show ' +
|
||||
'a value. For instance if you do a cumulative sum on 7 days ' +
|
||||
'you may want your "Min Period" to be 7, so that all data points ' +
|
||||
'shown are the total of 7 periods. This will hide the "ramp up" ' +
|
||||
'taking place over the first 7 periods',
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
<ControlSubSectionHeader>
|
||||
{t('Time Comparison')}
|
||||
</ControlSubSectionHeader>,
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'time_compare',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
multi: true,
|
||||
freeForm: true,
|
||||
label: t('Time Shift'),
|
||||
choices: [
|
||||
['1 day', t('1 day')],
|
||||
['1 week', t('1 week')],
|
||||
['28 days', t('28 days')],
|
||||
['30 days', t('30 days')],
|
||||
['52 weeks', t('52 weeks')],
|
||||
['1 year', t('1 year')],
|
||||
['104 weeks', t('104 weeks')],
|
||||
['2 years', t('2 years')],
|
||||
['156 weeks', t('156 weeks')],
|
||||
['3 years', t('3 years')],
|
||||
],
|
||||
description: t(
|
||||
'Overlay one or more timeseries from a ' +
|
||||
'relative time period. Expects relative time deltas ' +
|
||||
'in natural language (example: 24 hours, 7 days, ' +
|
||||
'52 weeks, 365 days). Free text is supported.',
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'comparison_type',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Calculation type'),
|
||||
default: 'values',
|
||||
choices: [
|
||||
['values', t('Actual Values')],
|
||||
['absolute', t('Difference')],
|
||||
['percentage', t('Percentage change')],
|
||||
['ratio', t('Ratio')],
|
||||
],
|
||||
description: t(
|
||||
'How to display time shifts: as individual lines; as the ' +
|
||||
'difference between the main time series and each time shift; ' +
|
||||
'as the percentage change; or as the ratio between series and time shifts.',
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
[<ControlSubSectionHeader>{t('Resample')}</ControlSubSectionHeader>],
|
||||
[
|
||||
{
|
||||
name: 'resample_rule',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('Rule'),
|
||||
default: null,
|
||||
choices: [
|
||||
['1T', t('1T')],
|
||||
['1H', t('1H')],
|
||||
['1D', t('1D')],
|
||||
['7D', t('7D')],
|
||||
['1M', t('1M')],
|
||||
['1AS', t('1AS')],
|
||||
],
|
||||
description: t('Pandas resample rule'),
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'resample_method',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
freeForm: true,
|
||||
label: t('Method'),
|
||||
default: null,
|
||||
choices: [
|
||||
['asfreq', t('asfreq')],
|
||||
['bfill', t('bfill')],
|
||||
['ffill', t('ffill')],
|
||||
['median', t('median')],
|
||||
['mean', t('mean')],
|
||||
['sum', t('sum')],
|
||||
],
|
||||
description: t('Pandas resample method'),
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -1,82 +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/sort-prop-types */
|
||||
import PropTypes from 'prop-types';
|
||||
import { ANNOTATION_TYPES } from './vendor/superset/AnnotationTypes';
|
||||
|
||||
export const numberOrAutoType = PropTypes.oneOfType([
|
||||
PropTypes.number,
|
||||
PropTypes.oneOf(['auto']),
|
||||
]);
|
||||
|
||||
export const stringOrObjectWithLabelType = PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.shape({
|
||||
label: PropTypes.string,
|
||||
}),
|
||||
]);
|
||||
|
||||
export const rgbObjectType = PropTypes.shape({
|
||||
r: PropTypes.number.isRequired,
|
||||
g: PropTypes.number.isRequired,
|
||||
b: PropTypes.number.isRequired,
|
||||
});
|
||||
|
||||
export const numericXYType = PropTypes.shape({
|
||||
x: PropTypes.number,
|
||||
y: PropTypes.number,
|
||||
});
|
||||
|
||||
export const categoryAndValueXYType = PropTypes.shape({
|
||||
x: PropTypes.string,
|
||||
y: PropTypes.number,
|
||||
});
|
||||
|
||||
export const boxPlotValueType = PropTypes.shape({
|
||||
outliers: PropTypes.arrayOf(PropTypes.number),
|
||||
Q1: PropTypes.number,
|
||||
Q2: PropTypes.number,
|
||||
Q3: PropTypes.number,
|
||||
whisker_high: PropTypes.number,
|
||||
whisker_low: PropTypes.number,
|
||||
});
|
||||
|
||||
export const bulletDataType = PropTypes.shape({
|
||||
markerLabels: PropTypes.arrayOf(PropTypes.string),
|
||||
markerLineLabels: PropTypes.arrayOf(PropTypes.string),
|
||||
markerLines: PropTypes.arrayOf(PropTypes.number),
|
||||
markers: PropTypes.arrayOf(PropTypes.number),
|
||||
measures: PropTypes.arrayOf(PropTypes.number),
|
||||
rangeLabels: PropTypes.arrayOf(PropTypes.string),
|
||||
ranges: PropTypes.arrayOf(PropTypes.number),
|
||||
});
|
||||
|
||||
export const annotationLayerType = PropTypes.shape({
|
||||
annotationType: PropTypes.oneOf(Object.keys(ANNOTATION_TYPES)),
|
||||
color: PropTypes.string,
|
||||
hideLine: PropTypes.bool,
|
||||
name: PropTypes.string,
|
||||
opacity: PropTypes.string,
|
||||
show: PropTypes.bool,
|
||||
showMarkers: PropTypes.bool,
|
||||
sourceType: PropTypes.string,
|
||||
style: PropTypes.string,
|
||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
width: PropTypes.number,
|
||||
});
|
||||
@@ -1,189 +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.
|
||||
*/
|
||||
// @ts-nocheck -- legacy reactified component with untyped `this` context from reactify callbacks
|
||||
import { reactify } from '@superset-ui/core';
|
||||
import { styled } from '@apache-superset/core/theme';
|
||||
import PropTypes from 'prop-types';
|
||||
import Component from './NVD3Vis';
|
||||
import { hideTooltips, removeTooltip } from './utils';
|
||||
|
||||
function componentWillUnmount() {
|
||||
const { id } = this.props;
|
||||
if (id !== null && id !== undefined) {
|
||||
removeTooltip(id);
|
||||
} else {
|
||||
hideTooltips(true);
|
||||
}
|
||||
}
|
||||
|
||||
const ReactNVD3 = reactify(Component, { componentWillUnmount });
|
||||
|
||||
const NVD3 = ({ className, ...otherProps }) => (
|
||||
<div className={className}>
|
||||
<ReactNVD3 {...otherProps} />
|
||||
</div>
|
||||
);
|
||||
|
||||
NVD3.propTypes = {
|
||||
className: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default styled(NVD3)`
|
||||
.superset-legacy-chart-nvd3-dist-bar,
|
||||
.superset-legacy-chart-nvd3-bar {
|
||||
overflow-x: auto !important;
|
||||
svg {
|
||||
&.nvd3-svg {
|
||||
width: auto;
|
||||
font-size: ${({ theme }) => theme.fontSize};
|
||||
}
|
||||
}
|
||||
}
|
||||
.superset-legacy-chart-nvd3 {
|
||||
nv-x text {
|
||||
font-size: ${({ theme }) => theme.fontSize};
|
||||
}
|
||||
g.superset path {
|
||||
stroke-dasharray: 5, 5;
|
||||
}
|
||||
.nvtooltip {
|
||||
table td {
|
||||
font-size: @font-size-s !important;
|
||||
}
|
||||
}
|
||||
.nvtooltip tr.highlight td {
|
||||
font-weight: ${({ theme }) => theme.fontWeightStrong};
|
||||
font-size: ${({ theme }) => theme.fontSize}px !important;
|
||||
}
|
||||
text.nv-axislabel {
|
||||
font-size: ${({ theme }) => theme.fontSize} !important;
|
||||
}
|
||||
g.nv-axis text {
|
||||
fill: ${({ theme }) => theme.colorText};
|
||||
}
|
||||
g.nv-series text {
|
||||
fill: ${({ theme }) => theme.colorText};
|
||||
}
|
||||
g.solid path,
|
||||
line.solid {
|
||||
stroke-dasharray: unset;
|
||||
}
|
||||
g.dashed path,
|
||||
line.dashed {
|
||||
stroke-dasharray: 5, 5;
|
||||
}
|
||||
g.longDashed path,
|
||||
line.dotted {
|
||||
stroke-dasharray: 1, 1;
|
||||
}
|
||||
|
||||
g.opacityLow path,
|
||||
line.opacityLow {
|
||||
stroke-opacity: 0.2;
|
||||
}
|
||||
|
||||
g.opacityMedium path,
|
||||
line.opacityMedium {
|
||||
stroke-opacity: 0.5;
|
||||
}
|
||||
g.opacityHigh path,
|
||||
line.opacityHigh {
|
||||
stroke-opacity: 0.8;
|
||||
}
|
||||
g.time-shift-0 path,
|
||||
line.time-shift-0 {
|
||||
stroke-dasharray: 5, 5;
|
||||
}
|
||||
g.time-shift-1 path,
|
||||
line.time-shift-1 {
|
||||
stroke-dasharray: 1, 5;
|
||||
}
|
||||
g.time-shift-2 path,
|
||||
line.time-shift-3 {
|
||||
stroke-dasharray: 5, 1;
|
||||
}
|
||||
g.time-shift-3 path,
|
||||
line.time-shift-3 {
|
||||
stroke-dasharray: 5, 1;
|
||||
}
|
||||
g.time-shift-4 path,
|
||||
line.time-shift-4 {
|
||||
stroke-dasharray: 5, 10;
|
||||
}
|
||||
g.time-shift-5 path,
|
||||
line.time-shift-5 {
|
||||
stroke-dasharray: 0.9;
|
||||
}
|
||||
g.time-shift-6 path,
|
||||
line.time-shift-6 {
|
||||
stroke-dasharray: 15, 10, 5;
|
||||
}
|
||||
g.time-shift-7 path,
|
||||
line.time-shift-7 {
|
||||
stroke-dasharray: 15, 10, 5, 10;
|
||||
}
|
||||
g.time-shift-8 path,
|
||||
line.time-shift-8 {
|
||||
stroke-dasharray: 15, 10, 5, 10, 15;
|
||||
}
|
||||
g.time-shift-9 path,
|
||||
line.time-shift-9 {
|
||||
stroke-dasharray: 5, 5, 1, 5;
|
||||
}
|
||||
.nv-noData.body {
|
||||
font-size: ${({ theme }) => theme.fontSize};
|
||||
font-weight: ${({ theme }) => theme.fontWeightNormal};
|
||||
}
|
||||
}
|
||||
.superset-legacy-chart-nvd3-tr-highlight {
|
||||
border-top: 1px solid;
|
||||
border-bottom: 1px solid;
|
||||
font-weight: ${({ theme }) => theme.fontWeightStrong};
|
||||
}
|
||||
.superset-legacy-chart-nvd3-tr-total {
|
||||
font-weight: ${({ theme }) => theme.fontWeightStrong};
|
||||
}
|
||||
.nvtooltip {
|
||||
.tooltip-header {
|
||||
white-space: nowrap;
|
||||
font-weight: ${({ theme }) => theme.fontWeightStrong};
|
||||
}
|
||||
tbody tr:not(.tooltip-header) td:nth-of-type(2) {
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
.d3-tip.nv-event-annotation-layer-table,
|
||||
.d3-tip.nv-event-annotation-layer-NATIVE {
|
||||
width: 200px;
|
||||
border-radius: 2px;
|
||||
background-color: ${({ theme }) => theme.colorBgContainer};
|
||||
fill-opacity: 0.6;
|
||||
margin: ${({ theme }) => theme.sizeUnit * 2}px;
|
||||
padding: ${({ theme }) => theme.sizeUnit * 2}px;
|
||||
color: ${({ theme }) => theme.colorTextLightSolid};
|
||||
&:after {
|
||||
content: '\\25BC';
|
||||
font-size: ${({ theme }) => theme.fontSize};
|
||||
color: ${({ theme }) => theme.colorText};
|
||||
position: absolute;
|
||||
bottom: -14px;
|
||||
left: 94px;
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -1,134 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
import { QueryFormData } from '@superset-ui/core';
|
||||
import {
|
||||
ControlPanelConfig,
|
||||
D3_FORMAT_OPTIONS,
|
||||
getStandardizedControls,
|
||||
sections,
|
||||
} from '@superset-ui/chart-controls';
|
||||
import {
|
||||
lineInterpolation,
|
||||
showLegend,
|
||||
xAxisLabel,
|
||||
bottomMargin,
|
||||
xAxisFormat,
|
||||
yLogScale,
|
||||
yAxisBounds,
|
||||
xAxisShowMinmax,
|
||||
yAxisShowMinmax,
|
||||
yAxisLabel,
|
||||
leftMargin,
|
||||
} from '../NVD3Controls';
|
||||
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
['metric'],
|
||||
['adhoc_filters'],
|
||||
[
|
||||
{
|
||||
name: 'freq',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Frequency'),
|
||||
default: 'W-MON',
|
||||
freeForm: true,
|
||||
clearable: false,
|
||||
choices: [
|
||||
['AS', t('Year (freq=AS)')],
|
||||
['52W-MON', t('52 weeks starting Monday (freq=52W-MON)')],
|
||||
['W-SUN', t('1 week starting Sunday (freq=W-SUN)')],
|
||||
['W-MON', t('1 week starting Monday (freq=W-MON)')],
|
||||
['D', t('Day (freq=D)')],
|
||||
['4W-MON', t('4 weeks (freq=4W-MON)')],
|
||||
],
|
||||
description: t(
|
||||
`The periodicity over which to pivot time. Users can provide
|
||||
"Pandas" offset alias.
|
||||
Click on the info bubble for more details on accepted "freq" expressions.`,
|
||||
),
|
||||
tooltipOnClick: () => {
|
||||
window.open(
|
||||
'https://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases',
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('Chart Options'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[showLegend],
|
||||
[lineInterpolation],
|
||||
['color_picker', null],
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('X Axis'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[xAxisLabel],
|
||||
[bottomMargin],
|
||||
[xAxisShowMinmax],
|
||||
[
|
||||
{
|
||||
name: xAxisFormat.name,
|
||||
config: {
|
||||
...xAxisFormat.config,
|
||||
default: 'SMART_NUMBER',
|
||||
choices: D3_FORMAT_OPTIONS,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('Y Axis'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[yAxisLabel],
|
||||
[leftMargin],
|
||||
[yAxisShowMinmax],
|
||||
[yLogScale],
|
||||
['y_axis_format'],
|
||||
[yAxisBounds],
|
||||
],
|
||||
},
|
||||
],
|
||||
controlOverrides: {
|
||||
metric: {
|
||||
clearable: false,
|
||||
},
|
||||
},
|
||||
formDataOverrides: (formData: QueryFormData) => ({
|
||||
...formData,
|
||||
metric: getStandardizedControls().shiftMetric(),
|
||||
}),
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,51 +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 } 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(
|
||||
'Compares metrics between different time periods. Displays time series data across multiple periods (like weeks or months) to show period-over-period trends and patterns.',
|
||||
),
|
||||
exampleGallery: [{ url: example, urlDark: exampleDark }],
|
||||
name: t('Time-series Period Pivot'),
|
||||
tags: [t('Legacy'), t('Time'), t('nvd3')],
|
||||
thumbnail,
|
||||
thumbnailDark,
|
||||
useLegacyApi: true,
|
||||
});
|
||||
|
||||
export default class TimePivotChartPlugin extends ChartPlugin {
|
||||
constructor() {
|
||||
super({
|
||||
loadChart: () => import('../ReactNVD3'),
|
||||
metadata,
|
||||
transformProps,
|
||||
controlPanel,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { Preset, VizType } from '@superset-ui/core';
|
||||
import BubbleChartPlugin from './Bubble';
|
||||
import BulletChartPlugin from './Bullet';
|
||||
import CompareChartPlugin from './Compare';
|
||||
import TimePivotChartPlugin from './TimePivot';
|
||||
|
||||
export default class NVD3ChartPreset extends Preset {
|
||||
constructor() {
|
||||
super({
|
||||
name: 'NVD3 charts',
|
||||
plugins: [
|
||||
new BubbleChartPlugin().configure({ key: VizType.LegacyBubble }),
|
||||
new BulletChartPlugin().configure({ key: VizType.Bullet }),
|
||||
new CompareChartPlugin().configure({ key: VizType.Compare }),
|
||||
new TimePivotChartPlugin().configure({ key: VizType.TimePivot }),
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,206 +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.
|
||||
*/
|
||||
// @ts-nocheck -- legacy transformProps with loosely-typed formData from ChartProps
|
||||
import { ChartProps, VizType } from '@superset-ui/core';
|
||||
import isTruthy from './utils/isTruthy';
|
||||
import {
|
||||
tokenizeToNumericArray,
|
||||
tokenizeToStringArray,
|
||||
} from './utils/tokenize';
|
||||
import { formatLabel } from './utils';
|
||||
|
||||
const NOOP = () => {};
|
||||
|
||||
interface DatasourceMetric {
|
||||
d3format?: string;
|
||||
metric_name?: string;
|
||||
}
|
||||
|
||||
interface NVD3Datasource {
|
||||
metrics?: DatasourceMetric[];
|
||||
verboseMap?: Record<string, string>;
|
||||
}
|
||||
|
||||
const grabD3Format = (
|
||||
datasource: NVD3Datasource | undefined,
|
||||
targetMetric: string,
|
||||
): string | undefined => {
|
||||
let foundFormatter: string | undefined;
|
||||
const { metrics = [] } = datasource || {};
|
||||
metrics.forEach(metric => {
|
||||
if (metric.d3format && metric.metric_name === targetMetric) {
|
||||
foundFormatter = metric.d3format;
|
||||
}
|
||||
});
|
||||
|
||||
return foundFormatter;
|
||||
};
|
||||
|
||||
export default function transformProps(chartProps: ChartProps) {
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
annotationData,
|
||||
datasource,
|
||||
formData,
|
||||
hooks,
|
||||
queriesData,
|
||||
} = chartProps;
|
||||
|
||||
const { onAddFilter = NOOP, onError = NOOP } = hooks;
|
||||
|
||||
const {
|
||||
annotationLayers,
|
||||
barStacked,
|
||||
bottomMargin,
|
||||
colorPicker,
|
||||
colorScheme,
|
||||
comparisonType,
|
||||
contribution,
|
||||
donut,
|
||||
entity,
|
||||
labelsOutside,
|
||||
leftMargin,
|
||||
lineInterpolation,
|
||||
maxBubbleSize,
|
||||
metric,
|
||||
orderBars,
|
||||
pieLabelType,
|
||||
reduceXTicks,
|
||||
richTooltip,
|
||||
sendTimeRange,
|
||||
showBarValue,
|
||||
showBrush,
|
||||
showControls,
|
||||
showLabels,
|
||||
showLegend,
|
||||
showMarkers,
|
||||
size,
|
||||
stackedStyle,
|
||||
vizType,
|
||||
x,
|
||||
xAxisFormat,
|
||||
xAxisLabel,
|
||||
xAxisShowminmax,
|
||||
xLogScale,
|
||||
xTicksLayout,
|
||||
y,
|
||||
yAxisBounds,
|
||||
yAxis2Bounds,
|
||||
yAxisLabel,
|
||||
yAxisFormat,
|
||||
yAxisShowminmax,
|
||||
yAxis2Showminmax,
|
||||
yLogScale,
|
||||
sliceId,
|
||||
} = formData;
|
||||
|
||||
let {
|
||||
markerLabels,
|
||||
markerLines,
|
||||
markerLineLabels,
|
||||
markers,
|
||||
numberFormat,
|
||||
rangeLabels,
|
||||
ranges,
|
||||
} = formData;
|
||||
|
||||
const rawData = queriesData[0].data || [];
|
||||
const data = Array.isArray(rawData)
|
||||
? rawData.map(row => ({
|
||||
...row,
|
||||
values: Array.isArray(row.values)
|
||||
? row.values.map(value => ({ ...value }))
|
||||
: row.values,
|
||||
key: formatLabel(row.key, datasource.verboseMap),
|
||||
}))
|
||||
: rawData;
|
||||
|
||||
if (vizType === VizType.Pie) {
|
||||
numberFormat = numberFormat || grabD3Format(datasource, metric);
|
||||
} else if (vizType === VizType.Bullet) {
|
||||
ranges = tokenizeToNumericArray(ranges) || [0, data.measures * 1.1];
|
||||
rangeLabels = tokenizeToStringArray(rangeLabels);
|
||||
markerLabels = tokenizeToStringArray(markerLabels);
|
||||
markerLines = tokenizeToNumericArray(markerLines);
|
||||
markerLineLabels = tokenizeToStringArray(markerLineLabels);
|
||||
markers = tokenizeToNumericArray(markers);
|
||||
}
|
||||
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
data,
|
||||
annotationData,
|
||||
annotationLayers,
|
||||
areaStackedStyle: stackedStyle,
|
||||
baseColor: colorPicker,
|
||||
bottomMargin,
|
||||
colorScheme,
|
||||
comparisonType,
|
||||
contribution,
|
||||
entity,
|
||||
isBarStacked: barStacked,
|
||||
isDonut: donut,
|
||||
isPieLabelOutside: labelsOutside,
|
||||
leftMargin,
|
||||
lineInterpolation,
|
||||
markerLabels,
|
||||
markerLines,
|
||||
markerLineLabels,
|
||||
markers,
|
||||
maxBubbleSize: parseInt(maxBubbleSize, 10),
|
||||
numberFormat,
|
||||
onBrushEnd: isTruthy(sendTimeRange)
|
||||
? timeRange => {
|
||||
onAddFilter('__time_range', timeRange, false, true);
|
||||
}
|
||||
: undefined,
|
||||
onError,
|
||||
orderBars,
|
||||
pieLabelType,
|
||||
rangeLabels,
|
||||
ranges,
|
||||
reduceXTicks,
|
||||
showBarValue,
|
||||
showBrush,
|
||||
showControls,
|
||||
showLabels,
|
||||
showLegend,
|
||||
showMarkers,
|
||||
sizeField: size,
|
||||
useRichTooltip: richTooltip,
|
||||
vizType,
|
||||
xAxisFormat,
|
||||
xAxisLabel,
|
||||
xAxisShowMinMax: xAxisShowminmax,
|
||||
xField: x,
|
||||
xIsLogScale: xLogScale,
|
||||
xTicksLayout,
|
||||
yAxisFormat,
|
||||
yAxisBounds,
|
||||
yAxis2Bounds,
|
||||
yAxisLabel,
|
||||
yAxisShowMinMax: yAxisShowminmax,
|
||||
yAxis2ShowMinMax: yAxis2Showminmax,
|
||||
yField: y,
|
||||
yIsLogScale: yLogScale,
|
||||
sliceId,
|
||||
};
|
||||
}
|
||||
@@ -1,354 +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.
|
||||
*/
|
||||
// @ts-nocheck -- legacy file heavily dependent on untyped d3 v3 and nvd3 APIs
|
||||
import d3 from 'd3';
|
||||
import d3tip from 'd3-tip';
|
||||
import dompurify from 'dompurify';
|
||||
import {
|
||||
SMART_DATE_ID,
|
||||
getTimeFormatter,
|
||||
getNumberFormatter,
|
||||
} from '@superset-ui/core';
|
||||
// Regexp for the label added to time shifted series
|
||||
// (1 hour offset, 2 days offset, etc.)
|
||||
const TIME_SHIFT_PATTERN = /\d+ \w+ offset/;
|
||||
|
||||
const ANIMATION_TIME = 1000;
|
||||
|
||||
export function cleanColorInput(value) {
|
||||
// for superset series that should have the same color
|
||||
return String(value)
|
||||
.trim()
|
||||
.replace(' (right axis)', '')
|
||||
.split(', ')
|
||||
.filter(k => !TIME_SHIFT_PATTERN.test(k))
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
* If format is smart_date, format date
|
||||
* Otherwise, format number with the given format name
|
||||
* @param {*} format
|
||||
*/
|
||||
export function getTimeOrNumberFormatter(format) {
|
||||
return format === SMART_DATE_ID
|
||||
? getTimeFormatter(SMART_DATE_ID)
|
||||
: getNumberFormatter(format);
|
||||
}
|
||||
|
||||
export function drawBarValues(svg, data, stacked, axisFormat) {
|
||||
const format = getNumberFormatter(axisFormat);
|
||||
const countSeriesDisplayed = data.filter(d => !d.disabled).length;
|
||||
const totalStackedValues =
|
||||
stacked && data.length !== 0
|
||||
? data[0].values.map((bar, iBar) => {
|
||||
const bars = data
|
||||
.filter(series => !series.disabled)
|
||||
.map(series => series.values[iBar]);
|
||||
|
||||
return d3.sum(bars, d => d.y);
|
||||
})
|
||||
: [];
|
||||
svg.selectAll('.bar-chart-label-group').remove();
|
||||
setTimeout(() => {
|
||||
svg.selectAll('.bar-chart-label-group').remove();
|
||||
const groupLabels = svg
|
||||
.select('g.nv-barsWrap')
|
||||
.append('g')
|
||||
.attr('class', 'bar-chart-label-group');
|
||||
svg
|
||||
.selectAll('g.nv-group')
|
||||
.filter((d, i) => !stacked || i === countSeriesDisplayed - 1)
|
||||
.selectAll('rect')
|
||||
.each(function each(d, index) {
|
||||
const rectObj = d3.select(this);
|
||||
const transformAttr = rectObj.attr('transform');
|
||||
const xPos = parseFloat(rectObj.attr('x'));
|
||||
const yPos = parseFloat(rectObj.attr('y'));
|
||||
const rectWidth = parseFloat(rectObj.attr('width'));
|
||||
const rectHeight = parseFloat(rectObj.attr('height'));
|
||||
const textEls = groupLabels
|
||||
.append('text')
|
||||
.text(format(stacked ? totalStackedValues[index] : d.y))
|
||||
.attr('transform', transformAttr)
|
||||
.attr('class', 'bar-chart-label');
|
||||
|
||||
// fine tune text position
|
||||
const bbox = textEls.node().getBBox();
|
||||
const labelWidth = bbox.width;
|
||||
const labelHeight = bbox.height;
|
||||
textEls.attr('x', xPos + rectWidth / 2 - labelWidth / 2);
|
||||
if (rectObj.attr('class').includes('positive')) {
|
||||
textEls.attr('y', yPos - 5);
|
||||
} else {
|
||||
textEls.attr('y', yPos + rectHeight + labelHeight);
|
||||
}
|
||||
});
|
||||
}, ANIMATION_TIME);
|
||||
}
|
||||
|
||||
// Formats the series key to account for a possible NULL value
|
||||
function getFormattedKey(seriesKey, shouldDompurify) {
|
||||
if (seriesKey === '<NULL>') {
|
||||
return `<${seriesKey.slice(1, -1)}>`;
|
||||
}
|
||||
|
||||
return shouldDompurify ? dompurify.sanitize(seriesKey) : seriesKey;
|
||||
}
|
||||
|
||||
export function generateCompareTooltipContent(d, valueFormatter) {
|
||||
let tooltip = '';
|
||||
tooltip +=
|
||||
"<table><thead><tr><td colspan='3'>" +
|
||||
`<strong class='x-value'>${d.value}</strong>` +
|
||||
'</td></tr></thead><tbody>';
|
||||
d.series.sort((a, b) => (a.value >= b.value ? -1 : 1));
|
||||
d.series.forEach(series => {
|
||||
const key = getFormattedKey(series.key, true);
|
||||
tooltip +=
|
||||
`<tr class="${series.highlight ? 'emph' : ''}">` +
|
||||
`<td class='legend-color-guide' style="opacity: ${
|
||||
series.highlight ? '1' : '0.75'
|
||||
};"">` +
|
||||
'<div ' +
|
||||
`style="border: 2px solid ${
|
||||
series.highlight ? 'black' : 'transparent'
|
||||
}; background-color: ${series.color};"` +
|
||||
'></div>' +
|
||||
'</td>' +
|
||||
`<td>${key}</td>` +
|
||||
`<td>${valueFormatter(series.value)}</td>` +
|
||||
'</tr>';
|
||||
});
|
||||
tooltip += '</tbody></table>';
|
||||
|
||||
return dompurify.sanitize(tooltip);
|
||||
}
|
||||
|
||||
export function generateMultiLineTooltipContent(d, xFormatter, yFormatters) {
|
||||
const tooltipTitle = xFormatter(d.value);
|
||||
let tooltip = '';
|
||||
|
||||
tooltip +=
|
||||
"<table><thead><tr><td colspan='3'>" +
|
||||
`<strong class='x-value'>${tooltipTitle}</strong>` +
|
||||
'</td></tr></thead><tbody>';
|
||||
|
||||
d.series.forEach((series, i) => {
|
||||
const yFormatter = yFormatters[i];
|
||||
const key = getFormattedKey(series.key, true);
|
||||
tooltip +=
|
||||
"<tr><td class='legend-color-guide'>" +
|
||||
`<div style="background-color: ${series.color};"></div></td>` +
|
||||
`<td class='key'>${key}</td>` +
|
||||
`<td class='value'>${yFormatter(series.value)}</td></tr>`;
|
||||
});
|
||||
|
||||
tooltip += '</tbody></table>';
|
||||
|
||||
return dompurify.sanitize(tooltip);
|
||||
}
|
||||
|
||||
export function generateTimePivotTooltip(d, xFormatter, yFormatter) {
|
||||
const tooltipTitle = xFormatter(d.value);
|
||||
let tooltip = '';
|
||||
|
||||
tooltip +=
|
||||
"<table><thead><tr><td colspan='3'>" +
|
||||
`<strong class='x-value'>${tooltipTitle}</strong>` +
|
||||
'</td></tr></thead><tbody>';
|
||||
|
||||
d.series.forEach(series => {
|
||||
if (series.highlight) {
|
||||
let label = '';
|
||||
if (series.key === 'current') {
|
||||
label = series.key;
|
||||
} else {
|
||||
label = `${series.key} of the selected frequency:`;
|
||||
}
|
||||
tooltip +=
|
||||
"<tr><td class='legend-color-guide'>" +
|
||||
`<div style="background-color: ${series.color};"></div></td>` +
|
||||
`<td class='key'>${label}</td>` +
|
||||
`<td class='value'>${yFormatter(series.value)}</td></tr>`;
|
||||
}
|
||||
});
|
||||
|
||||
tooltip += '</tbody></table>';
|
||||
|
||||
return dompurify.sanitize(tooltip);
|
||||
}
|
||||
|
||||
function getLabel(stringOrObjectWithLabel) {
|
||||
return stringOrObjectWithLabel.label || stringOrObjectWithLabel;
|
||||
}
|
||||
|
||||
function createHTMLRow(col1, col2) {
|
||||
return `<tr><td>${col1}</td><td>${col2}</td></tr>`;
|
||||
}
|
||||
|
||||
export function generateBubbleTooltipContent({
|
||||
point,
|
||||
entity,
|
||||
xField,
|
||||
yField,
|
||||
sizeField,
|
||||
xFormatter,
|
||||
yFormatter,
|
||||
sizeFormatter,
|
||||
}) {
|
||||
let s = '<table>';
|
||||
s +=
|
||||
`<tr><td style="color: ${point.color};">` +
|
||||
`<strong>${point[entity]}</strong> (${point.group})` +
|
||||
'</td></tr>';
|
||||
s += createHTMLRow(getLabel(xField), xFormatter(point.x));
|
||||
s += createHTMLRow(getLabel(yField), yFormatter(point.y));
|
||||
s += createHTMLRow(getLabel(sizeField), sizeFormatter(point.size));
|
||||
s += '</table>';
|
||||
|
||||
return dompurify.sanitize(s);
|
||||
}
|
||||
|
||||
// shouldRemove indicates whether the nvtooltips should be removed from the DOM
|
||||
export function hideTooltips(shouldRemove) {
|
||||
const targets = document.querySelectorAll('.nvtooltip');
|
||||
if (targets.length > 0) {
|
||||
// Only set opacity to 0 when hiding tooltips so they would reappear
|
||||
// on hover, which sets the opacity to 1
|
||||
targets.forEach(t => {
|
||||
if (shouldRemove) {
|
||||
t.remove();
|
||||
} else {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
t.style.opacity = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function generateTooltipClassName(uuid) {
|
||||
return `tooltip-${uuid}`;
|
||||
}
|
||||
|
||||
export function removeTooltip(uuid) {
|
||||
const classSelector = `.${generateTooltipClassName(uuid)}`;
|
||||
const target = document.querySelector(classSelector);
|
||||
if (target) {
|
||||
target.remove();
|
||||
}
|
||||
}
|
||||
|
||||
export function wrapTooltip(chart) {
|
||||
const tooltipLayer =
|
||||
chart.useInteractiveGuideline && chart.useInteractiveGuideline()
|
||||
? chart.interactiveLayer
|
||||
: chart;
|
||||
const tooltipGeneratorFunc = tooltipLayer.tooltip.contentGenerator();
|
||||
tooltipLayer.tooltip.contentGenerator(d => {
|
||||
// The nvd3-fork default contentGenerator builds tooltip HTML with
|
||||
// unescaped series keys (and feeds them into the tooltip's `.html()`
|
||||
// sink at render time). Run the final string through DOMPurify so
|
||||
// charts that do NOT install a custom contentGenerator (Line, Bar,
|
||||
// Area, Pie, BoxPlot, etc.) cannot execute stored payloads in
|
||||
// column or series names. Custom contentGenerators set elsewhere in
|
||||
// this module already return sanitized output, making this a
|
||||
// belt-and-braces wrap.
|
||||
const tooltip = `<div>${tooltipGeneratorFunc(d)}</div>`;
|
||||
return dompurify.sanitize(tooltip);
|
||||
});
|
||||
}
|
||||
|
||||
// Builds the sanitized HTML for an annotation layer's tooltip. Title and
|
||||
// description values come from the annotation data source, so the output is
|
||||
// run through dompurify before being inserted into the DOM by d3-tip.
|
||||
export function generateAnnotationTooltipContent(layer, d) {
|
||||
const title =
|
||||
d[layer.titleColumn] && d[layer.titleColumn].length > 0
|
||||
? `${d[layer.titleColumn]} - ${layer.name}`
|
||||
: layer.name;
|
||||
const body = Array.isArray(layer.descriptionColumns)
|
||||
? layer.descriptionColumns.map(c => d[c])
|
||||
: Object.values(d);
|
||||
|
||||
return dompurify.sanitize(
|
||||
`<div><strong>${title}</strong></div><br/><div>${body.join(', ')}</div>`,
|
||||
);
|
||||
}
|
||||
|
||||
export function tipFactory(layer) {
|
||||
return d3tip()
|
||||
.attr('class', `d3-tip ${layer.annotationTipClass || ''}`)
|
||||
.direction('n')
|
||||
.offset([-5, 0])
|
||||
.html(d => (d ? generateAnnotationTooltipContent(layer, d) : ''));
|
||||
}
|
||||
|
||||
export function getMaxLabelSize(svg, axisClass) {
|
||||
// axis class = .nv-y2 // second y axis on dual line chart
|
||||
// axis class = .nv-x // x axis on time series line chart
|
||||
const tickTexts = svg.selectAll(`.${axisClass} g.tick text`);
|
||||
if (tickTexts.length > 0) {
|
||||
const lengths = tickTexts[0].map(text => text.getComputedTextLength());
|
||||
|
||||
return Math.ceil(Math.max(0, ...lengths));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function formatLabel(input, verboseMap = {}) {
|
||||
// The input for label may be a string or an array of string
|
||||
// When using the time shift feature, the label contains a '---' in the array
|
||||
const verboseLookup = s => verboseMap[s] || s;
|
||||
|
||||
return Array.isArray(input) && input.length > 0
|
||||
? input
|
||||
.map(l => (TIME_SHIFT_PATTERN.test(l) ? l : verboseLookup(l)))
|
||||
.join(', ')
|
||||
: verboseLookup(input);
|
||||
}
|
||||
|
||||
export function stringifyTimeRange(extent) {
|
||||
if (extent.some(d => d.toISOString === undefined)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return extent.map(d => d.toISOString().slice(0, -1)).join(' : ');
|
||||
}
|
||||
|
||||
export function setAxisShowMaxMin(axis, showminmax) {
|
||||
if (axis && axis.showMaxMin && showminmax !== undefined) {
|
||||
axis.showMaxMin(showminmax);
|
||||
}
|
||||
}
|
||||
|
||||
export function computeYDomain(data) {
|
||||
if (Array.isArray(data) && data.length > 0 && Array.isArray(data[0].values)) {
|
||||
const extents = data
|
||||
.filter(d => !d.disabled)
|
||||
.map(row => d3.extent(row.values, v => v.y));
|
||||
const minOfMin = d3.min(extents, ([min]) => min);
|
||||
const maxOfMax = d3.max(extents, ([, max]) => max);
|
||||
|
||||
return [minOfMin, maxOfMax];
|
||||
}
|
||||
|
||||
return [0, 1];
|
||||
}
|
||||
@@ -1,86 +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.
|
||||
*/
|
||||
// @ts-nocheck -- vendor file; not fully typed
|
||||
import { t } from '@apache-superset/core/translation';
|
||||
|
||||
function extractTypes(metadata) {
|
||||
return Object.keys(metadata).reduce((prev, key) => {
|
||||
const result = prev;
|
||||
result[key] = key;
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
export const ANNOTATION_TYPES_METADATA = {
|
||||
FORMULA: {
|
||||
value: 'FORMULA',
|
||||
label: t('Formula'),
|
||||
},
|
||||
EVENT: {
|
||||
value: 'EVENT',
|
||||
label: t('Event'),
|
||||
supportNativeSource: true,
|
||||
},
|
||||
INTERVAL: {
|
||||
value: 'INTERVAL',
|
||||
label: t('Interval'),
|
||||
supportNativeSource: true,
|
||||
},
|
||||
TIME_SERIES: {
|
||||
value: 'TIME_SERIES',
|
||||
label: t('Time Series'),
|
||||
},
|
||||
};
|
||||
|
||||
export const ANNOTATION_TYPES = extractTypes(ANNOTATION_TYPES_METADATA);
|
||||
|
||||
export const DEFAULT_ANNOTATION_TYPE = ANNOTATION_TYPES.FORMULA;
|
||||
|
||||
export const ANNOTATION_SOURCE_TYPES_METADATA = {
|
||||
NATIVE: {
|
||||
value: 'NATIVE',
|
||||
label: 'Superset annotation',
|
||||
},
|
||||
};
|
||||
|
||||
export const ANNOTATION_SOURCE_TYPES = extractTypes(
|
||||
ANNOTATION_SOURCE_TYPES_METADATA,
|
||||
);
|
||||
|
||||
export function requiresQuery(annotationSourceType) {
|
||||
return !!annotationSourceType;
|
||||
}
|
||||
|
||||
const NATIVE_COLUMN_NAMES = {
|
||||
descriptionColumns: ['long_descr'],
|
||||
intervalEndColumn: 'end_dttm',
|
||||
timeColumn: 'start_dttm',
|
||||
titleColumn: 'short_descr',
|
||||
};
|
||||
|
||||
export function applyNativeColumns(annotation) {
|
||||
if (annotation.sourceType === ANNOTATION_SOURCE_TYPES.NATIVE) {
|
||||
return { ...annotation, ...NATIVE_COLUMN_NAMES };
|
||||
}
|
||||
|
||||
return annotation;
|
||||
}
|
||||
|
||||
export default ANNOTATION_TYPES;
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -1,358 +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 {
|
||||
getTimeFormatterRegistry,
|
||||
SMART_DATE_ID,
|
||||
createSmartDateFormatter,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
import {
|
||||
computeYDomain,
|
||||
generateAnnotationTooltipContent,
|
||||
generateBubbleTooltipContent,
|
||||
generateMultiLineTooltipContent,
|
||||
getTimeOrNumberFormatter,
|
||||
formatLabel,
|
||||
tipFactory,
|
||||
} from '../src/utils';
|
||||
|
||||
const DATA = [
|
||||
{
|
||||
key: ['East Asia & Pacific'],
|
||||
values: [
|
||||
{
|
||||
x: -315619200000.0,
|
||||
y: 1031863394.0,
|
||||
},
|
||||
{
|
||||
x: -283996800000.0,
|
||||
y: 1034767718.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['South Asia'],
|
||||
values: [
|
||||
{
|
||||
x: -315619200000.0,
|
||||
y: 572036107.0,
|
||||
},
|
||||
{
|
||||
x: -283996800000.0,
|
||||
y: 584143236.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['Europe & Central Asia'],
|
||||
values: [
|
||||
{
|
||||
x: -315619200000.0,
|
||||
y: 660881033.0,
|
||||
},
|
||||
{
|
||||
x: -283996800000.0,
|
||||
y: 668526708.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const DATA_WITH_DISABLED_SERIES = [
|
||||
{
|
||||
disabled: true,
|
||||
key: ['East Asia & Pacific'],
|
||||
values: [
|
||||
{
|
||||
x: -315619200000.0,
|
||||
y: 1031863394.0,
|
||||
},
|
||||
{
|
||||
x: -283996800000.0,
|
||||
y: 1034767718.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
disabled: true,
|
||||
key: ['South Asia'],
|
||||
values: [
|
||||
{
|
||||
x: -315619200000.0,
|
||||
y: 572036107.0,
|
||||
},
|
||||
{
|
||||
x: -283996800000.0,
|
||||
y: 584143236.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: ['Europe & Central Asia'],
|
||||
values: [
|
||||
{
|
||||
x: -315619200000.0,
|
||||
y: 660881033.0,
|
||||
},
|
||||
{
|
||||
x: -283996800000.0,
|
||||
y: 668526708.0,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
describe('nvd3/utils', () => {
|
||||
beforeEach(() => {
|
||||
getTimeFormatterRegistry().registerValue(
|
||||
SMART_DATE_ID,
|
||||
createSmartDateFormatter(),
|
||||
);
|
||||
});
|
||||
|
||||
describe('generateMultiLineTooltipContent()', () => {
|
||||
const identity = (value: any) => value;
|
||||
|
||||
test('renders the series key in the tooltip markup', () => {
|
||||
const tooltip = generateMultiLineTooltipContent(
|
||||
{
|
||||
value: 'x-value',
|
||||
series: [{ key: 'Region A', color: '#fff', value: 1 }],
|
||||
},
|
||||
identity,
|
||||
[identity],
|
||||
);
|
||||
expect(tooltip).toContain('Region A');
|
||||
});
|
||||
|
||||
test('strips a script payload from a malicious series key', () => {
|
||||
const tooltip = generateMultiLineTooltipContent(
|
||||
{
|
||||
value: 'x-value',
|
||||
series: [
|
||||
{
|
||||
key: '<img src=x onerror="alert(1)">',
|
||||
color: '#fff',
|
||||
value: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
identity,
|
||||
[identity],
|
||||
);
|
||||
// DOMPurify removes the event handler that would execute on render.
|
||||
expect(tooltip).not.toContain('onerror');
|
||||
expect(tooltip).not.toContain('alert(1)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getTimeOrNumberFormatter(format)', () => {
|
||||
test('is a function', () => {
|
||||
expect(typeof getTimeOrNumberFormatter).toBe('function');
|
||||
});
|
||||
test('returns a date formatter if format is smart_date', () => {
|
||||
const time = new Date(Date.UTC(2018, 10, 21, 22, 11));
|
||||
// @ts-expect-error -- getTimeOrNumberFormatter doesn't distinguish return types; accepts Date at runtime
|
||||
expect(getTimeOrNumberFormatter('smart_date')(time)).toBe('10:11');
|
||||
});
|
||||
test('returns a number formatter otherwise', () => {
|
||||
expect(getTimeOrNumberFormatter('.3s')(3000000)).toBe('3.00M');
|
||||
expect(getTimeOrNumberFormatter(undefined)(3000100)).toBe('3M');
|
||||
});
|
||||
});
|
||||
|
||||
describe('formatLabel()', () => {
|
||||
const verboseMap = {
|
||||
foo: 'Foo',
|
||||
bar: 'Bar',
|
||||
};
|
||||
|
||||
test('formats simple labels', () => {
|
||||
expect(formatLabel('foo')).toBe('foo');
|
||||
expect(formatLabel(['foo'])).toBe('foo');
|
||||
expect(formatLabel(['foo', 'bar'])).toBe('foo, bar');
|
||||
});
|
||||
test('formats simple labels with lookups', () => {
|
||||
expect(formatLabel('foo', verboseMap)).toBe('Foo');
|
||||
expect(formatLabel('baz', verboseMap)).toBe('baz');
|
||||
expect(formatLabel(['foo'], verboseMap)).toBe('Foo');
|
||||
expect(formatLabel(['foo', 'bar', 'baz'], verboseMap)).toBe(
|
||||
'Foo, Bar, baz',
|
||||
);
|
||||
});
|
||||
test('deals with time shift properly', () => {
|
||||
expect(formatLabel(['foo', '1 hour offset'], verboseMap)).toBe(
|
||||
'Foo, 1 hour offset',
|
||||
);
|
||||
expect(
|
||||
formatLabel(['foo', 'bar', 'baz', '2 hours offset'], verboseMap),
|
||||
).toBe('Foo, Bar, baz, 2 hours offset');
|
||||
});
|
||||
});
|
||||
|
||||
describe('computeYDomain()', () => {
|
||||
test('works with invalid data', () => {
|
||||
expect(computeYDomain('foo')).toEqual([0, 1]);
|
||||
});
|
||||
|
||||
test('works with all series enabled', () => {
|
||||
expect(computeYDomain(DATA)).toEqual([572036107.0, 1034767718.0]);
|
||||
});
|
||||
|
||||
test('works with some series disabled', () => {
|
||||
expect(computeYDomain(DATA_WITH_DISABLED_SERIES)).toEqual([
|
||||
660881033.0, 668526708.0,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Tooltip HTML sanitisation (XSS regression).
|
||||
// Each helper below feeds user-controlled column values into a
|
||||
// d3 / nvd3 .html() sink; the sanitised return must strip dangerous
|
||||
// markup so a stored payload cannot execute on hover.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
describe('generateBubbleTooltipContent() sanitises user input', () => {
|
||||
test('strips <script> from the entity column', () => {
|
||||
const html = generateBubbleTooltipContent({
|
||||
point: {
|
||||
color: 'red',
|
||||
group: 'g',
|
||||
entity: '<script>alert(1)</script>',
|
||||
x: 1,
|
||||
y: 2,
|
||||
size: 3,
|
||||
},
|
||||
entity: 'entity',
|
||||
xField: 'x',
|
||||
yField: 'y',
|
||||
sizeField: 'size',
|
||||
xFormatter: (v: number) => String(v),
|
||||
yFormatter: (v: number) => String(v),
|
||||
sizeFormatter: (v: number) => String(v),
|
||||
});
|
||||
expect(html).not.toMatch(/<script/i);
|
||||
expect(html).not.toMatch(/onerror=/i);
|
||||
});
|
||||
|
||||
test('strips <img onerror> injected via the group column', () => {
|
||||
const html = generateBubbleTooltipContent({
|
||||
point: {
|
||||
color: 'red',
|
||||
group: '<img src=x onerror=alert(1)>',
|
||||
entity: 'safe',
|
||||
x: 1,
|
||||
y: 2,
|
||||
size: 3,
|
||||
},
|
||||
entity: 'entity',
|
||||
xField: 'x',
|
||||
yField: 'y',
|
||||
sizeField: 'size',
|
||||
xFormatter: (v: number) => String(v),
|
||||
yFormatter: (v: number) => String(v),
|
||||
sizeFormatter: (v: number) => String(v),
|
||||
});
|
||||
expect(html).not.toMatch(/onerror/i);
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateMultiLineTooltipContent() sanitises user input', () => {
|
||||
test('strips <script> from a series key', () => {
|
||||
const html = generateMultiLineTooltipContent(
|
||||
{
|
||||
value: 0,
|
||||
series: [
|
||||
{
|
||||
key: '<script>alert(1)</script>',
|
||||
color: 'red',
|
||||
value: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
(v: number) => String(v),
|
||||
[(v: number) => String(v)],
|
||||
);
|
||||
expect(html).not.toMatch(/<script/i);
|
||||
});
|
||||
});
|
||||
|
||||
describe('tipFactory() sanitises annotation columns', () => {
|
||||
test('strips <script> from a description column value', () => {
|
||||
const tip = tipFactory({
|
||||
annotationTipClass: 'foo',
|
||||
titleColumn: 'title',
|
||||
descriptionColumns: ['desc'],
|
||||
name: 'layer',
|
||||
});
|
||||
// d3-tip's .html(fn) stores the callback as the renderer; invoke
|
||||
// it directly to assert the sanitised output.
|
||||
const datum = {
|
||||
title: 'normal',
|
||||
desc: '<script>alert(1)</script>payload',
|
||||
};
|
||||
const html = tip.html()(datum);
|
||||
expect(html).not.toMatch(/<script/i);
|
||||
expect(html).toContain('payload');
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateAnnotationTooltipContent()', () => {
|
||||
const layer = {
|
||||
name: 'My annotations',
|
||||
titleColumn: 'title',
|
||||
descriptionColumns: ['description'],
|
||||
};
|
||||
|
||||
test('renders the annotation title and description', () => {
|
||||
const html = generateAnnotationTooltipContent(layer, {
|
||||
title: 'Release',
|
||||
description: 'Shipped v1',
|
||||
});
|
||||
expect(html).toContain('Release - My annotations');
|
||||
expect(html).toContain('Shipped v1');
|
||||
});
|
||||
|
||||
test('falls back to the layer name when the title column is empty', () => {
|
||||
const html = generateAnnotationTooltipContent(layer, {
|
||||
title: '',
|
||||
description: 'Shipped v1',
|
||||
});
|
||||
expect(html).toContain('My annotations');
|
||||
});
|
||||
|
||||
test('strips an event-handler payload from the title column', () => {
|
||||
const html = generateAnnotationTooltipContent(layer, {
|
||||
title: '<img src=x onerror="alert(1)">',
|
||||
description: 'ok',
|
||||
});
|
||||
expect(html).not.toContain('onerror');
|
||||
expect(html).not.toContain('alert(1)');
|
||||
});
|
||||
|
||||
test('strips a script payload from a description column', () => {
|
||||
const html = generateAnnotationTooltipContent(layer, {
|
||||
title: 'Release',
|
||||
description: '<script>alert(document.cookie)</script>',
|
||||
});
|
||||
expect(html).not.toContain('<script>');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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 isTruthy from '../../src/utils/isTruthy';
|
||||
|
||||
describe('isTruthy', () => {
|
||||
test('evals false-looking strings properly', () => {
|
||||
expect(isTruthy('f')).toBe(false);
|
||||
expect(isTruthy('false')).toBe(false);
|
||||
expect(isTruthy('no')).toBe(false);
|
||||
expect(isTruthy('n')).toBe(false);
|
||||
expect(isTruthy('F')).toBe(false);
|
||||
expect(isTruthy('False')).toBe(false);
|
||||
expect(isTruthy('NO')).toBe(false);
|
||||
expect(isTruthy('N')).toBe(false);
|
||||
});
|
||||
test('evals true-looking strings properly', () => {
|
||||
expect(isTruthy('t')).toBe(true);
|
||||
expect(isTruthy('true')).toBe(true);
|
||||
expect(isTruthy('yes')).toBe(true);
|
||||
expect(isTruthy('y')).toBe(true);
|
||||
expect(isTruthy('Y')).toBe(true);
|
||||
expect(isTruthy('True')).toBe(true);
|
||||
expect(isTruthy('Yes')).toBe(true);
|
||||
expect(isTruthy('YES')).toBe(true);
|
||||
});
|
||||
test('evals bools properly', () => {
|
||||
expect(isTruthy(false)).toBe(false);
|
||||
expect(isTruthy(true)).toBe(true);
|
||||
});
|
||||
test('evals ints properly', () => {
|
||||
expect(isTruthy(0)).toBe(false);
|
||||
expect(isTruthy(1)).toBe(true);
|
||||
});
|
||||
test('evals constants properly', () => {
|
||||
expect(isTruthy(null)).toBe(false);
|
||||
expect(isTruthy(undefined)).toBe(false);
|
||||
});
|
||||
test('string auto is false', () => {
|
||||
expect(isTruthy('false')).toBe(false);
|
||||
});
|
||||
});
|
||||