mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
Flamegraph: Make color by package the default color mode (#76137)
* Make package based the default color mode * simplify the code a bit
This commit is contained in:
parent
c238b1f02f
commit
20d64705f5
@ -206,24 +206,13 @@ const FlameGraphContainer = ({
|
||||
};
|
||||
|
||||
function useColorScheme(dataContainer: FlameGraphDataContainer | undefined) {
|
||||
const [colorScheme, setColorScheme] = useState<ColorScheme | ColorSchemeDiff>(
|
||||
dataContainer?.isDiffFlamegraph() ? ColorSchemeDiff.Default : ColorScheme.ValueBased
|
||||
);
|
||||
useEffect(() => {
|
||||
if (
|
||||
dataContainer?.isDiffFlamegraph() &&
|
||||
(colorScheme === ColorScheme.ValueBased || colorScheme === ColorScheme.PackageBased)
|
||||
) {
|
||||
setColorScheme(ColorSchemeDiff.Default);
|
||||
}
|
||||
const defaultColorScheme = dataContainer?.isDiffFlamegraph() ? ColorSchemeDiff.Default : ColorScheme.PackageBased;
|
||||
const [colorScheme, setColorScheme] = useState<ColorScheme | ColorSchemeDiff>(defaultColorScheme);
|
||||
|
||||
if (
|
||||
!dataContainer?.isDiffFlamegraph() &&
|
||||
(colorScheme === ColorSchemeDiff.Default || colorScheme === ColorSchemeDiff.DiffColorBlind)
|
||||
) {
|
||||
setColorScheme(ColorScheme.ValueBased);
|
||||
}
|
||||
}, [dataContainer, colorScheme]);
|
||||
// This makes sure that if we change the data to/from diff profile we reset the color scheme.
|
||||
useEffect(() => {
|
||||
setColorScheme(defaultColorScheme);
|
||||
}, [defaultColorScheme]);
|
||||
|
||||
return [colorScheme, setColorScheme] as const;
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ function ColorSchemeButton(props: ColorSchemeButtonProps) {
|
||||
const styles = getStyles(props.getTheme(), false);
|
||||
let menu = (
|
||||
<Menu>
|
||||
<Menu.Item label="By value" onClick={() => props.onChange(ColorScheme.ValueBased)} />
|
||||
<Menu.Item label="By package name" onClick={() => props.onChange(ColorScheme.PackageBased)} />
|
||||
<Menu.Item label="By value" onClick={() => props.onChange(ColorScheme.ValueBased)} />
|
||||
</Menu>
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user