Skip to content

Commit 65bcf70

Browse files
committed
fix: chart tooltips can show "0 Gi"
we should use a real memory pretty printer Closes #208
1 parent 9c1b17f commit 65bcf70

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/plugin-codeflare/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@logdna/tail-file": "^3.0.0",
2727
"@patternfly/react-charts": "^6.74.3",
2828
"@patternfly/react-core": "^4.221.3",
29+
"pretty-bytes": "^6.0.0",
2930
"split2": "^4.1.0",
3031
"strip-ansi": "6.0.0",
3132
"xterm-addon-search": "^0.9.0"

plugins/plugin-codeflare/src/components/Chart.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import React from "react"
18+
import prettyBytes from "pretty-bytes"
1819

1920
import {
2021
Chart,
@@ -245,7 +246,7 @@ export default class BaseChart extends React.PureComponent<Props> {
245246
private static readonly formatters = {
246247
celsius: (value: number) => ~~value + "C",
247248
percentage: (value: number) => value + "%",
248-
memory: (value: number) => ~~(value / 1024 / 1024) + " GiB",
249+
memory: (value: number) => prettyBytes(value * 1024),
249250
timestamp: (timestamp: number) =>
250251
timestamp < 60 * 3 * 1000 ? (timestamp / 1000).toFixed(0) + "s" : (timestamp / 1000 / 60).toFixed(1) + "m",
251252
}

0 commit comments

Comments
 (0)