Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Reuse hex code from dataset for scales (#1071)
Browse files Browse the repository at this point in the history
Co-authored-by: Ilfat Galiev <v-ilgaliev@microsoft.com>
  • Loading branch information
zBritva and Ilfat Galiev committed Jun 2, 2023
1 parent 18b5d19 commit ab8bc02
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/app/stores/app_store.ts
Expand Up @@ -1381,20 +1381,30 @@ export class AppStore extends BaseStore {
extendScale = true;
reuseRange = true;
} else {
values = this.chartManager.getGroupedExpressionVector(
mapping.mapping.table,
groupBy,
mapping.mapping.expression
);
if (scale.classID == "scale.categorical<string,color>") {
newScale = true;
extendScale = true;
reuseRange = true;
const hexColor = new RegExp("^#[0-9,a-f,A-F]{6}");
// if values hex codes of color, charticulator should not use current range
// need to update scale's hex codes from data
if (
values.every(
(val: string) => typeof val === "string" && hexColor.test(val)
)
) {
reuseRange = false;
}
} else {
newScale = false;
extendScale = true;
reuseRange = true;
}
values = this.chartManager.getGroupedExpressionVector(
mapping.mapping.table,
groupBy,
mapping.mapping.expression
);
}
scaleClass.inferParameters(values as any, {
newScale,
Expand Down

0 comments on commit ab8bc02

Please sign in to comment.