mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: chart issues in dark mode (#8414)
This PR fixes two issues with the chart in dark mode: 1. Grid lines are almost invisible 2. Placeholder data lines are way too bright The fix for both is to use the theme's divider color.  
This commit is contained in:
		
							parent
							
								
									e6365d8bce
								
							
						
					
					
						commit
						5df7b15af0
					
				| @ -11,7 +11,7 @@ import annotationPlugin from 'chartjs-plugin-annotation'; | |||||||
| import { Bar } from 'react-chartjs-2'; | import { Bar } from 'react-chartjs-2'; | ||||||
| import useTheme from '@mui/material/styles/useTheme'; | import useTheme from '@mui/material/styles/useTheme'; | ||||||
| import { type FC, useEffect, useMemo, useState } from 'react'; | 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 { FeatureMetricsHours } from '../feature/FeatureView/FeatureMetrics/FeatureMetricsHours/FeatureMetricsHours'; | ||||||
| import GeneralSelect from '../common/GeneralSelect/GeneralSelect'; | import GeneralSelect from '../common/GeneralSelect/GeneralSelect'; | ||||||
| import { useFeatureMetricsRaw } from 'hooks/api/getters/useFeatureMetricsRaw/useFeatureMetricsRaw'; | import { useFeatureMetricsRaw } from 'hooks/api/getters/useFeatureMetricsRaw/useFeatureMetricsRaw'; | ||||||
| @ -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 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), |     labels: Array.from({ length: 15 }, (_, i) => i + 1), | ||||||
|     datasets: [ |     datasets: [ | ||||||
|         { |         { | ||||||
|             data: defaultYes, |             data: defaultYes, | ||||||
|             backgroundColor: '#EAEAED', |             backgroundColor: theme.palette.divider, | ||||||
|             hoverBackgroundColor: '#EAEAED', |             hoverBackgroundColor: theme.palette.divider, | ||||||
|             label: 'No metrics for this feature flag in the selected environment and time period', |             label: 'No metrics for this feature flag in the selected environment and time period', | ||||||
|         }, |         }, | ||||||
|     ], |     ], | ||||||
| }; | }); | ||||||
| 
 | 
 | ||||||
| const ChartWrapper = styled('div')({ | const ChartWrapper = styled('div')({ | ||||||
|     width: '90%', |     width: '90%', | ||||||
| @ -50,10 +50,14 @@ export const PlaceholderFlagMetricsChart = () => { | |||||||
|         return createPlaceholderBarChartOptions(theme); |         return createPlaceholderBarChartOptions(theme); | ||||||
|     }, [theme]); |     }, [theme]); | ||||||
| 
 | 
 | ||||||
|  |     const data = useMemo(() => { | ||||||
|  |         return placeholderData(theme); | ||||||
|  |     }, [theme]); | ||||||
|  | 
 | ||||||
|     return ( |     return ( | ||||||
|         <ChartWrapper> |         <ChartWrapper> | ||||||
|             <Bar |             <Bar | ||||||
|                 data={placeholderData} |                 data={data} | ||||||
|                 options={options} |                 options={options} | ||||||
|                 aria-label='A placeholder bar chart with a single feature flag exposure metrics' |                 aria-label='A placeholder bar chart with a single feature flag exposure metrics' | ||||||
|             /> |             /> | ||||||
|  | |||||||
| @ -58,6 +58,7 @@ export const createPlaceholderBarChartOptions = ( | |||||||
|             }, |             }, | ||||||
|             grid: { |             grid: { | ||||||
|                 drawBorder: false, |                 drawBorder: false, | ||||||
|  |                 color: theme.palette.divider, | ||||||
|             }, |             }, | ||||||
|         }, |         }, | ||||||
|     }, |     }, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user