Skip to content

Commit 7ceeb7f

Browse files
committed
Bug colormap
1 parent b3b06c3 commit 7ceeb7f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

studio/src/components/Shared/StyleScalars.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Listbox } from '@headlessui/react';
22

33
import { Histogram, Scalars } from '@data/types';
44

5+
import { useApplyStyle } from '@hooks/useApplyStyle';
6+
import { useLastStyle } from '@hooks/useLastStyle';
57
import { useUpdateStyles } from '@hooks/useStyleUpdate';
68

79
import { StyleHistogram } from './StyleHistogram';
@@ -11,10 +13,12 @@ const colormaps = ['plasma', 'magma', 'inferno', 'viridis'];
1113
export function StyleScalars(props: { scalars: Scalars; histogram: Histogram }) {
1214
const { scalars, histogram } = props;
1315
const updateStyles = useUpdateStyles();
16+
const [, applyStyle] = useLastStyle();
1417

1518
const handleChange = (value: string) => {
1619
scalars.colormap = value;
1720
updateStyles();
21+
applyStyle();
1822
};
1923

2024
return (

studio/src/hooks/useStyleUpdate.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export function useUpdateStyles() {
88
const ctx = React.useContext(context);
99

1010
const setStyle = (style?: Style, metadata?: Metadata) => {
11-
autoUpdateStyle(metadata ?? ctx.metadata, style ?? ctx.styles);
12-
ctx.setStyles({ ...style });
11+
const s = style ?? ctx.styles;
12+
autoUpdateStyle(metadata ?? ctx.metadata, s);
13+
ctx.setStyles({ ...s });
1314
};
1415

1516
return setStyle;

0 commit comments

Comments
 (0)