Guard against missing colors
parent
12d1845395
commit
5f80268191
|
@ -96,6 +96,9 @@ export const DEFAULT_COLORS = [
|
|||
]
|
||||
|
||||
export const validateColors = colors => {
|
||||
if (!colors) {
|
||||
return false
|
||||
}
|
||||
const hasMin = colors.some(color => color.type === COLOR_TYPE_MIN)
|
||||
const hasMax = colors.some(color => color.type === COLOR_TYPE_MAX)
|
||||
|
||||
|
|
|
@ -42,8 +42,11 @@ class Gauge extends Component {
|
|||
const gradientThickness = Math.max(minLineWidth, radius / 4)
|
||||
const labelValueFontSize = Math.max(minFontSize, radius / 4)
|
||||
|
||||
// Distill out max and min values
|
||||
const {colors} = this.props
|
||||
if (!colors || colors.length === 0) {
|
||||
return
|
||||
}
|
||||
// Distill out max and min values
|
||||
const minValue = Number(
|
||||
colors.find(color => color.type === COLOR_TYPE_MIN).value
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue