Fix null property access bug in ColorSchemeDropdown

pull/10616/head
Christopher Henn 2018-11-21 13:24:28 -08:00 committed by Chris Henn
parent 169015bd85
commit a30e644c4a
2 changed files with 10 additions and 3 deletions

View File

@ -5,7 +5,10 @@ import React, {SFC, CSSProperties} from 'react'
import {Dropdown, DropdownMenuColors} from 'src/clockface'
// Constants
import {LINE_COLOR_SCALES} from 'src/shared/constants/graphColorPalettes'
import {
LINE_COLOR_SCALES,
DEFAULT_LINE_COLORS,
} from 'src/shared/constants/graphColorPalettes'
// Styles
import 'src/shared/components/ColorSchemeDropdown.scss'
@ -31,7 +34,11 @@ const findSelectedScaleID = (colors: Color[]) => {
const needle = key(colors)
const selectedScale = LINE_COLOR_SCALES.find(d => key(d.colors) === needle)
return selectedScale.id
if (selectedScale) {
return selectedScale.id
} else {
return DEFAULT_LINE_COLORS[0].id
}
}
const ColorSchemeDropdown: SFC<Props> = ({value, onChange}) => {

View File

@ -224,7 +224,7 @@ class Dygraph extends Component<Props, State> {
private get colors(): string[] {
const {timeSeries, colors} = this.props
const numSeries = get(timeSeries, '0.length', colors.length)
const numSeries: number = get(timeSeries, '0.length', colors.length)
const resolvedColors = getLineColorsHexes(colors, numSeries)
return resolvedColors