Skip to content

Commit

Permalink
fix: domain default undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Nov 13, 2024
1 parent 99ce570 commit ef5e3eb
Showing 1 changed file with 7 additions and 4 deletions.
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 ef5e3eb

Please sign in to comment.