const customizeChart = () => { registerOverlay({ name: "customOverlay",…
- User
const customizeChart = () => { registerOverlay({ name: "customOverlay", needDefaultPointFigure: true, needDefaultXAxisFigure: true, needDefaultYAxisFigure: true, lock: true, totalStep: 1, createPointFigures: function({overlay, coordinates}) { const priceValue = overlay.points[0].value || price; const quantity = overlay.points[0].dataIndex; const priceCloseValue = overlay.points[0].timestamp || priceClose; const percent = ((priceValue / priceCloseValue) * 100) - 100; const text =
$${priceValue} | ${quantity} | ${${percent.toFixed(2)}%} | ❌;return [ { type: "line", attrs: { coordinates: [ {x: 0, y: coordinates[0].y}, {x: 50, y: coordinates[0].y}, ], }, styles: { style: "solid", }, }, { type: "rectText", attrs: { x: 50, y: coordinates[0].y - 9, text: text, baseline: "top", }, styles: { style: "stroke_fill", }, }, ]; }, }); createOverlayHandler();};
рисуется rectText, в него я добавляю текст const text = $${priceValue} | {${percent.toFixed(2)}%} | ❌; и после этого текст нужно отрисовать линия до конца графика
- Assistant
Чтобы отрисовать линию до конца графика, вы можете изменить следующий блок кода в функции
createPointFigures:return [ { type: "line", attrs: { coordinates: [ {x: 0, y: coordinates[0].y}, {x: 50, y: coordinates[0].y}, {x: coordinates[1].x, y: coordinates[1].y}, ], }, styles: { style: "solid", }, }, { type: "rectText", attrs: { x: 50, y: coordinates[0].y - 9, text: text, baseline: "top", }, styles: { style: "stroke_fill", }, }, ];В этом коде мы добавили третью точку координаты для линии, которая имеет значения
{x: coordinates[1].x, y: coordinates[1].y}. Теперь линия будет продолжаться до конца графика.