You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "SBIN2010 (via GitHub)" <gi...@apache.org> on 2026/10/12 21:50:00 UTC
[PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
SBIN2010 opened a new pull request, #45223:
URL: https://github.com/apache/superset/pull/45223
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
The ECharts bubble chart now supports dashboard cross-filtering, as well as drill-to-detail and drill-by functionality. This addresses the issue described in discussion https://github.com/apache/superset/discussions/31728: previously, clicking a bubble did not filter other charts sharing the same dataset.
Clicking a bubble filters other charts based on the corresponding entity and, if a series dimension is defined, the series. Clicking the same bubble again clears the filter. Bubbles that do not match the active selection become semi-transparent, and the cursor changes to a pointer only when cross-filtering is enabled for the chart.
A missing measurement value is passed as `IS NULL`. An empty string remains an `IN` filter value of `''` and is displayed as `""`, ensuring that the filter chip, legend, and tooltip do not conflate it with `<NULL>`. The filter chip displays a clear label (`entity` or `entity, series`). Selected values ββare stored in the dashboard state as a JSON array, so `null`, `''`, and numeric values ββremain distinguishable, and the key is preserved correctly when using permalinks.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
1. Create a Bubble chart with Entity, X, Y, and Size, and optionally a Series dimension. Add it to a dashboard that has cross-filtering enabled, next to another chart on the same dataset (the setup from https://github.com/apache/superset/discussions/31728).
2. Click a bubble. The other chart should filter to that entity (and series, when set), the filter chip should show the readable label, and the other bubbles should dim.
3. Click the same bubble again. The filter and the dimming should clear.
4. Repeat with a null entity and a null series. The emitted filter should use `IS NULL`, and the chip should show `<NULL>`.
5. Right-click a bubble. The context menu should offer cross-filter, drill to detail, and drill by, including `IS NULL` for an empty dimension.
6. Turn cross-filtering off for the dashboard (or chart). Clicks should no longer emit a filter, and the cursor should stay the default.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [x] Has associated issue: https://github.com/apache/superset/discussions/31728
- [ ] Required feature flags:
- [x ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [x ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4252692620
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,170 @@
+/**
+ * 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 {
+ DataRecordValue,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/** Display text for an empty-string dimension value. */
+export const EMPTY_STRING = '""';
+
+/**
+ * Human-readable text for a dimension value, used for series names, tooltips
+ * and the cross-filter chip. `null` and `''` stay distinguishable because they
+ * produce different filters (`IS NULL` vs `IN ['']`).
+ */
+export function formatBubbleValue(value: DataRecordValue): string {
+ if (value == null) {
+ return NULL_STRING;
+ }
+ const text = String(value);
+ return text === '' ? EMPTY_STRING : text;
+}
+
+export function isBubbleDatum(value: unknown): value is BubbleDatum {
+ return Array.isArray(value) && value.length > SERIES_INDEX;
+}
+
+function toKeyPart(
+ value: DataRecordValue | undefined,
+): string | number | boolean | null {
+ if (value == null) {
+ return null;
+ }
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+ return value instanceof Date ? value.toISOString() : value;
+}
+
+/**
+ * Stable identifier of a bubble, stored in `filterState.selectedValues`.
+ * A JSON array keeps entity and series unambiguous (including `null` vs `''`
+ * and `1` vs `'1'`) and survives serialization into dashboard state.
+ */
+export function getBubbleCrossFilterKey(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const parts = hasSeries
+ ? [toKeyPart(entityValue), toKeyPart(seriesValue)]
+ : [toKeyPart(entityValue)];
+ return JSON.stringify(parts);
+}
+
+export function getBubbleCrossFilterLabel(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const entityPart = formatBubbleValue(entityValue);
+ if (!hasSeries) {
+ return entityPart;
+ }
+ return `${entityPart}, ${formatBubbleValue(seriesValue ?? null)}`;
+}
+
+export function getSelectedBubbleKeys(selectedValues: unknown): string[] {
+ if (!selectedValues) {
+ return [];
+ }
+ if (Array.isArray(selectedValues)) {
+ return selectedValues.map(value => String(value));
+ }
+ if (typeof selectedValues === 'object') {
+ return Object.values(selectedValues as Record<string, unknown>).map(value =>
+ String(value),
+ );
+ }
+ return [];
+}
+
+function dimensionFilter(
+ col: QueryFormColumn,
+ value: DataRecordValue,
+): QueryObjectFilterClause {
+ if (value == null) {
+ return { col, op: 'IS NULL' };
+ }
+ return {
+ col,
+ op: 'IN',
+ val: [value],
+ };
Review Comment:
**Suggestion:** `DataRecordValue` includes `bigint`, but this keeps it raw in the filter. Selecting one makes JSON serialization throw, so the dashboard query fails.
**Assessment:** π `Major` Β· π `Occurrence: Rarely` Β· π·οΈ `Type error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=acbbe4fa348b40fba84692c607ddf774&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=acbbe4fa348b40fba84692c607ddf774&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent π€ </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts
**Line:** 120:124
**Comment:**
*Type Error: `DataRecordValue` includes `bigint`, but this keeps it raw in the filter. Selecting one makes JSON serialization throw, so the dashboard query fails.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45223&comment_hash=b7ac70a73a1e5259a50c6c4ea7e8062dfaaa62dbe6bb03a8b56cd813e38b2f73&reaction=like'>π</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45223&comment_hash=b7ac70a73a1e5259a50c6c4ea7e8062dfaaa62dbe6bb03a8b56cd813e38b2f73&reaction=dislike'>π</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "SBIN2010 (via GitHub)" <gi...@apache.org>.
SBIN2010 merged PR #45223:
URL: https://github.com/apache/superset/pull/45223
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "SBIN2010 (via GitHub)" <gi...@apache.org>.
SBIN2010 commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4262086061
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,180 @@
+/**
+ * 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 {
+ DataRecordValue,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/** Display text for an empty-string dimension value. */
+export const EMPTY_STRING = '""';
+
+/**
+ * Human-readable text for a dimension value, used for series names, tooltips
+ * and the cross-filter chip. `null` and `''` stay distinguishable because they
+ * produce different filters (`IS NULL` vs `IN ['']`).
+ */
+export function formatBubbleValue(value: DataRecordValue): string {
+ if (value == null) {
+ return NULL_STRING;
+ }
+ const text = String(value);
+ return text === '' ? EMPTY_STRING : text;
+}
+
+export function isBubbleDatum(value: unknown): value is BubbleDatum {
+ return Array.isArray(value) && value.length > SERIES_INDEX;
+}
+
+function toKeyPart(
+ value: DataRecordValue | undefined,
+): string | number | boolean | null {
+ if (value == null) {
+ return null;
+ }
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+ return value instanceof Date ? value.toISOString() : value;
+}
+
+/**
+ * Stable identifier of a bubble, stored in `filterState.selectedValues`.
+ * A JSON array keeps entity and series unambiguous (including `null` vs `''`
+ * and `1` vs `'1'`) and survives serialization into dashboard state.
+ */
+export function getBubbleCrossFilterKey(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const parts = hasSeries
+ ? [toKeyPart(entityValue), toKeyPart(seriesValue)]
+ : [toKeyPart(entityValue)];
+ return JSON.stringify(parts);
+}
+
+export function getBubbleCrossFilterLabel(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const entityPart = formatBubbleValue(entityValue);
Review Comment:
fix in [1fd9b58](https://github.com/apache/superset/pull/45223/commits/1fd9b587ca86ed2dd13a5c4e3cc1e3a774f25eb8)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4263638264
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/EchartsBubble.tsx:
##########
@@ -16,9 +16,71 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { useMemo } from 'react';
+import {
+ ContextMenuFilters,
+ DataRecordValue,
+ getColumnLabel,
+ getNumberFormatter,
+ getTimeFormatter,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
import { BubbleChartTransformedProps } from './types';
import Echart from '../components/Echart';
+import { EventHandlers } from '../types';
import { useLegendEventHandlers } from '../utils/legendEventHandlers';
+import { formatSeriesName } from '../utils/series';
+import {
+ BubbleDatum,
+ ENTITY_INDEX,
+ getBubbleCrossFilterDataMask,
+ getSelectedBubbleKeys,
+ isBubbleDatum,
+ SERIES_INDEX,
+ toJsonSafeFilterValue,
+} from './crossFilter';
+
+const noop = () => {};
+
+type BubbleEvent = {
+ componentType?: string;
+ data?: unknown;
+ event?: { stop: () => void; event: PointerEvent };
+};
+
+function buildDrillFilters(
+ entity: QueryFormColumn,
+ series: QueryFormColumn | undefined,
+ datum: BubbleDatum,
+ dateFormat: string | undefined,
+ coltypeMapping: BubbleChartTransformedProps['coltypeMapping'],
+): QueryObjectFilterClause[] {
+ const columns: Array<{ col: QueryFormColumn; value: DataRecordValue }> = [
+ { col: entity, value: datum[ENTITY_INDEX] },
+ ];
+ if (series) {
+ columns.push({ col: series, value: datum[SERIES_INDEX] });
+ }
+ const timeFormatter = getTimeFormatter(dateFormat);
+ const numberFormatter = getNumberFormatter();
Review Comment:
Nit, take it or leave it. The drill filters still go through the smart formatter here, so a numeric entity reads `Drill to detail by 12.3k` in the context menu.
That's what the other ECharts charts do with a default number format, so it's fine to leave. Dropping `numberFormatter` here too would just keep it in line with the chip.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #45223:
URL: https://github.com/apache/superset/pull/45223#issuecomment-6133826998
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/45223?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `97.22222%` with `3 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 83.00%. Comparing base ([`11b6997`](https://app.codecov.io/gh/apache/superset/commit/11b6997a488035cdd050e4f19a9803cdc9c1861d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`18cbf60`](https://app.codecov.io/gh/apache/superset/commit/18cbf6020301043c2bac95ee1ceda8cd3b5ea054?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 4 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/45223?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../plugin-chart-echarts/src/Bubble/EchartsBubble.tsx](https://app.codecov.io/gh/apache/superset/pull/45223?src=pr&el=tree&filepath=superset-frontend%2Fplugins%2Fplugin-chart-echarts%2Fsrc%2FBubble%2FEchartsBubble.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGx1Z2lucy9wbHVnaW4tY2hhcnQtZWNoYXJ0cy9zcmMvQnViYmxlL0VjaGFydHNCdWJibGUudHN4) | 91.66% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/45223?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #45223 +/- ##
========================================
Coverage 82.99% 83.00%
========================================
Files 3026 3027 +1
Lines 195907 196009 +102
Branches 45734 45768 +34
========================================
+ Hits 162594 162694 +100
- Misses 30103 30105 +2
Partials 3210 3210
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/45223/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Ξ | |
|---|---|---|
| [javascript](https://app.codecov.io/gh/apache/superset/pull/45223/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.73% <97.22%> (+0.02%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/45223?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #45223:
URL: https://github.com/apache/superset/pull/45223#issuecomment-6133543782
### <span aria-hidden="true">β
</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">π¨</span> Latest commit | e34facb0a79a4dbb8e7af12417010dd0aab77dc8 |
|<span aria-hidden="true">π</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6acd5a7eaba3fd1c0e06535f |
|<span aria-hidden="true">π</span> Deploy Preview | [https://deploy-preview-45223--superset-docs-preview.netlify.app](https://deploy-preview-45223--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">π±</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">π€</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpBCoAgEADAv-w5yAgN-kGvkHXdrcBSNjtE9Pe8zWFeKJqPUmEG6CAonrQ1C2Ptwx0Se9pQqyfN1-VlT5V1P9d2I5eUnyW27ZCixYkx4ChxIMPG2dEKfD8) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-45223--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4252822188
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,170 @@
+/**
+ * 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 {
+ DataRecordValue,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/** Display text for an empty-string dimension value. */
+export const EMPTY_STRING = '""';
+
+/**
+ * Human-readable text for a dimension value, used for series names, tooltips
+ * and the cross-filter chip. `null` and `''` stay distinguishable because they
+ * produce different filters (`IS NULL` vs `IN ['']`).
+ */
+export function formatBubbleValue(value: DataRecordValue): string {
+ if (value == null) {
+ return NULL_STRING;
+ }
+ const text = String(value);
+ return text === '' ? EMPTY_STRING : text;
+}
+
+export function isBubbleDatum(value: unknown): value is BubbleDatum {
+ return Array.isArray(value) && value.length > SERIES_INDEX;
+}
+
+function toKeyPart(
+ value: DataRecordValue | undefined,
+): string | number | boolean | null {
+ if (value == null) {
+ return null;
+ }
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+ return value instanceof Date ? value.toISOString() : value;
+}
+
+/**
+ * Stable identifier of a bubble, stored in `filterState.selectedValues`.
+ * A JSON array keeps entity and series unambiguous (including `null` vs `''`
+ * and `1` vs `'1'`) and survives serialization into dashboard state.
+ */
+export function getBubbleCrossFilterKey(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const parts = hasSeries
+ ? [toKeyPart(entityValue), toKeyPart(seriesValue)]
+ : [toKeyPart(entityValue)];
+ return JSON.stringify(parts);
+}
+
+export function getBubbleCrossFilterLabel(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const entityPart = formatBubbleValue(entityValue);
+ if (!hasSeries) {
+ return entityPart;
+ }
+ return `${entityPart}, ${formatBubbleValue(seriesValue ?? null)}`;
+}
+
+export function getSelectedBubbleKeys(selectedValues: unknown): string[] {
+ if (!selectedValues) {
+ return [];
+ }
+ if (Array.isArray(selectedValues)) {
+ return selectedValues.map(value => String(value));
+ }
+ if (typeof selectedValues === 'object') {
+ return Object.values(selectedValues as Record<string, unknown>).map(value =>
+ String(value),
+ );
+ }
+ return [];
+}
+
+function dimensionFilter(
+ col: QueryFormColumn,
+ value: DataRecordValue,
+): QueryObjectFilterClause {
+ if (value == null) {
+ return { col, op: 'IS NULL' };
+ }
+ return {
+ col,
+ op: 'IN',
+ val: [value],
+ };
Review Comment:
β
**CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `18cbf60`.
Added `toJsonSafeFilterValue`, which converts `bigint` values to strings before they are placed in the filter's `val` array.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "SBIN2010 (via GitHub)" <gi...@apache.org>.
SBIN2010 commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4263604812
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,229 @@
+/**
+ * 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 {
+ DataRecordValue,
+ getColumnLabel,
+ getNumberFormatter,
+ getTimeFormatter,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+import { formatSeriesName } from '../utils/series';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/**
+ * Display text for an empty string. Matches `optionLabel` in
+ * `src/utils/common.ts`; this plugin cannot import that module.
+ */
+export const EMPTY_STRING = '<empty string>';
+
+/**
+ * Human-readable text for a dimension value, used for series names, tooltips
+ * and the cross-filter chip. `null` and `''` stay distinguishable because they
+ * produce different filters (`IS NULL` vs `IN ['']`).
+ */
+export function formatBubbleValue(value: DataRecordValue): string {
+ if (value == null) {
+ return NULL_STRING;
+ }
+ const text = String(value);
+ return text === '' ? EMPTY_STRING : text;
+}
+
+export function isBubbleDatum(value: unknown): value is BubbleDatum {
+ return Array.isArray(value) && value.length > SERIES_INDEX;
+}
+
+function toKeyPart(
+ value: DataRecordValue | undefined,
+): string | number | boolean | null {
+ if (value == null) {
+ return null;
+ }
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+ return value instanceof Date ? value.toISOString() : value;
+}
+
+/**
+ * Stable identifier of a bubble, stored in `filterState.selectedValues`.
+ * A JSON array keeps entity and series unambiguous (including `null` vs `''`
+ * and `1` vs `'1'`) and survives serialization into dashboard state.
+ */
+export function getBubbleCrossFilterKey(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const parts = hasSeries
+ ? [toKeyPart(entityValue), toKeyPart(seriesValue)]
+ : [toKeyPart(entityValue)];
+ return JSON.stringify(parts);
+}
+
+type CrossFilterLabelFormat = {
+ coltypeMapping?: Record<string, number>;
+ timeFormatter?: ReturnType<typeof getTimeFormatter>;
+ numberFormatter?: ReturnType<typeof getNumberFormatter>;
+};
+
+/**
+ * Chip text for one dimension. An empty string is labeled before
+ * `formatSeriesName`, which would leave it blank. Temporal values use the
+ * same formatter as the drill filters.
+ */
+function formatCrossFilterPart(
+ col: QueryFormColumn,
+ value: DataRecordValue,
+ format: CrossFilterLabelFormat,
+): string {
+ if (value === '') {
+ return EMPTY_STRING;
+ }
+ return formatSeriesName(value, {
+ timeFormatter: format.timeFormatter,
+ numberFormatter: format.numberFormatter,
+ coltype: format.coltypeMapping?.[getColumnLabel(col)],
+ });
+}
+
+export function getBubbleCrossFilterLabel(
+ entity: QueryFormColumn,
+ entityValue: DataRecordValue,
+ series: QueryFormColumn | undefined,
+ seriesValue: DataRecordValue | undefined,
+ format: CrossFilterLabelFormat,
+): string {
+ const entityPart = formatCrossFilterPart(entity, entityValue, format);
+ if (!series) {
+ return entityPart;
+ }
+ return `${entityPart}, ${formatCrossFilterPart(series, seriesValue ?? null, format)}`;
+}
+
+export function getSelectedBubbleKeys(selectedValues: unknown): string[] {
+ if (!selectedValues) {
+ return [];
+ }
+ if (Array.isArray(selectedValues)) {
+ return selectedValues.map(value => String(value));
+ }
+ if (typeof selectedValues === 'object') {
+ return Object.values(selectedValues as Record<string, unknown>).map(value =>
+ String(value),
+ );
+ }
+ return [];
+}
+
+/**
+ * `bigint` throws in `JSON.stringify`, and the data mask is serialized into
+ * dashboard state and the chart-data request.
+ */
+export function toJsonSafeFilterValue(
+ value: Exclude<DataRecordValue, null>,
+): Exclude<DataRecordValue, null | bigint> {
+ return typeof value === 'bigint' ? value.toString() : value;
+}
+
+function dimensionFilter(
+ col: QueryFormColumn,
+ value: DataRecordValue,
+): QueryObjectFilterClause {
+ if (value == null) {
+ return { col, op: 'IS NULL' };
+ }
+ return {
+ col,
+ op: 'IN',
+ val: [toJsonSafeFilterValue(value)],
+ };
+}
+
+export function getBubbleCrossFilterDataMask({
+ entity,
+ series,
+ datum,
+ selectedKeys,
+ coltypeMapping,
+ dateFormat,
+}: {
+ entity: QueryFormColumn;
+ series?: QueryFormColumn;
+ datum: BubbleDatum;
+ selectedKeys: string[];
+ coltypeMapping?: Record<string, number>;
+ dateFormat?: string;
+}) {
+ const hasSeries = Boolean(series);
+ const entityValue = datum[ENTITY_INDEX];
+ const seriesValue = datum[SERIES_INDEX];
+ const key = getBubbleCrossFilterKey(entityValue, seriesValue, hasSeries);
+ const isCurrentValueSelected = selectedKeys.includes(key);
+ const nextKeys = isCurrentValueSelected ? [] : [key];
+ const label = getBubbleCrossFilterLabel(
+ entity,
+ entityValue,
+ hasSeries ? series : undefined,
+ seriesValue,
+ {
+ coltypeMapping,
+ timeFormatter: getTimeFormatter(dateFormat),
+ numberFormatter: getNumberFormatter(),
Review Comment:
fix in f0341f7
Removed getNumberFormatter from crossfilter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #45223:
URL: https://github.com/apache/superset/pull/45223#issuecomment-6133290521
### <span aria-hidden="true">β
</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">π¨</span> Latest commit | ca5022955fb28769711bac3b3e1a45066e90963b |
|<span aria-hidden="true">π</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6acd560890beaf83929a87b7 |
|<span aria-hidden="true">π</span> Deploy Preview | [https://deploy-preview-45223--superset-docs-preview.netlify.app](https://deploy-preview-45223--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">π±</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">π€</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpBCoAgEADAv-w5KIpS-0GvkF1dK7CUzQ4R_T1vc5gXsqQjF5gBGiDB023VgbG0dFNk6zaUYp2k67Jhj4VlP9d6PeeYnsXXPaHz49Rp0xFj0IPpDWpFCr4f) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-45223--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4252757958
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,170 @@
+/**
+ * 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 {
+ DataRecordValue,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/** Display text for an empty-string dimension value. */
+export const EMPTY_STRING = '""';
+
+/**
+ * Human-readable text for a dimension value, used for series names, tooltips
+ * and the cross-filter chip. `null` and `''` stay distinguishable because they
+ * produce different filters (`IS NULL` vs `IN ['']`).
+ */
+export function formatBubbleValue(value: DataRecordValue): string {
+ if (value == null) {
+ return NULL_STRING;
+ }
+ const text = String(value);
+ return text === '' ? EMPTY_STRING : text;
+}
+
+export function isBubbleDatum(value: unknown): value is BubbleDatum {
+ return Array.isArray(value) && value.length > SERIES_INDEX;
+}
+
+function toKeyPart(
+ value: DataRecordValue | undefined,
+): string | number | boolean | null {
+ if (value == null) {
+ return null;
+ }
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+ return value instanceof Date ? value.toISOString() : value;
+}
+
+/**
+ * Stable identifier of a bubble, stored in `filterState.selectedValues`.
+ * A JSON array keeps entity and series unambiguous (including `null` vs `''`
+ * and `1` vs `'1'`) and survives serialization into dashboard state.
+ */
+export function getBubbleCrossFilterKey(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const parts = hasSeries
+ ? [toKeyPart(entityValue), toKeyPart(seriesValue)]
+ : [toKeyPart(entityValue)];
+ return JSON.stringify(parts);
+}
+
+export function getBubbleCrossFilterLabel(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const entityPart = formatBubbleValue(entityValue);
+ if (!hasSeries) {
+ return entityPart;
+ }
+ return `${entityPart}, ${formatBubbleValue(seriesValue ?? null)}`;
+}
+
+export function getSelectedBubbleKeys(selectedValues: unknown): string[] {
+ if (!selectedValues) {
+ return [];
+ }
+ if (Array.isArray(selectedValues)) {
+ return selectedValues.map(value => String(value));
+ }
+ if (typeof selectedValues === 'object') {
+ return Object.values(selectedValues as Record<string, unknown>).map(value =>
+ String(value),
+ );
+ }
+ return [];
+}
+
+function dimensionFilter(
+ col: QueryFormColumn,
+ value: DataRecordValue,
+): QueryObjectFilterClause {
+ if (value == null) {
+ return { col, op: 'IS NULL' };
+ }
+ return {
+ col,
+ op: 'IN',
+ val: [value],
+ };
Review Comment:
β
**CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `e34facb`.
Added `toJsonSafeFilterValue`, which converts `bigint` values to strings before they are placed in the filter's `val` array.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4255952339
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,180 @@
+/**
+ * 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 {
+ DataRecordValue,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/** Display text for an empty-string dimension value. */
+export const EMPTY_STRING = '""';
Review Comment:
The app already has a display convention for this: `EMPTY_STRING = '<empty string>'` in `src/utils/common.ts`, used by `optionLabel` next to `<NULL>`.
A plugin can't import from there, but matching the text would keep a bubble legend from reading `""` while the rest of the app says `<empty string>`.
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,180 @@
+/**
+ * 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 {
+ DataRecordValue,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/** Display text for an empty-string dimension value. */
+export const EMPTY_STRING = '""';
+
+/**
+ * Human-readable text for a dimension value, used for series names, tooltips
+ * and the cross-filter chip. `null` and `''` stay distinguishable because they
+ * produce different filters (`IS NULL` vs `IN ['']`).
+ */
+export function formatBubbleValue(value: DataRecordValue): string {
+ if (value == null) {
+ return NULL_STRING;
+ }
+ const text = String(value);
+ return text === '' ? EMPTY_STRING : text;
+}
+
+export function isBubbleDatum(value: unknown): value is BubbleDatum {
+ return Array.isArray(value) && value.length > SERIES_INDEX;
+}
+
+function toKeyPart(
+ value: DataRecordValue | undefined,
+): string | number | boolean | null {
+ if (value == null) {
+ return null;
+ }
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+ return value instanceof Date ? value.toISOString() : value;
+}
+
+/**
+ * Stable identifier of a bubble, stored in `filterState.selectedValues`.
+ * A JSON array keeps entity and series unambiguous (including `null` vs `''`
+ * and `1` vs `'1'`) and survives serialization into dashboard state.
+ */
+export function getBubbleCrossFilterKey(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const parts = hasSeries
+ ? [toKeyPart(entityValue), toKeyPart(seriesValue)]
+ : [toKeyPart(entityValue)];
+ return JSON.stringify(parts);
+}
+
+export function getBubbleCrossFilterLabel(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const entityPart = formatBubbleValue(entityValue);
Review Comment:
If I'm reading it right, a temporal entity or series arrives here as the raw epoch, so the cross-filter chip would read something like `1704067200000`. The drill filters in `EchartsBubble.tsx` already go through `formatSeriesName` with the column type.
Could the chip label use the same formatter? `coltypeMapping` and `dateFormat` are both in scope where the data mask is built.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "SBIN2010 (via GitHub)" <gi...@apache.org>.
SBIN2010 commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4262083728
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,180 @@
+/**
+ * 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 {
+ DataRecordValue,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/** Display text for an empty-string dimension value. */
+export const EMPTY_STRING = '""';
Review Comment:
fix in [1fd9b58](https://github.com/apache/superset/pull/45223/commits/1fd9b587ca86ed2dd13a5c4e3cc1e3a774f25eb8)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "SBIN2010 (via GitHub)" <gi...@apache.org>.
SBIN2010 commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4263723974
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/EchartsBubble.tsx:
##########
@@ -16,9 +16,71 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { useMemo } from 'react';
+import {
+ ContextMenuFilters,
+ DataRecordValue,
+ getColumnLabel,
+ getNumberFormatter,
+ getTimeFormatter,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
import { BubbleChartTransformedProps } from './types';
import Echart from '../components/Echart';
+import { EventHandlers } from '../types';
import { useLegendEventHandlers } from '../utils/legendEventHandlers';
+import { formatSeriesName } from '../utils/series';
+import {
+ BubbleDatum,
+ ENTITY_INDEX,
+ getBubbleCrossFilterDataMask,
+ getSelectedBubbleKeys,
+ isBubbleDatum,
+ SERIES_INDEX,
+ toJsonSafeFilterValue,
+} from './crossFilter';
+
+const noop = () => {};
+
+type BubbleEvent = {
+ componentType?: string;
+ data?: unknown;
+ event?: { stop: () => void; event: PointerEvent };
+};
+
+function buildDrillFilters(
+ entity: QueryFormColumn,
+ series: QueryFormColumn | undefined,
+ datum: BubbleDatum,
+ dateFormat: string | undefined,
+ coltypeMapping: BubbleChartTransformedProps['coltypeMapping'],
+): QueryObjectFilterClause[] {
+ const columns: Array<{ col: QueryFormColumn; value: DataRecordValue }> = [
+ { col: entity, value: datum[ENTITY_INDEX] },
+ ];
+ if (series) {
+ columns.push({ col: series, value: datum[SERIES_INDEX] });
+ }
+ const timeFormatter = getTimeFormatter(dateFormat);
+ const numberFormatter = getNumberFormatter();
Review Comment:
Let's leave it the same as the other charts for consistency.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #45223:
URL: https://github.com/apache/superset/pull/45223#discussion_r4263412766
##########
superset-frontend/plugins/plugin-chart-echarts/src/Bubble/crossFilter.ts:
##########
@@ -0,0 +1,229 @@
+/**
+ * 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 {
+ DataRecordValue,
+ getColumnLabel,
+ getNumberFormatter,
+ getTimeFormatter,
+ QueryFormColumn,
+ QueryObjectFilterClause,
+} from '@superset-ui/core';
+import { NULL_STRING } from '../constants';
+import { formatSeriesName } from '../utils/series';
+
+/** Scatter point payload: [x, y, size, entity, series]. */
+export type BubbleDatum = [
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+ DataRecordValue,
+];
+
+export const ENTITY_INDEX = 3;
+export const SERIES_INDEX = 4;
+
+/**
+ * Display text for an empty string. Matches `optionLabel` in
+ * `src/utils/common.ts`; this plugin cannot import that module.
+ */
+export const EMPTY_STRING = '<empty string>';
+
+/**
+ * Human-readable text for a dimension value, used for series names, tooltips
+ * and the cross-filter chip. `null` and `''` stay distinguishable because they
+ * produce different filters (`IS NULL` vs `IN ['']`).
+ */
+export function formatBubbleValue(value: DataRecordValue): string {
+ if (value == null) {
+ return NULL_STRING;
+ }
+ const text = String(value);
+ return text === '' ? EMPTY_STRING : text;
+}
+
+export function isBubbleDatum(value: unknown): value is BubbleDatum {
+ return Array.isArray(value) && value.length > SERIES_INDEX;
+}
+
+function toKeyPart(
+ value: DataRecordValue | undefined,
+): string | number | boolean | null {
+ if (value == null) {
+ return null;
+ }
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+ return value instanceof Date ? value.toISOString() : value;
+}
+
+/**
+ * Stable identifier of a bubble, stored in `filterState.selectedValues`.
+ * A JSON array keeps entity and series unambiguous (including `null` vs `''`
+ * and `1` vs `'1'`) and survives serialization into dashboard state.
+ */
+export function getBubbleCrossFilterKey(
+ entityValue: DataRecordValue,
+ seriesValue: DataRecordValue | undefined,
+ hasSeries: boolean,
+): string {
+ const parts = hasSeries
+ ? [toKeyPart(entityValue), toKeyPart(seriesValue)]
+ : [toKeyPart(entityValue)];
+ return JSON.stringify(parts);
+}
+
+type CrossFilterLabelFormat = {
+ coltypeMapping?: Record<string, number>;
+ timeFormatter?: ReturnType<typeof getTimeFormatter>;
+ numberFormatter?: ReturnType<typeof getNumberFormatter>;
+};
+
+/**
+ * Chip text for one dimension. An empty string is labeled before
+ * `formatSeriesName`, which would leave it blank. Temporal values use the
+ * same formatter as the drill filters.
+ */
+function formatCrossFilterPart(
+ col: QueryFormColumn,
+ value: DataRecordValue,
+ format: CrossFilterLabelFormat,
+): string {
+ if (value === '') {
+ return EMPTY_STRING;
+ }
+ return formatSeriesName(value, {
+ timeFormatter: format.timeFormatter,
+ numberFormatter: format.numberFormatter,
+ coltype: format.coltypeMapping?.[getColumnLabel(col)],
+ });
+}
+
+export function getBubbleCrossFilterLabel(
+ entity: QueryFormColumn,
+ entityValue: DataRecordValue,
+ series: QueryFormColumn | undefined,
+ seriesValue: DataRecordValue | undefined,
+ format: CrossFilterLabelFormat,
+): string {
+ const entityPart = formatCrossFilterPart(entity, entityValue, format);
+ if (!series) {
+ return entityPart;
+ }
+ return `${entityPart}, ${formatCrossFilterPart(series, seriesValue ?? null, format)}`;
+}
+
+export function getSelectedBubbleKeys(selectedValues: unknown): string[] {
+ if (!selectedValues) {
+ return [];
+ }
+ if (Array.isArray(selectedValues)) {
+ return selectedValues.map(value => String(value));
+ }
+ if (typeof selectedValues === 'object') {
+ return Object.values(selectedValues as Record<string, unknown>).map(value =>
+ String(value),
+ );
+ }
+ return [];
+}
+
+/**
+ * `bigint` throws in `JSON.stringify`, and the data mask is serialized into
+ * dashboard state and the chart-data request.
+ */
+export function toJsonSafeFilterValue(
+ value: Exclude<DataRecordValue, null>,
+): Exclude<DataRecordValue, null | bigint> {
+ return typeof value === 'bigint' ? value.toString() : value;
+}
+
+function dimensionFilter(
+ col: QueryFormColumn,
+ value: DataRecordValue,
+): QueryObjectFilterClause {
+ if (value == null) {
+ return { col, op: 'IS NULL' };
+ }
+ return {
+ col,
+ op: 'IN',
+ val: [toJsonSafeFilterValue(value)],
+ };
+}
+
+export function getBubbleCrossFilterDataMask({
+ entity,
+ series,
+ datum,
+ selectedKeys,
+ coltypeMapping,
+ dateFormat,
+}: {
+ entity: QueryFormColumn;
+ series?: QueryFormColumn;
+ datum: BubbleDatum;
+ selectedKeys: string[];
+ coltypeMapping?: Record<string, number>;
+ dateFormat?: string;
+}) {
+ const hasSeries = Boolean(series);
+ const entityValue = datum[ENTITY_INDEX];
+ const seriesValue = datum[SERIES_INDEX];
+ const key = getBubbleCrossFilterKey(entityValue, seriesValue, hasSeries);
+ const isCurrentValueSelected = selectedKeys.includes(key);
+ const nextKeys = isCurrentValueSelected ? [] : [key];
+ const label = getBubbleCrossFilterLabel(
+ entity,
+ entityValue,
+ hasSeries ? series : undefined,
+ seriesValue,
+ {
+ coltypeMapping,
+ timeFormatter: getTimeFormatter(dateFormat),
+ numberFormatter: getNumberFormatter(),
Review Comment:
With no format passed, `getNumberFormatter()` is the smart formatter, so a numeric entity gets abbreviated on the chip. An id like `12345` reads `12.3k` and a year like `2024` reads `2.02k`, while the legend and tooltip still show the full number.
Could the chip leave `numberFormatter` out? `formatSeriesName` falls back to `toString()` without it, and the temporal path doesn't use it. A test with a numeric entity would pin it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(plugin-chart-echarts): add cross-filtering to the Bubble chart [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #45223:
URL: https://github.com/apache/superset/pull/45223#issuecomment-6133386754
## CodeAnt PR Risk: High Risk
- The PR should not merge yet because EchartsBubble.tsx declares eventHandlers twice and passes the prop twice, causing a compilation failure.
- crossFilter.ts also puts bigint values directly into filter clauses, which can fail when dashboard state is JSON-serialized.
**Assessed commit:** `c93888a98398`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org