Skip to content

Commit a2e1cda

Browse files
committed
frontend: fix chart sometimes showing -0 on y-axis
1 parent ba862df commit a2e1cda

File tree

1 file changed

+16
-4
lines changed
  • frontends/web/src/routes/account/summary

1 file changed

+16
-4
lines changed

frontends/web/src/routes/account/summary/chart.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,21 @@ export const Chart = ({
419419
lineSeries.current = chart.current.addAreaSeries({
420420
priceLineVisible: false,
421421
lastValueVisible: false,
422-
priceFormat: {
423-
type: 'volume',
424-
},
422+
priceFormat: (
423+
data.chartFiat === 'BTC' ? {
424+
minMove: 0.000001,
425+
// precision: 6,
426+
type: 'custom',
427+
formatter: (price: number) => {
428+
if (price < 0) {
429+
return '0';
430+
}
431+
return price.toLocaleString();
432+
},
433+
} : {
434+
type: 'volume',
435+
}
436+
),
425437
topColor: darkmode ? '#5E94BF' : '#DFF1FF',
426438
bottomColor: darkmode ? '#1D1D1B' : '#F5F5F5',
427439
lineColor: 'rgba(94, 148, 192, 1)',
@@ -444,7 +456,7 @@ export const Chart = ({
444456
chartInitialized.current = true;
445457
updateRange(chart, chartDisplay);
446458
}
447-
}, [calculateChange, chartDisplay, data.chartDataDaily, data.chartDataHourly, data.chartDataMissing, hasData, hideAmounts, i18n.language, isMobile]);
459+
}, [calculateChange, chartDisplay, data.chartDataDaily, data.chartDataHourly, data.chartDataMissing, data.chartFiat, hasData, hideAmounts, i18n.language, isMobile]);
448460

449461
const reinitializeChart = () => {
450462
removeChart();

0 commit comments

Comments
 (0)