Skip to content

Commit

Permalink
fix: Removes trailing and leading special chars from value dimension …
Browse files Browse the repository at this point in the history
…label (#10)

* fix: Updated build

* fix: Regex espression to remove trailing and leading special chars from value dimension label

* update: Separated trimming special chars into a function and set REGEX as constant
  • Loading branch information
andres-rubio-go authored Jul 5, 2023
1 parent 43bff12 commit 4b50f5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion radialgauge_v2.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/viz_gauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import SSF from 'ssf';

const DEFAULT_MAX_RANGE = null;

const LEADING_TRAILING_SPECIAL_CHARS_REGEX = /(^| +)[!-\/:-@\[-`\{-~]*([^ ]*?)[!-\/:-@\[-`\{-~]*(?=\s|$)/gi;

function processPivot(data, queryResponse, config, viz, pivotKey) {
data = data.length === undefined ? [data] : data;
let dims, meas;
Expand Down Expand Up @@ -136,7 +138,7 @@ function processPivot(data, queryResponse, config, viz, pivotKey) {
value_dimension:
config.value_label_override === undefined ||
config.value_label_override === ''
? pivotKey
? trimTrailingLeadingSpecialChars(pivotKey)
: config.value_label_override,
target: tarValue,
target_rendered: tarRendered,
Expand All @@ -150,6 +152,10 @@ function processPivot(data, queryResponse, config, viz, pivotKey) {
return chunk;
}

function trimTrailingLeadingSpecialChars(str) {
return str.replace(LEADING_TRAILING_SPECIAL_CHARS_REGEX, '$1$2');
}

function processData(data, queryResponse, config, viz) {
data = data.length === undefined ? [data] : data;
let dims, meas;
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1886,9 +1886,9 @@ caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
integrity sha512-SNiAsLnpLkqPyWyCZW0N44gTXRUyGh45TX9dif9gzlvbTWzCOP5jrnygvyjsJJvCRhnC9XHq49jX/IO2p0mVZw==

caniuse-lite@^1.0.30001043:
version "1.0.30001046"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001046.tgz#7a06d3e8fd8aa7f4d21c9a2e313f35f2d06b013e"
integrity sha512-CsGjBRYWG6FvgbyGy+hBbaezpwiqIOLkxQPY4A4Ea49g1eNsnQuESB+n4QM0BKii1j80MyJ26Ir5ywTQkbRE4g==
version "1.0.30001506"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001506.tgz"
integrity sha512-6XNEcpygZMCKaufIcgpQNZNf00GEqc7VQON+9Rd0K1bMYo8xhMZRAo5zpbnbMNizi4YNgIDAFrdykWsvY3H4Hw==

caseless@~0.12.0:
version "0.12.0"
Expand Down

0 comments on commit 4b50f5a

Please # to comment.