Skip to content

Commit

Permalink
fix: scale domain when default undefined (#2636)
Browse files Browse the repository at this point in the history
* fix: domain default undefined

* chore: add changeset
  • Loading branch information
lvisei authored Nov 13, 2024
1 parent 99ce570 commit c9db10a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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

0 comments on commit c9db10a

Please sign in to comment.