Skip to content

Commit

Permalink
Fix: stacked area chart for non string dimension values (#4859)
Browse files Browse the repository at this point in the history
* Fix: stacked area chart for non string dimension values

* Disable lint for regex
  • Loading branch information
djbarnwal authored and ericpgreen2 committed May 8, 2024
1 parent 2438e8f commit c1ca7e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web-common/src/features/charts/templates/build-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface ChartField {
// for custom tooltip field names
tooltipName?: string;
// for mapping nominal values to colors
values?: (string | null)[];
values?: (number | undefined | string | null)[];
}

export function buildVegaLiteSpec(
Expand Down
13 changes: 8 additions & 5 deletions web-common/src/features/charts/templates/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ export function multiLayerBaseSpec() {
return baseSpec;
}

export function sanitizeValueForVega(value: string | null) {
return value
? value.replace(/[\.\-\{\}\[\]]/g, (match) => `\\${match}`) //eslint-disable-line
: String(value);
export function sanitizeValueForVega(value: unknown) {
if (typeof value === "string") {
return value.replace(/[\.\-\{\}\[\]]/g, (match) => `\\${match}`); //eslint-disable-line
} else {
return String(value);
}
}
export function sanitizeValuesForSpec(values: (string | null)[]) {

export function sanitizeValuesForSpec(values: unknown[]) {
return values.map((value) => sanitizeValueForVega(value));
}

2 comments on commit c1ca7e5

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Published on https://ui.rilldata.com as production
🚀 Deployed on https://663c4147cf3402462c561fa2--rill-ui.netlify.app

Please sign in to comment.