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

Reuse hex code from dataset for scales #1071

Merged
merged 1 commit into from
Jun 2, 2023
Merged
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
20 changes: 15 additions & 5 deletions src/app/stores/app_store.ts
Original file line number Diff line number Diff line change
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
Loading