Fix null property access bug in ColorSchemeDropdown
parent
169015bd85
commit
a30e644c4a
|
@ -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}) => {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue