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

fix: scale domain when default undefined #2636

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/heavy-glasses-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/l7-layers': patch
---

fix: scale domain when default undefined
11 changes: 7 additions & 4 deletions packages/layers/src/plugins/FeatureScalePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@ export default class FeatureScalePlugin implements ILayerPlugin {
data?: IParseDataItem[],
) {
const cfg: IScale = {
...scaleOption,
type,
};

if (cfg?.domain) return cfg;

// quantile domain 需要根据ID 进行去重
let values = [];
if (type === ScaleTypes.QUANTILE) {
Expand All @@ -266,9 +270,7 @@ export default class FeatureScalePlugin implements ILayerPlugin {
values = data?.map((item) => item[field]) || [];
}

if (scaleOption?.domain) {
cfg.domain = scaleOption?.domain;
} else if (type === ScaleTypes.CAT || type === ScaleTypes.IDENTITY) {
if (type === ScaleTypes.CAT || type === ScaleTypes.IDENTITY) {
cfg.domain = uniq(values);
} else if (type === ScaleTypes.QUANTILE) {
cfg.domain = values;
Expand All @@ -281,7 +283,8 @@ export default class FeatureScalePlugin implements ILayerPlugin {
// linear/Power/log
cfg.domain = extent(values);
}
return { ...cfg, ...scaleOption };

return cfg;
}

// 创建Scale 实例
Expand Down
Loading