Skip to content
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

feat: Add line width unit control in deckgl Polygon and Path #24755

Merged
merged 6 commits into from
Jul 27, 2023

Conversation

kgabryje
Copy link
Member

SUMMARY

Currently the default unit of line width in deckgl Path and Polygon charts is meter. That leads to some confusion, especially in large scale maps, because users might think that the line is not drawn at all - while in reality it's simply too thin to be visible. This PR addresses that problem by changing the default unit from meters to pixels.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen.Recording.2023-07-20.at.15.23.21.mov

TESTING INSTRUCTIONS

  1. Create a deckgl Path chart
  2. Verify that the default line width unit is pixels and default line width is 1 and that drawn line is visible
  3. Verify a deckgl Polygons chart
  4. Check "Stroked" and uncheck "Extruded"
  5. Verify that line between polygons is visible
  6. Verify that existing charts still use meters unit

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
      Current: 0.12 s
      10+: 0.12 s
      100+: 0.21 s
      1000+: 0.13 s
  • Introduces new feature or API
  • Removes existing feature or API

@kgabryje kgabryje requested a review from a team as a code owner July 20, 2023 13:26
@kgabryje kgabryje force-pushed the feat/deckgl-path-width-units branch from 00ea75d to a2bb699 Compare July 20, 2023 16:20
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #24755 (99e2ae1) into master (b8a3eef) will increase coverage by 1.74%.
The diff coverage is n/a.

❗ Current head 99e2ae1 differs from pull request most recent head f517ac6. Consider uploading reports for the commit f517ac6 to get more accurate results

@@            Coverage Diff             @@
##           master   #24755      +/-   ##
==========================================
+ Coverage   67.17%   68.92%   +1.74%     
==========================================
  Files        1902     1902              
  Lines       73939    73939              
  Branches     8176     8176              
==========================================
+ Hits        49672    50965    +1293     
+ Misses      22154    20861    -1293     
  Partials     2113     2113              
Flag Coverage Δ
hive 54.14% <ø> (ø)
javascript 55.76% <ø> (ø)
mysql 79.19% <ø> (ø)
postgres 79.28% <ø> (-0.02%) ⬇️
presto 54.03% <ø> (?)
python 83.30% <ø> (+3.65%) ⬆️
sqlite ?
unit 54.96% <ø> (?)

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

Impacted Files Coverage Δ
...et-chart-deckgl/src/layers/Geojson/controlPanel.ts 50.00% <ø> (ø)
...egacy-preset-chart-deckgl/src/layers/Path/Path.jsx 0.00% <ø> (ø)
...reset-chart-deckgl/src/layers/Path/controlPanel.ts 50.00% <ø> (ø)
...preset-chart-deckgl/src/layers/Polygon/Polygon.jsx 0.00% <ø> (ø)
...et-chart-deckgl/src/layers/Polygon/controlPanel.ts 33.33% <ø> (ø)
...reset-chart-deckgl/src/utilities/Shared_DeckGL.jsx 86.48% <ø> (ø)
superset/examples/deck.py 0.00% <ø> (ø)

... and 103 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Slice.viz_type == "deck_polygon",
)
):
params = json.loads(slc.params)
Copy link
Member

Choose a reason for hiding this comment

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

@kgabryje would you mind adding a try/except around the json.loads(...) block as there could be instances where the JSON payload is corrupted. See #24737 for details.

if not params.get("line_width_unit"):
params["line_width_unit"] = "meters"
slc.params = json.dumps(params)
session.merge(slc)
Copy link
Member

Choose a reason for hiding this comment

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

There's no need to do a session.merge(...) here. Typically merge is used when you may have more than one in-memory objects which map to the same database record with some key.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for explanation!

params = json.loads(slc.params)
if not params.get("line_width_unit"):
params["line_width_unit"] = "meters"
slc.params = json.dumps(params)
Copy link
Member

Choose a reason for hiding this comment

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

Also per #24737 it's probably best to only update slc.params if the parameters were updated. There's likely only a handful of charts which need upgrading and thus there's no need to update them all—which adds unnecessary effort on the database.

Copy link
Member

Choose a reason for hiding this comment

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

I assume that this will impact nearly all charts that are found by the filter clause. But I agree, adding the indentation here is more prudent and will avoid unnecessary db work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that's exactly the case, but you're right - for the sake of code quality I added the indent

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

One remark to complement John's review comments.

@@ -387,6 +387,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements
"stroked": False,
"extruded": True,
"multiplier": 0.1,
"line_width": 10,
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we also add "line_width_unit": "meters" here, as the default unit is now being changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch!

params = json.loads(slc.params)
if not params.get("line_width_unit"):
params["line_width_unit"] = "meters"
slc.params = json.dumps(params)
Copy link
Member

Choose a reason for hiding this comment

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

I assume that this will impact nearly all charts that are found by the filter clause. But I agree, adding the indentation here is more prudent and will avoid unnecessary db work.

@kgabryje kgabryje force-pushed the feat/deckgl-path-width-units branch from 2c59e03 to f517ac6 Compare July 24, 2023 13:15
Comment on lines -111 to +110
[extruded, multiplier],
[lineWidth, null],
[extruded],
[multiplier],
[lineWidth],
Copy link
Member

Choose a reason for hiding this comment

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

Finally these are split onto their own rows 👏

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to do the same in the rest of deckgl plugins in upcoming PRs, no more controls squished in 1 row 😄

@kgabryje kgabryje merged commit d26ea98 into apache:master Jul 27, 2023
29 checks passed
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants