Skip to content

feat(deckgl): add new color controls with color breakpoints #34017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jul 11, 2025

Conversation

DamianPendrak
Copy link
Contributor

@DamianPendrak DamianPendrak commented Jul 1, 2025

SUMMARY

Add new Controls that handle fixed colors, palette, and color breakpoints based on selection. Implement new color breakpoints Control to set colors of the Deck.gl Charts based on the Metric value.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screenshot 2025-07-01 at 20 33 12

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link

korbit-ai bot commented Jul 1, 2025

Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment /korbit-review.

Your admin can change your review schedule in the Korbit Console

@DamianPendrak DamianPendrak marked this pull request as ready for review July 3, 2025 13:51
@dosubot dosubot bot added the viz:charts:deck.gl Related to deck.gl charts label Jul 3, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Functionality Missing Color Breakpoints Validation ▹ view 🧠 Not in standard
Design Redundant Interface Properties ▹ view 🧠 Not in scope
Functionality Conflicting popover control props ▹ view 🧠 Not in scope
Design Mixed Layer and Aggregation Logic ▹ view 🧠 Not in scope
Readability Misleading Component Name ▹ view 🧠 Incorrect
Readability Unexplained Empty Function Prop ▹ view 🧠 Incorrect
Documentation Missing color scheme type usage guidance ▹ view 🧠 Not in scope
Functionality Incomplete Drag and Drop Implementation ▹ view 🧠 Incorrect
Design Array Indices Used As IDs ▹ view 🧠 Not in standard
Readability Ambiguous boolean parameter name ▹ view 🧠 Not in scope
Files scanned

Due to the exceptionally large size of this PR, I've limited my review to the following files:

File Path Reviewed
superset-frontend/plugins/legacy-preset-chart-deckgl/src/types.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/utils.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Grid/controlPanel.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Hex/controlPanel.ts
superset-frontend/src/explore/components/controls/ContourControl/ContourOption.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Heatmap/Heatmap.tsx
superset-frontend/src/explore/components/controls/ColorBreakpointsControl/ColorBreakpointPopoverTrigger.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Screengrid/controlPanel.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/components/Legend.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Arc/Arc.tsx
superset-frontend/src/explore/components/controls/ColorBreakpointsControl/ColorBreakpointOption.tsx
superset-frontend/src/explore/components/controls/index.js
superset-frontend/src/explore/components/controls/ColorBreakpointsControl/types.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Scatter/controlPanel.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Grid/Grid.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Heatmap/controlPanel.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Hex/Hex.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/factory.tsx
superset-frontend/src/explore/components/controls/ColorBreakpointsControl/index.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/controlPanel.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/common.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Arc/controlPanel.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/utils.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Screengrid/Screengrid.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/CategoricalDeckGLContainer.tsx
superset-frontend/plugins/legacy-preset-chart-deckgl/src/layers/Polygon/Polygon.tsx
superset-frontend/src/explore/components/controls/ColorBreakpointsControl/ColorBreakpointPopoverControl.tsx
superset-frontend/packages/superset-ui-chart-controls/src/types.ts
superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.tsx

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

['color_scheme'],
...generateDeckGLColorSchemeControls({
defaultSchemeType: COLOR_SCHEME_TYPES.categorical_palette,
disableCategoricalColumn: true,

This comment was marked as resolved.

Comment on lines 107 to 116
name: 'color_scheme_type',
config: {
type: 'SelectControl',
label: t('Color Scheme Type'),
clearable: false,
validators: [],
choices: [
[COLOR_SCHEME_TYPES.fixed_color, t('Fixed color')],
[COLOR_SCHEME_TYPES.linear_palette, t('Linear palette')],
],
default: COLOR_SCHEME_TYPES.linear_palette,
},

This comment was marked as resolved.

Comment on lines +52 to +53
defaultOpen={visible}
open={visible}

This comment was marked as resolved.

Comment on lines +83 to +86
const colorAggFunc =
colorSchemeType === COLOR_SCHEME_TYPES.color_breakpoints
? (p: number[]) => getColorForBreakpoints(aggFunc, p, colorBreakpoints)
: aggFunc;

This comment was marked as resolved.

Comment on lines 81 to +86
const aggFunc = getAggFunc(fd.js_agg_function, p => p.weight);

const colorAggFunc =
colorSchemeType === COLOR_SCHEME_TYPES.color_breakpoints
? (p: number[]) => getColorForBreakpoints(aggFunc, p, colorBreakpoints)
: aggFunc;

This comment was marked as resolved.

Comment on lines +48 to +67
export interface ColorBreakpointsPopoverTriggerProps {
description?: string;
hovered?: boolean;
value?: ColorBreakpointType;
children?: ReactNode;
saveColorBreakpoint: (colorBreakpoint: ColorBreakpointType) => void;
isControlled?: boolean;
visible?: boolean;
toggleVisibility?: (visibility: boolean) => void;
colorBreakpoints: ColorBreakpointType[];
}

export interface ColorBreakpointsPopoverControlProps {
description?: string;
hovered?: boolean;
value?: ColorBreakpointType;
onSave?: (colorBreakpoint: ColorBreakpointType) => void;
onClose?: () => void;
colorBreakpoints: ColorBreakpointType[];
}

This comment was marked as resolved.


const DEFAULT_COLOR_BREAKPOINTS: ColorBreakpointType[] = [];

const NewContourFormatPlaceholder = styled('div')`

This comment was marked as resolved.

colorBreakpoints={colorBreakpoints}
index={index}
onClose={removeColorBreakpoint}
onShift={() => {}}

This comment was marked as resolved.

Comment on lines 106 to 107
onDrop={() => {}}
canDrop={() => true}

This comment was marked as resolved.

Comment on lines +74 to +84
const editColorBreakpoint = (
breakpoint: ColorBreakpointType,
index: number,
) => {
const newBreakpoints = [...colorBreakpoints];
newBreakpoints[index] = {
...breakpoint,
id: index,
};
setColorBreakpoints(newBreakpoints);
};

This comment was marked as resolved.

@DamianPendrak DamianPendrak force-pushed the deckgl-metric-color-update branch 5 times, most recently from 0d197a2 to 2503e14 Compare July 8, 2025 16:40
@rusackas
Copy link
Member

rusackas commented Jul 9, 2025

Very cool! Looks like it needs a rebase, but I'll spin up a test environment in the meantime.

Copy link
Contributor

github-actions bot commented Jul 9, 2025

@rusackas Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments

Copy link
Contributor

github-actions bot commented Jul 9, 2025

@rusackas Ephemeral environment spinning up at http://34.214.104.35:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup.

@kgabryje
Copy link
Member

kgabryje commented Jul 9, 2025

Looks very cool!
A few questions:

  1. Changing the color breakpoints and scheme types prompts to run a new query. Could we make it so that the changes are reflected immediately?
  2. Could you add tooltips to the new controls?
  3. After I added the breakpoints, the values that don't match any breakpoint take the color of the first breakpoint, which could be confusing (screenshot - the value 2415 and the values below 1000 use the color of 1000-1500 breakpoint). Maybe we should add a default color control?
image

@@ -190,3 +192,19 @@ export function getBuckets(

return buckets;
}

export function getColorBreakpointsBuckets(fd: QueryFormData) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe this function could accepts only the breakpoints as the argument instead of the whole form data object? That way we might avoid some rerenders caused by passing form data to a dependency array in useEffect

/* eslint camelcase: 0 */

export function formatSelectOptions(options: (string | number)[]) {
return options.map(opt => [opt, opt.toString()]);
}

export const getSelectedColorSchemeType = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this function? Can't we just call formData.color_scheme_type directly?

height: ${({ theme }) => theme.sizeUnit * 3}px;
border-radius: ${({ theme }) => theme.sizeUnit / 2}px;
background: ${(props: { color: string }) => props.color};
margin-right: ${({ theme }) => theme.sizeUnit * 1.5}px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the full size units? Whatever looks better, theme.sizeUnit or theme.sizeUnit *2

@DamianPendrak
Copy link
Contributor Author

Very cool! Looks like it needs a rebase, but I'll spin up a test environment in the meantime.

Thanks @rusackas! It does, but the bump of the deck.gl dependencies in #33603 broke the deck.gl charts for me on local env in the master branch. Is it just me, or should I revert the deck.gl packages versions bump on this branch?

Screenshot 2025-07-09 at 15 56 44

@amaannawab923
Copy link
Contributor

Same here , it breaks on local setup @DamianPendrak , #33603 ... tried to fix it while maintaining the changes from the open street maps ... but it keeps on breaking

@DamianPendrak DamianPendrak force-pushed the deckgl-metric-color-update branch from 11f614b to cb93580 Compare July 10, 2025 11:53
@github-actions github-actions bot added doc Namespace | Anything related to documentation dependencies:npm labels Jul 10, 2025
Copy link

codecov bot commented Jul 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.98%. Comparing base (7d0fabe) to head (7044d15).
Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #34017       +/-   ##
===========================================
+ Coverage        0   72.98%   +72.98%     
===========================================
  Files           0      559      +559     
  Lines           0    40516    +40516     
  Branches        0     4267     +4267     
===========================================
+ Hits            0    29571    +29571     
- Misses          0     9836     +9836     
- Partials        0     1109     +1109     
Flag Coverage Δ
hive 47.14% <100.00%> (?)
mysql 71.97% <100.00%> (?)
postgres 72.03% <100.00%> (?)
presto 50.89% <100.00%> (?)
python 72.94% <100.00%> (?)
sqlite 71.56% <100.00%> (?)
unit 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -84,6 +84,9 @@ export const getLayer: GetLayerType<HexagonLayer> = function ({
? (p: number[]) => getColorForBreakpoints(aggFunc, p, colorBreakpoints)
: aggFunc;

console.log('colorBreakpoints', colorBreakpoints);
console.log('colorRange', colorRange);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the console logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@kgabryje Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments

Copy link
Contributor

@kgabryje Ephemeral environment spinning up at http://54.203.127.237:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! LGTM

@rusackas rusackas merged commit 7229e1c into apache:master Jul 11, 2025
62 checks passed
@mistercrunch
Copy link
Member

Looks like this PR has bad merge conflicts and reverted things that were set up in #33603 (comment).

@DamianPendrak
Copy link
Contributor Author

@mistercrunch yes, I didn't manage to bring back the revert before merging to master, as I explained in #34123 (comment)

@mistercrunch
Copy link
Member

mistercrunch commented Jul 15, 2025

Oh so this was this intentional then? Not sure if the reviewer/merger knew we were reverting a PR as part of this one.

I created #34176 thinking this was a mistake, but unclear if / what is the path forward. I'm not sure why these 2 PRs had to be mutually exclusive but you all should work on a fix, happy to review.

@DamianPendrak
Copy link
Contributor Author

I'm sorry, I didn't communicate that here, my mistake. I was going to bring back the reverted PR, but it got merged before passing QA. The #33603 breaks all deck.gl Charts on local environment, but I thought it breaks on ephemeral too, so I reverted it

@mistercrunch
Copy link
Member

Oh I wasn't clear on #33603 breaking deck.gl - are we sure that's the case?

@DamianPendrak
Copy link
Contributor Author

Yes, only breaking local environment with Docker is confirmed. Not sure about ephemeral env, but @amaannawab923 says it should work on ephemeral as building with npm run build works

@mistercrunch
Copy link
Member

Good to know, do we know more about what's happening? I think I see this in my console:

Uncaught TypeError: Cannot read properties of null (reading 'stack')
    at eval (overlay.js:608:17)

But there are so many other messages in the damn console that I can't tell if that's the actual/exact issue. We'll take on cleaning up the console, but in the meantime we should get to the bottom of this....

So somehow npm run build works and npm run dev leads to that msg?

@amaannawab923
Copy link
Contributor

@mistercrunch
The Reason for this is , somehow the node modules are getting deleted on local environment , some problem with versioning and it tries to find those dependancies within node modules in local dev environment and when it doesnt , it throws out the error "Module not found"
I tried patching it multiple times with missing methods and dependancies , Even going inside Node modules folder and editing the source code to make it work but it doesnt work out

@amaannawab923
Copy link
Contributor

But somehow if i do npm run build and use bundled code , i stopped getting those errors and thats how i was able to implement this dark theme for deck gl maps
Screenshot 2025-07-09 at 1 23 54 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies:npm doc Namespace | Anything related to documentation packages plugins size/XXL testenv-up viz:charts:deck.gl Related to deck.gl charts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants