-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#11982] Math.round to long maxValue
- Loading branch information
1 parent
ccae72c
commit d6cbe0c
Showing
2 changed files
with
26 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 25 additions & 24 deletions
49
web-frontend/src/main/v3/packages/ui/src/components/common/MiniChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
import { Chart } from '@pinpoint-fe/ui/constants'; | ||
import { ComposedChart, ReferenceLine } from 'recharts'; | ||
import { useRechart } from '../ReChart/useRechart'; | ||
import { ChartContainer } from '../ui'; | ||
|
||
export interface MiniChart { | ||
chart: Chart; | ||
} | ||
|
||
export const MiniChart = ({ chart }: MiniChart) => { | ||
const { data, maxValue, renderChartChildComponents } = useRechart(chart); | ||
const { data, chartConfig, maxValue, renderChartChildComponents } = useRechart(chart); | ||
|
||
return ( | ||
<ComposedChart | ||
width={128} | ||
height={40} | ||
data={data} | ||
margin={{ | ||
top: 6, | ||
right: 30, | ||
bottom: 6, | ||
left: 2, | ||
}} | ||
> | ||
{data?.length && maxValue > -1 && ( | ||
<ReferenceLine | ||
y={maxValue} | ||
stroke="black" | ||
strokeDasharray="3 3" | ||
position="middle" | ||
label={{ position: 'right', value: maxValue }} | ||
ifOverflow="extendDomain" | ||
/> | ||
)} | ||
{renderChartChildComponents()} | ||
</ComposedChart> | ||
<ChartContainer config={chartConfig} className="w-full h-[40px]"> | ||
<ComposedChart | ||
data={data} | ||
margin={{ | ||
top: 6, | ||
right: 60, | ||
bottom: 6, | ||
left: 2, | ||
}} | ||
> | ||
{data?.length && maxValue > -1 && ( | ||
<ReferenceLine | ||
y={maxValue} | ||
stroke="black" | ||
strokeDasharray="3 3" | ||
position="middle" | ||
label={{ position: 'right', value: Math.round(maxValue * 100) / 100 }} | ||
ifOverflow="extendDomain" | ||
/> | ||
)} | ||
{renderChartChildComponents()} | ||
</ComposedChart> | ||
</ChartContainer> | ||
); | ||
}; |