From 19c40ab24fb693bd636139245376efa5b08547c6 Mon Sep 17 00:00:00 2001 From: Chitlange Sahas Date: Mon, 25 Oct 2021 15:05:56 -0700 Subject: [PATCH] fix: simple table +Inf and -Inf renders as such (#505) --- giraffe/package.json | 2 +- giraffe/src/utils/fromFlux.ts | 10 ++-- stories/package.json | 2 +- stories/src/data/tableGraph.ts | 66 ++++++++++++++++++++++++ stories/src/simpleTableGraph.stories.tsx | 21 +++++++- 5 files changed, 93 insertions(+), 8 deletions(-) diff --git a/giraffe/package.json b/giraffe/package.json index b8d33356..15a98742 100644 --- a/giraffe/package.json +++ b/giraffe/package.json @@ -1,6 +1,6 @@ { "name": "@influxdata/giraffe", - "version": "2.18.10", + "version": "2.18.11", "main": "dist/index.js", "module": "src/index.js", "license": "MIT", diff --git a/giraffe/src/utils/fromFlux.ts b/giraffe/src/utils/fromFlux.ts index 551170e0..b1e7acda 100644 --- a/giraffe/src/utils/fromFlux.ts +++ b/giraffe/src/utils/fromFlux.ts @@ -272,12 +272,12 @@ const parseValue = (value: string | undefined, columnType: ColumnType): any => { return Date.parse(value.trim()) } - if (columnType === 'number' && value === '') { - return null - } - if (columnType === 'number') { - return Number(value) + if (value === '') { + return null + } + const parsedValue = Number(value) + return parsedValue === parsedValue ? parsedValue : value } return null diff --git a/stories/package.json b/stories/package.json index ff12fbfc..3bea9962 100644 --- a/stories/package.json +++ b/stories/package.json @@ -1,6 +1,6 @@ { "name": "@influxdata/giraffe-stories", - "version": "2.18.9", + "version": "2.18.11", "license": "MIT", "scripts": { "lint": "eslint '{src,../giraffe/src}/**/*.{ts,tsx}'", diff --git a/stories/src/data/tableGraph.ts b/stories/src/data/tableGraph.ts index f5dccd5b..c5584fc8 100644 --- a/stories/src/data/tableGraph.ts +++ b/stories/src/data/tableGraph.ts @@ -63,3 +63,69 @@ export const tableCSV = `#group,false,false,true,true,false,false,true,true,true ,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:20Z,10.21021021021021,usage_system,cpu,cpu0,MBP15-TLUONG.local ,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:30Z,11.4,usage_system,cpu,cpu0,MBP15-TLUONG.local ` + +export const nonNumbersInNumbersColumn = `#group,false,false,true,true,false,false,true,true,true,true +#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string +#default,_result,,,,,,,,, +,result,table,_start,_stop,_time,_value,_field,_measurement,cpu,host +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:45:50Z,+Inf,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:00Z,Infinity,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:10Z,-Inf,usage_system,cpu,cpu1,foo1.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:20Z,+∞,usage_system,cpu,cpu1,foo1.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:10Z,∞,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:20Z,-∞,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:30Z,,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:40Z,null,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:50Z,1.001001001001001,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:00Z,0.6993006993006993,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:10Z,0.7007007007007007,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:20Z,0.8,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:30Z,0.7992007992007992,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:40Z,0.8,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:50Z,0.8,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:00Z,0.9,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:10Z,0.9,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:20Z,0.8008008008008008,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:30Z,0.8991008991008991,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:40Z,0.7,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:50Z,0.9,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:00Z,0.7007007007007007,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:10Z,0.7992007992007992,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:20Z,0.9009009009009009,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:30Z,1.098901098901099,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:40Z,0.8,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:50Z,0.9,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:00Z,0.9,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:10Z,0.7,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:20Z,0.7,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,0,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:30Z,0.9009009009009009,usage_system,cpu,cpu1,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:45:50Z,21.678321678321677,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:00Z,12.2,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:10Z,19.51951951951952,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:20Z,11.9,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:30Z,13.386613386613387,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:40Z,11.4,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:46:50Z,12.1,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:00Z,10.91091091091091,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:10Z,10.589410589410589,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:20Z,12.612612612612613,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:30Z,10.289710289710289,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:40Z,11.7,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:47:50Z,10.5,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:00Z,10.6,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:10Z,13.3,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:20Z,13.6,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:30Z,11.511511511511511,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:40Z,11.3,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:48:50Z,12.8,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:00Z,10.989010989010989,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:10Z,10.71071071071071,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:20Z,11.711711711711711,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:30Z,13.086913086913087,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:40Z,10.989010989010989,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:49:50Z,11.511511511511511,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:00Z,11.488511488511488,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:10Z,10.6,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:20Z,10.21021021021021,usage_system,cpu,cpu0,MBP15-TLUONG.local +,,1,2020-07-01T21:45:43.0968Z,2020-07-01T21:50:43.0968Z,2020-07-01T21:50:30Z,11.4,usage_system,cpu,cpu0,MBP15-TLUONG.local +` diff --git a/stories/src/simpleTableGraph.stories.tsx b/stories/src/simpleTableGraph.stories.tsx index a8f30de6..83274399 100644 --- a/stories/src/simpleTableGraph.stories.tsx +++ b/stories/src/simpleTableGraph.stories.tsx @@ -3,7 +3,7 @@ import {storiesOf} from '@storybook/react' import {withKnobs, boolean} from '@storybook/addon-knobs' import {PlotContainer} from './helpers' import {Config, Plot} from '../../giraffe/src' -import {tableCSV} from './data/tableGraph' +import {tableCSV, nonNumbersInNumbersColumn} from './data/tableGraph' storiesOf('Simple Table Graph', module) .addDecorator(withKnobs) @@ -26,3 +26,22 @@ storiesOf('Simple Table Graph', module) ) }) + .add('Non-numbers in a numbers column', () => { + const showAll = boolean('showAll', false) + + const config: Config = { + fluxResponse: nonNumbersInNumbersColumn, + layers: [ + { + type: 'simple table', + showAll: showAll, + }, + ], + } + + return ( + + + + ) + })