export const CandleChart = ({ }: CandleChartProps) => { const chart = useRef<Chart…
- User
export const CandleChart = ({
}: CandleChartProps) => { const chart = useRef<Chart|null>(null);
const openOrdersEl = { "30443150224": { apiKeyId: "2", apiKeyName: "Test", id: "30443150224", symbol: "BTCUSDT", type: "LIMIT", price: 0.0634, quantity: 100, side: "long", status: "NEW", }, "30443151724": { apiKeyId: "2", apiKeyName: "Test", id: "30443151724", symbol: "BTCUSDT", type: "LIMIT", price: 0.0636, quantity: 102, side: "short", status: "NEW", }, "35678150224": { apiKeyId: "2", apiKeyName: "Test", id: "35678150224", symbol: "BTCUSDT", type: "LIMIT", price: 0.0632, quantity: 100, side: "long", status: "NEW", }, "31234560224": { apiKeyId: "2", apiKeyName: "Test", id: "31234560224", symbol: "BTCUSDT", type: "LIMIT", price: 0.06338, quantity: 102, side: "long", status: "NEW", }, };
return (<> <Box ref={ref} id={
chart-${uniqueId}} width={!showToolbar ? "calc(100% - 5px)" : "calc(100% - 55px)"} height="100%" position="relative" sx={{borderLeft: theme =>2px solid ${theme.palette.grey[50]}}} > </>); };import {MutableRefObject} from "react"; import React, {useEffect} from "react"; import {Chart, registerOverlay} from "klinecharts"; import {IconButton} from "@mui/material";
interface BarTradeEntity { id: string symbol: string price: number; side: string; quantity: number; }
interface OpenordersProps { chart: MutableRefObject<Chart | null | undefined>, paneId: MutableRefObject, settingOpenOrder: BarTradeEntity, priceClose: number, }
const Openorders = ({chart, paneId, settingOpenOrder, priceClose}: OpenordersProps) => { const {id, price, quantity, side, symbol} = settingOpenOrder; const color = side === "long" ? "#006943" : "#B41C18"; console.log("Openorders");
const customizeChart = () => { registerOverlay({ name: "customOverlay", needDefaultXAxisFigure: true, totalStep: 1, createPointFigures: function({overlay, coordinates}) { const percent = ((price / priceClose) * 100) - 100; const text =
$${price} | ${quantity} | ${${percent.toFixed(2)}}% | .; const w = (text.length * 5.8); const crossSize = 8; const crossX = 100 + w - (crossSize * 3) - 3; const crossY = coordinates[0].y - crossSize / 2 - 2;code - Assistant
Чтобы отрисовать компонент Openorders, вам необходимо добавить его внутрь компонента CandleChart. Вот код с добавленным компонентом Openorders:
jsx