Skip to content

Commit

Permalink
fix: simple table +Inf and -Inf renders as such (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChitlangeSahas authored Oct 25, 2021
1 parent cdd462f commit 19c40ab
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 8 deletions.
2 changes: 1 addition & 1 deletion giraffe/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 5 additions & 5 deletions giraffe/src/utils/fromFlux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stories/package.json
Original file line number Diff line number Diff line change
@@ -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}'",
Expand Down
66 changes: 66 additions & 0 deletions stories/src/data/tableGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
`
21 changes: 20 additions & 1 deletion stories/src/simpleTableGraph.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -26,3 +26,22 @@ storiesOf('Simple Table Graph', module)
</PlotContainer>
)
})
.add('Non-numbers in a numbers column', () => {
const showAll = boolean('showAll', false)

const config: Config = {
fluxResponse: nonNumbersInNumbersColumn,
layers: [
{
type: 'simple table',
showAll: showAll,
},
],
}

return (
<PlotContainer>
<Plot config={config} />
</PlotContainer>
)
})

0 comments on commit 19c40ab

Please sign in to comment.