Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Removes trailing and leading special chars from value dimension label #10

Merged
Show file tree
Hide file tree
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
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