File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 lineTransform ,
1313 LineLayerConfig ,
1414} from '@influxdata/giraffe'
15+ import memoizeOne from 'memoize-one'
1516
1617// Components
1718import EmptyGraphMessage from 'src/shared/components/EmptyGraphMessage'
@@ -196,12 +197,13 @@ const XYPlot: FC<Props> = ({
196197 let colorMapping = null
197198
198199 if ( isFlagEnabled ( 'graphColorMapping' ) ) {
200+ const memoizedGetColorMappingObjects = memoizeOne ( getColorMappingObjects )
199201 const [ , fillColumnMap ] = createGroupIDColumn ( result . table , groupKey )
200202 const {
201203 colorMappingForGiraffe,
202204 colorMappingForIDPE,
203205 needsToSaveToIDPE,
204- } = getColorMappingObjects ( fillColumnMap , properties )
206+ } = memoizedGetColorMappingObjects ( fillColumnMap , properties )
205207 colorMapping = colorMappingForGiraffe
206208
207209 // when the view is in a dashboard cell, and there is a need to save to IDPE, save it.
Original file line number Diff line number Diff line change 11import { XYViewProperties } from 'src/types'
22import { addedDiff , deletedDiff } from 'deep-object-diff'
33import { getNominalColorScale } from '@influxdata/giraffe'
4+ import { DEFAULT_LINE_COLORS } from 'src/shared/constants/graphColorPalettes'
45
56/**
67 * Evaluates whether mappings need to be updated
@@ -158,8 +159,9 @@ export const generateSeriesToColorHex = (
158159 const cgMap = { ...columnGroupMap }
159160 cgMap . mappings . forEach ( ( graphLine , colorIndex ) => {
160161 const id = getSeriesId ( graphLine , columnGroupMap . columnKeys )
161- const colors = properties . colors . map ( value => value . hex )
162- const fillScale = getNominalColorScale ( columnGroupMap , colors )
162+ const colors = properties . colors ?? DEFAULT_LINE_COLORS
163+ const colorsHexArray = colors . map ( value => value . hex )
164+ const fillScale = getNominalColorScale ( columnGroupMap , colorsHexArray )
163165 seriesToColorHex [ id ] = fillScale ( colorIndex )
164166 } )
165167
You can’t perform that action at this time.
0 commit comments