Skip to content

Commit 0cf8281

Browse files
committed
chore: limit graphColorMapping to CLOUD
1 parent 022199e commit 0cf8281

File tree

3 files changed

+46
-28
lines changed

3 files changed

+46
-28
lines changed

src/timeMachine/components/Vis.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import {RemoteDataState, AppState, ViewProperties} from 'src/types'
3434
import {getActiveTimeRange} from 'src/timeMachine/selectors/index'
3535
import {setViewProperties} from 'src/timeMachine/actions'
3636

37+
// Constants
38+
import {CLOUD} from 'src/shared/constants'
39+
3740
type ReduxProps = ConnectedProps<typeof connector>
3841
type Props = ReduxProps
3942

@@ -95,7 +98,7 @@ const TimeMachineVis: FC<Props> = ({
9598
!!giraffeResult.table.length)
9699

97100
useEffect(() => {
98-
if (viewProperties.hasOwnProperty('colors')) {
101+
if (CLOUD && viewProperties.hasOwnProperty('colors')) {
99102
const groupKey = [...giraffeResult.fluxGroupKeyUnion, 'result']
100103
const [, fillColumnMap] = createGroupIDColumn(
101104
giraffeResult.table,

src/visualization/types/Graph/options.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ import AxisTicksGenerator from 'src/visualization/components/internal/AxisTicksG
4343
import {XYViewProperties} from 'src/types'
4444
import {VisualizationOptionProps} from 'src/visualization'
4545

46+
// Constants
4647
const {BASE_2, BASE_10} = AXES_SCALE_OPTIONS
48+
import {CLOUD} from 'src/shared/constants'
4749

4850
interface Props extends VisualizationOptionProps {
4951
properties: XYViewProperties
@@ -250,19 +252,23 @@ export const GraphOptions: FC<Props> = ({properties, results, update}) => {
250252
<ColorSchemeDropdown
251253
value={properties.colors?.filter(c => c.type === 'scale') ?? []}
252254
onChange={colors => {
253-
const [, fillColumnMap] = createGroupIDColumn(
254-
results.table,
255-
groupKey
256-
)
257-
// the properties that we use to calculate the colors are updated in the next render cycle so we need
258-
// to make a new object and override the colors
259-
const newProperties = {...properties, colors}
260-
const colorMapping = generateSeriesToColorHex(
261-
fillColumnMap,
262-
newProperties
263-
)
255+
if (CLOUD) {
256+
const [, fillColumnMap] = createGroupIDColumn(
257+
results.table,
258+
groupKey
259+
)
260+
// the properties that we use to calculate the colors are updated in the next render cycle so we need
261+
// to make a new object and override the colors
262+
const newProperties = {...properties, colors}
263+
const colorMapping = generateSeriesToColorHex(
264+
fillColumnMap,
265+
newProperties
266+
)
264267

265-
update({colors, colorMapping})
268+
update({colors, colorMapping})
269+
} else {
270+
update({colors})
271+
}
266272
}}
267273
/>
268274
</Form.Element>

src/visualization/types/Graph/view.tsx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ interface Props extends VisualizationProps {
7272
properties: XYViewProperties
7373
}
7474

75+
// Constants
76+
import {CLOUD} from 'src/shared/constants'
77+
7578
export const Graph: FC<Props> = ({
7679
properties,
7780
annotations,
@@ -244,20 +247,24 @@ export const Graph: FC<Props> = ({
244247
return <EmptyGraphMessage message={INVALID_DATA_COPY} />
245248
}
246249

247-
const memoizedGetColorMappingObjects = memoizeOne(getColorMappingObjects)
248-
const [, fillColumnMap] = createGroupIDColumn(resultState.table, groupKey)
249-
const {colorMappingForGiraffe, colorMappingForIDPE, needsToSaveToIDPE} =
250-
memoizedGetColorMappingObjects(fillColumnMap, properties)
251-
const colorMapping = colorMappingForGiraffe
250+
let colorMapping = null
251+
252+
if (CLOUD) {
253+
const memoizedGetColorMappingObjects = memoizeOne(getColorMappingObjects)
254+
const [, fillColumnMap] = createGroupIDColumn(resultState.table, groupKey)
255+
const {colorMappingForGiraffe, colorMappingForIDPE, needsToSaveToIDPE} =
256+
memoizedGetColorMappingObjects(fillColumnMap, properties)
257+
colorMapping = colorMappingForGiraffe
252258

253-
// when the view is in a dashboard cell, and there is a need to save to IDPE, save it.
254-
// when VEO is open, prevent from saving because it causes state issues. It will be handled in the timemachine code separately.
255-
if (needsToSaveToIDPE && view?.dashboardID && !isVeoOpen) {
256-
const newView = {...view}
257-
newView.properties.colorMapping = colorMappingForIDPE
259+
// when the view is in a dashboard cell, and there is a need to save to IDPE, save it.
260+
// when VEO is open, prevent from saving because it causes state issues. It will be handled in the timemachine code separately.
261+
if (needsToSaveToIDPE && view?.dashboardID && !isVeoOpen) {
262+
const newView = {...view}
263+
newView.properties.colorMapping = colorMappingForIDPE
258264

259-
// save to IDPE
260-
dispatch(updateViewAndVariables(view.dashboardID, newView))
265+
// save to IDPE
266+
dispatch(updateViewAndVariables(view.dashboardID, newView))
267+
}
261268
}
262269

263270
const config: Config = {
@@ -298,11 +305,13 @@ export const Graph: FC<Props> = ({
298305
],
299306
}
300307

301-
const layer = {...(config.layers[0] as LineLayerConfig)}
308+
if (CLOUD) {
309+
const layer = {...(config.layers[0] as LineLayerConfig)}
302310

303-
layer.colorMapping = colorMapping
311+
layer.colorMapping = colorMapping
304312

305-
config.layers[0] = layer
313+
config.layers[0] = layer
314+
}
306315

307316
addAnnotationLayer(
308317
config,

0 commit comments

Comments
 (0)