export interface ProfitChartWidgetType { [key: string]: string number; } interface…
- User
export interface ProfitChartWidgetType { [key: string]: string | number; }
interface CumulativeProfitChartProps { data: ProfitChartWidgetType; }
const CumulativeProfitChart = ({data}: CumulativeProfitChartProps) => { const [profitData, setProfitData] = useState<ProfitChartWidgetType[]>([]); const darkTheme = useTheme().palette.mode === "dark";
useEffect(() => { if (data.length === 0) { setProfitData([]); } else { setProfitData(parseProfitData(data)); } }, [data]);
if(Object.entries(data).length === 0) { return <></>; }
return <> {parseFloat(`{profitPercentage}`).toFixed(2)} { profitPercentage > 0 ? <span style={{paddingLeft: 10}} > : <></> }
code<Box p={1} mt={-2.5} height="calc(100% - 110px)"> <ResponsiveContainer minHeight={"100%"} height="100%" width="100%" > <LineChart margin={{ top: 20, right: 0, left: 3, bottom: -5, }} width={500} data={profitData}> <CartesianGrid strokeDasharray="3 3" stroke={darkTheme ? "#5c5a57" : "#ccc"} /> <XAxis dataKey="date" axisLine={false} tickLine={false} minTickGap={-20} tick={({x, y, payload}) => { const date = dayjs(payload.value); const weekday = date.locale("ru").format("dd"); const day = date.format("DD"); return ( <text x={x} y={y + 10} textAnchor="middle" fill="#9E9B98" fontSize={13} > {`${weekday}, ${day}`} </text> ); }} /> <YAxis orientation="right" axisLine={false} tickLine={false} tick={({x, y, payload}) => { return ( <text x={x + 15} y={y} textAnchor="middle" fill="#9E9B98" fontSize={13} > { +payload.value >= 0 ? `$${Math.abs(+payload.value)}` : `-$${Math.abs(+payload.value)}` } </text> ); }} /> <Tooltip content={<CustomTooltip />} /> <Line type="linear" dataKey="profit" stroke="#006943" strokeWidth={3} dot={false} /> </LineChart> </ResponsiveContainer> </Box> - Assistant
To display dots on the added dates and not show dots on the existing dates, you can modify the
parseProfitDatafunction as follows:jsx
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.