Skip to content

Commit dd1ce30

Browse files
authored
theme: new chart colors (#89878)
New chonk chart colors. We'll fix what breaks as it gets reported, there are many places that seem to hand pick certain colors off the them, but I'm not sure if that is intentional, or if they were just picked because they looked the nicest
1 parent 9613f77 commit dd1ce30

File tree

31 files changed

+457
-244
lines changed

31 files changed

+457
-244
lines changed

static/app/components/charts/baseChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function BaseChart({
402402
resolveColors ||
403403
(series.length
404404
? theme.chart.getColorPalette(series.length)
405-
: theme.chart.colors[theme.chart.colors.length - 1]);
405+
: theme.chart.getColorPalette(theme.chart.colors.length - 1));
406406

407407
const resolvedSeries = useMemo(() => {
408408
const previousPeriodColors =

static/app/components/performance/waterfall/utils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ export const pickBarColor = (input: string | undefined, theme: Theme): string =>
250250
const barColors = makeBarColors(theme);
251251

252252
if (!input || input.length < 3) {
253-
return theme.chart.colors[17][4];
253+
const colors = theme.chart.getColorPalette(17);
254+
return colors[4]!;
254255
}
255256

256257
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message

static/app/components/themeAndStyleProvider.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Fragment, useEffect} from 'react';
22
import {createPortal} from 'react-dom';
33
import createCache from '@emotion/cache';
4+
import type {Theme} from '@emotion/react';
45
import {CacheProvider, ThemeProvider} from '@emotion/react';
56

67
import {loadPreferencesState} from 'sentry/actionCreators/preferences';
@@ -35,8 +36,8 @@ export function ThemeAndStyleProvider({children}: Props) {
3536
const theme = useThemeSwitcher();
3637

3738
return (
38-
<ThemeProvider theme={theme}>
39-
<GlobalStyles isDark={config.theme === 'dark'} theme={theme} />
39+
<ThemeProvider theme={theme as Theme}>
40+
<GlobalStyles isDark={config.theme === 'dark'} theme={theme as Theme} />
4041
<CacheProvider value={cache}>{children}</CacheProvider>
4142
{createPortal(
4243
<Fragment>

static/app/components/userMisery.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ type Props = {
1616

1717
function UserMisery(props: Props) {
1818
const theme = useTheme();
19+
const colors = theme.chart.getColorPalette(0);
1920
const {bars, barHeight, userMisery, miseryLimit, totalUsers, miserableUsers} = props;
2021
// User Misery will always be > 0 because of the maximum a posteriori estimate
2122
// and below 5% will always be an overestimation of the actual proportion
2223
// of miserable to total unique users. We are going to visualize it as
2324
// 0 User Misery while still preserving the actual value for sorting purposes.
2425
const adjustedMisery = userMisery > 0.05 ? userMisery : 0;
2526

26-
const palette = new Array(bars).fill(theme.chart.colors[0][0]);
27+
const palette = new Array(bars).fill(colors[0][0]);
2728
const score = Math.round(adjustedMisery * palette.length);
2829

2930
let title: React.ReactNode;

static/app/utils/profiling/flamegraph/flamegraphTheme.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ const SIZES: FlamegraphTheme['SIZES'] = {
180180
CHART_PX_PADDING: 30,
181181
};
182182

183-
function makeFlamegraphFonts(theme: Theme): FlamegraphTheme['FONTS'] {
183+
function makeFlamegraphFonts(
184+
theme: Theme | DO_NOT_USE_ChonkTheme
185+
): FlamegraphTheme['FONTS'] {
184186
return {
185187
FONT: MONOSPACE_FONT,
186188
FRAME_FONT: theme.text.familyMono,
@@ -189,6 +191,7 @@ function makeFlamegraphFonts(theme: Theme): FlamegraphTheme['FONTS'] {
189191

190192
/** Legacy theme definitions */
191193
export function makeLightFlamegraphTheme(theme: Theme): FlamegraphTheme {
194+
const chartColors = theme.chart.getColorPalette(12);
192195
return {
193196
LCH: LCH_LIGHT,
194197
SIZES,
@@ -207,10 +210,10 @@ export function makeLightFlamegraphTheme(theme: Theme): FlamegraphTheme {
207210
'by frequency': makeColorMapByFrequency,
208211
'by system vs application frame': makeColorMapBySystemVsApplicationFrame,
209212
},
210-
CPU_CHART_COLORS: theme.chart.colors[12].map(c => hexToColorChannels(c, 0.8)),
213+
CPU_CHART_COLORS: chartColors.map(c => hexToColorChannels(c, 0.8)),
211214
MEMORY_CHART_COLORS: [
212-
hexToColorChannels(theme.chart.colors[4][2], 0.8),
213-
hexToColorChannels(theme.chart.colors[4][3], 0.8),
215+
hexToColorChannels(chartColors[2], 0.8),
216+
hexToColorChannels(chartColors[3], 0.8),
214217
],
215218
CHART_CURSOR_INDICATOR: 'rgba(31,35,58,.75)',
216219
CHART_LABEL_COLOR: 'rgba(31,35,58,.75)',
@@ -246,6 +249,7 @@ export function makeLightFlamegraphTheme(theme: Theme): FlamegraphTheme {
246249
}
247250

248251
export function makeDarkFlamegraphTheme(theme: Theme): FlamegraphTheme {
252+
const chartColors = theme.chart.getColorPalette(12);
249253
return {
250254
LCH: LCH_DARK,
251255
SIZES,
@@ -264,10 +268,10 @@ export function makeDarkFlamegraphTheme(theme: Theme): FlamegraphTheme {
264268
'by frequency': makeColorMapByFrequency,
265269
'by system vs application frame': makeColorMapBySystemVsApplicationFrame,
266270
},
267-
CPU_CHART_COLORS: theme.chart.colors[12].map(c => hexToColorChannels(c, 0.8)),
271+
CPU_CHART_COLORS: chartColors.map(c => hexToColorChannels(c, 0.8)),
268272
MEMORY_CHART_COLORS: [
269-
hexToColorChannels(theme.chart.colors[4][2], 0.5),
270-
hexToColorChannels(theme.chart.colors[4][3], 0.5),
273+
hexToColorChannels(chartColors[2], 0.5),
274+
hexToColorChannels(chartColors[3], 0.5),
271275
],
272276
CHART_CURSOR_INDICATOR: 'rgba(255, 255, 255, 0.5)',
273277
CHART_LABEL_COLOR: 'rgba(255, 255, 255, 0.5)',
@@ -321,6 +325,8 @@ const SPAN_LCH_LIGHT_CHONK = {
321325
export const makeLightChonkFlamegraphTheme = (
322326
theme: DO_NOT_USE_ChonkTheme
323327
): FlamegraphTheme => {
328+
const chartColors = theme.chart.getColorPalette(12);
329+
324330
return {
325331
LCH: LCH_LIGHT_CHONK,
326332
SIZES,
@@ -339,7 +345,7 @@ export const makeLightChonkFlamegraphTheme = (
339345
},
340346

341347
// Charts
342-
CPU_CHART_COLORS: theme.chart.colors[12].map(c => hexToColorChannels(c, 0.8)),
348+
CPU_CHART_COLORS: chartColors.map(c => hexToColorChannels(c, 0.8)),
343349
MEMORY_CHART_COLORS: [
344350
hexToColorChannels(theme.colors.yellow400, 1),
345351
hexToColorChannels(theme.colors.red400, 1),
@@ -410,6 +416,7 @@ const SPANS_LCH_DARK_CHONK = {
410416
export const makeDarkChonkFlamegraphTheme = (
411417
theme: DO_NOT_USE_ChonkTheme
412418
): FlamegraphTheme => {
419+
const chartColors = theme.chart.getColorPalette(12);
413420
return {
414421
LCH: LCH_DARK_CHONK,
415422
SIZES,
@@ -428,7 +435,7 @@ export const makeDarkChonkFlamegraphTheme = (
428435
},
429436

430437
// Charts
431-
CPU_CHART_COLORS: theme.chart.colors[12].map(c => hexToColorChannels(c, 0.8)),
438+
CPU_CHART_COLORS: chartColors.map(c => hexToColorChannels(c, 0.8)),
432439
MEMORY_CHART_COLORS: [
433440
hexToColorChannels(theme.colors.yellow400, 1),
434441
hexToColorChannels(theme.colors.red400, 1),

0 commit comments

Comments
 (0)