Ensure that values are displayed on gauges
parent
cb670d7c33
commit
9ff9f63dd2
|
@ -101,7 +101,7 @@ class GaugeChart extends PureComponent<Props> {
|
|||
const {lastValues} = getLastValues(data)
|
||||
const precision = 100.0
|
||||
|
||||
return Math.round(_.get(lastValues, 1, 0) * precision) / precision
|
||||
return Math.round(_.get(lastValues, 0, 0) * precision) / precision
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ type SeriesValue = number | string
|
|||
|
||||
interface Series {
|
||||
name: string
|
||||
values: SeriesValue[] | null
|
||||
values: SeriesValue[][] | null
|
||||
columns: string[] | null
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ export default function(
|
|||
['', '']
|
||||
).slice(1)
|
||||
|
||||
console.dir(values)
|
||||
|
||||
const lastValues = values[values.length - 1].slice(1) // remove time with slice 1
|
||||
|
||||
return {lastValues, series}
|
||||
|
|
|
@ -3,6 +3,23 @@ import React from 'react'
|
|||
import Gauge from 'src/shared/components/Gauge'
|
||||
import GaugeChart from 'src/shared/components/GaugeChart'
|
||||
|
||||
const data = [
|
||||
{
|
||||
response: {
|
||||
results: [
|
||||
{
|
||||
series: [
|
||||
{
|
||||
values: [[1, 2]],
|
||||
columns: ['time', 'value'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const defaultProps = {
|
||||
data: [],
|
||||
isFetchingInitially: false,
|
||||
|
@ -30,5 +47,14 @@ describe('GaugeChart', () => {
|
|||
expect(wrapper.find(Gauge).props().gaugePosition).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when data has a value', () => {
|
||||
it('renders the correct number', () => {
|
||||
const wrapper = setup({data})
|
||||
|
||||
expect(wrapper.find(Gauge).exists()).toBe(true)
|
||||
expect(wrapper.find(Gauge).props().gaugePosition).toBe(2)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue