Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: chart issues in dark mode #8414

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions frontend/src/component/personalDashboard/FlagMetricsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import annotationPlugin from 'chartjs-plugin-annotation';
import { Bar } from 'react-chartjs-2';
import useTheme from '@mui/material/styles/useTheme';
import { type FC, useEffect, useMemo, useState } from 'react';
import { Box, styled } from '@mui/material';
import { Box, type Theme, styled } from '@mui/material';
import { FeatureMetricsHours } from '../feature/FeatureView/FeatureMetrics/FeatureMetricsHours/FeatureMetricsHours';
import GeneralSelect from '../common/GeneralSelect/GeneralSelect';
import { useFeatureMetricsRaw } from 'hooks/api/getters/useFeatureMetricsRaw/useFeatureMetricsRaw';
Expand All @@ -27,17 +27,17 @@ import { FlagExposure } from 'component/feature/FeatureView/FeatureOverview/Feat

const defaultYes = [0, 14, 28, 21, 33, 31, 31, 22, 26, 37, 31, 14, 21, 14, 0];

const placeholderData = {
const placeholderData = (theme: Theme) => ({
labels: Array.from({ length: 15 }, (_, i) => i + 1),
datasets: [
{
data: defaultYes,
backgroundColor: '#EAEAED',
hoverBackgroundColor: '#EAEAED',
backgroundColor: theme.palette.divider,
hoverBackgroundColor: theme.palette.divider,
label: 'No metrics for this feature flag in the selected environment and time period',
},
],
};
});

const ChartWrapper = styled('div')({
width: '90%',
Expand All @@ -50,10 +50,14 @@ export const PlaceholderFlagMetricsChart = () => {
return createPlaceholderBarChartOptions(theme);
}, [theme]);

const data = useMemo(() => {
return placeholderData(theme);
}, [theme]);

return (
<ChartWrapper>
<Bar
data={placeholderData}
data={data}
options={options}
aria-label='A placeholder bar chart with a single feature flag exposure metrics'
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const createPlaceholderBarChartOptions = (
},
grid: {
drawBorder: false,
color: theme.palette.divider,
},
},
},
Expand Down
Loading