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

Carto: Support styling layer by color column #8177

Merged
merged 10 commits into from
Oct 24, 2023

Conversation

Josmorsot
Copy link
Collaborator

Background

Allow to style a layer using the a color property.

Change List

  • support for HexColor column in fetchMap

@Josmorsot Josmorsot requested a review from felixpalmer October 6, 2023 11:54
modules/carto/src/api/layer-map.ts Outdated Show resolved Hide resolved
@Josmorsot Josmorsot requested a review from felixpalmer October 10, 2023 07:48
@@ -380,6 +372,33 @@ export function getColorAccessor(
return normalizeAccessor(accessor, data);
}

export function getDomainAndScaleColor(name, scaleType, range, data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need to introduce this new function? I feel it just makes the code harder to follow

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't need but I think that it's more clear than having a long function. This function is just calculating the domain and scaleColor for each case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, but can your rename to calculateLayerScale, remove the export and put these three lines in the helper function:

scale.domain(domain);
scale.range(scaleColor);
scale.unknown(UNKNOWN_COLOR);

and then just return the scale

modules/carto/src/api/layer-map.ts Outdated Show resolved Hide resolved
@Josmorsot Josmorsot requested a review from felixpalmer October 23, 2023 07:41
@@ -380,6 +372,33 @@ export function getColorAccessor(
return normalizeAccessor(accessor, data);
}

export function getDomainAndScaleColor(name, scaleType, range, data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, but can your rename to calculateLayerScale, remove the export and put these three lines in the helper function:

scale.domain(domain);
scale.range(scaleColor);
scale.unknown(UNKNOWN_COLOR);

and then just return the scale

@felixpalmer felixpalmer marked this pull request as ready for review October 23, 2023 16:52
@Josmorsot Josmorsot merged commit b46d59b into master Oct 24, 2023
2 checks passed
@Josmorsot Josmorsot deleted the feature/sc-353849/apply-hexcolor-to-deck-gl-fetchmap branch October 24, 2023 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants