fix: format histogram channel values to two decimal places

- Updated the HistogramChart component to display channel values (red, green, blue, and luminance) formatted to two decimal places for improved readability and precision in the user interface.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-06-23 11:50:36 +08:00
parent cc04d99a0e
commit 3b0c52ed82

View File

@@ -295,19 +295,24 @@ export const HistogramChart: FC<HistogramChartProps> = ({
{t('histogram.value')}: {hoverInfo.value} {t('histogram.value')}: {hoverInfo.value}
</div> </div>
{channelVisibility.red && ( {channelVisibility.red && (
<div className="text-red-400">R: {hoverInfo.channels.red}</div> <div className="text-red">
R: {hoverInfo.channels.red.toFixed(2)}
</div>
)} )}
{channelVisibility.green && ( {channelVisibility.green && (
<div className="text-green-400"> <div className="text-green">
G: {hoverInfo.channels.green} G: {hoverInfo.channels.green.toFixed(2)}
</div> </div>
)} )}
{channelVisibility.blue && ( {channelVisibility.blue && (
<div className="text-blue-400">B: {hoverInfo.channels.blue}</div> <div className="text-blue">
B: {hoverInfo.channels.blue.toFixed(2)}
</div>
)} )}
{channelVisibility.luminance && ( {channelVisibility.luminance && (
<div className="text-white"> <div className="text-white">
{t('histogram.luminance')}: {hoverInfo.channels.luminance} {t('histogram.luminance')}:{' '}
{hoverInfo.channels.luminance.toFixed(2)}
</div> </div>
)} )}
</m.div> </m.div>
@@ -324,12 +329,12 @@ export const HistogramChart: FC<HistogramChartProps> = ({
onClick={() => toggleChannel('red')} onClick={() => toggleChannel('red')}
className={`flex items-center gap-1 rounded px-2 py-1 text-xs transition-all ${ className={`flex items-center gap-1 rounded px-2 py-1 text-xs transition-all ${
channelVisibility.red channelVisibility.red
? 'border border-red-500/30 bg-red-500/20 text-red-400' ? 'text-red border border-red-500/30 bg-red-500/20'
: 'border border-white/10 bg-white/5 text-white/40' : 'border border-white/10 bg-white/5 text-white/40'
}`} }`}
> >
<div <div
className={`size-2 rounded-full ${channelVisibility.red ? 'bg-red-400' : 'bg-white/20'}`} className={`size-2 rounded-full ${channelVisibility.red ? 'bg-red' : 'bg-white/20'}`}
/> />
<span>R</span> <span>R</span>
</button> </button>
@@ -343,7 +348,7 @@ export const HistogramChart: FC<HistogramChartProps> = ({
}`} }`}
> >
<div <div
className={`size-2 rounded-full ${channelVisibility.green ? 'bg-green-400' : 'bg-white/20'}`} className={`size-2 rounded-full ${channelVisibility.green ? 'bg-green' : 'bg-white/20'}`}
/> />
<span>G</span> <span>G</span>
</button> </button>
@@ -357,7 +362,7 @@ export const HistogramChart: FC<HistogramChartProps> = ({
}`} }`}
> >
<div <div
className={`size-2 rounded-full ${channelVisibility.blue ? 'bg-blue-400' : 'bg-white/20'}`} className={`size-2 rounded-full ${channelVisibility.blue ? 'bg-blue' : 'bg-white/20'}`}
/> />
<span>B</span> <span>B</span>
</button> </button>
@@ -371,7 +376,7 @@ export const HistogramChart: FC<HistogramChartProps> = ({
}`} }`}
> >
<div <div
className={`size-2 rounded-full ${channelVisibility.luminance ? 'bg-white' : 'bg-white/20'}`} className={`size-2 rounded-full ${channelVisibility.luminance ? 'bg-white/80' : 'bg-white/20'}`}
/> />
<span>{t('histogram.luminance')}</span> <span>{t('histogram.luminance')}</span>
</button> </button>