Guard against missing colors

pull/10616/head
Alex P 2017-12-05 12:07:40 -08:00
parent 12d1845395
commit 5f80268191
2 changed files with 7 additions and 1 deletions

View File

@ -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)

View File

@ -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
)