Skip to content

Commit b15754a

Browse files
authored
fix: use Giraffe's unit prefix formatters correctly (#4193)
1 parent c5e281b commit b15754a

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"@docsearch/react": "^3.0.0-alpha.37",
162162
"@influxdata/clockface": "^3.5.2",
163163
"@influxdata/flux-lsp-browser": "0.8.8",
164-
"@influxdata/giraffe": "^2.24.3",
164+
"@influxdata/giraffe": "^2.25.0",
165165
"@influxdata/influxdb-templates": "0.9.0",
166166
"@influxdata/react-custom-scrollbars": "4.3.8",
167167
"abortcontroller-polyfill": "^1.3.0",

src/visualization/utils/getFormatter.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ describe('getFormatter', () => {
1111
prefix: 'prefix ',
1212
suffix: ' suffix',
1313
base: '10' as Base,
14-
format: true,
1514
}
1615

1716
const formatter = getFormatter('number', formatterOptions)
@@ -32,22 +31,21 @@ describe('getFormatter', () => {
3231

3332
const formattedValue = formatter(100000)
3433

35-
expect(formattedValue).toBe('prefix 100k suffix')
34+
expect(formattedValue).toBe('prefix 100000 suffix')
3635
})
3736

3837
it("should format correctly for base 2 'number' columntype", function() {
3938
const formatterOptions = {
4039
prefix: 'prefix ',
4140
suffix: ' suffix',
4241
base: '2' as Base,
43-
format: false,
4442
}
4543

4644
const formatter = getFormatter('number', formatterOptions)
4745

4846
const formattedValue = formatter(100000)
4947

50-
expect(formattedValue).toBe('prefix 100000 suffix')
48+
expect(formattedValue).toBe('prefix 97.6563 K suffix')
5149
})
5250

5351
// time column type

src/visualization/utils/getFormatter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ export const getFormatter = (
2828
timeZone,
2929
trimZeros = true,
3030
timeFormat = DEFAULT_TIME_FORMAT,
31-
format,
3231
}: GetFormatterOptions = {}
3332
): null | ((x: any) => string) => {
3433
if (columnType === 'number' && base === '2') {
3534
return binaryPrefixFormatter({
3635
prefix,
3736
suffix,
3837
significantDigits: VIS_SIG_DIGITS,
39-
format,
38+
format: true,
4039
})
4140
}
4241

@@ -46,7 +45,7 @@ export const getFormatter = (
4645
suffix,
4746
significantDigits: VIS_SIG_DIGITS,
4847
trimZeros,
49-
format,
48+
format: true,
5049
})
5150
}
5251

@@ -56,7 +55,7 @@ export const getFormatter = (
5655
suffix,
5756
significantDigits: VIS_SIG_DIGITS,
5857
trimZeros,
59-
format: true,
58+
format: false,
6059
})
6160
}
6261

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,10 +1197,10 @@
11971197
resolved "https://registry.yarnpkg.com/@influxdata/flux-lsp-browser/-/flux-lsp-browser-0.8.8.tgz#6a8476fc7bab8ea4a7cf08a7ef27438e20934d6f"
11981198
integrity sha512-SiDmq0Ygghqp3qj/M9r6TA8Gn3yYmiskmhXNWemzJbjs4uLDmkiyTCWCC+I1a+dQPWJqnNK57EW4UkXcY+mPIA==
11991199

1200-
"@influxdata/giraffe@^2.24.3":
1201-
version "2.24.3"
1202-
resolved "https://registry.yarnpkg.com/@influxdata/giraffe/-/giraffe-2.24.3.tgz#47e3979085c2ee5bdd8a9745d232284004ca501d"
1203-
integrity sha512-Vtf9PxvGgsCkzI/w83vTNvylDECw1/0nYrH57tpiAB07zyfjPWQsctyadGBSt4WO0CoK+wu/xk1XVCJDN2kxXw==
1200+
"@influxdata/giraffe@^2.25.0":
1201+
version "2.25.0"
1202+
resolved "https://registry.yarnpkg.com/@influxdata/giraffe/-/giraffe-2.25.0.tgz#b042462c33ac112e144c6a0f6144b230629c124e"
1203+
integrity sha512-cLlR8xTSCCaZJGPlg6ZRZDLyb+PW3aCYHZeFG16I03Zp8kcREuRriepRyVf5c0uHj0InlXh122tYlKwF01RXpg==
12041204
dependencies:
12051205
merge-images "^2.0.0"
12061206

0 commit comments

Comments
 (0)