-
-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
最新一根蜡烛的现价线显示如何自定义内容? #589
Comments
I am also needing to do a similar function like this. If you find a solution can you guide me please. Thank you very much |
Hello @StationSun const dataList = chart.getDataList();
const lastData = dataList[dataList.length - 1];
const lastPrice = lastData.close; After that I use convertToPixel to get the pixel value of priceMark const pixelPosition = chart.convertToPixel(
{ value: lastPrice },
{ paneId: "candle_pane" }
); Then I will create a state to save pixelPosition.y to setPosition(pixelPosition.y); Then I hide priceMark.text then I create a div to display it with top being the value of setPosition <div
style={{
right: 0,
top: top,
zIndex: 100,
fontSize: 10,
borderRadius: 5,
paddingBlock: 2,
paddingInline: 5,
color: "#aaaaaa",
position: "absolute",
transition: "top 0.5s",
border: "1px solid #aaaaaa",
backgroundColor: themeParams === "dark" ? "#181A20" : "#FFFFFF",
}}
>
{String(lastPrice).replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
<br />
{new Date().toLocaleTimeString()}
</div> Here there will be a problem that sometimes the position will be larger than the height value of the screen. So I create a function like this: const [top, setTop] = useState(position);
useEffect(() => {
if (position > height) {
setTop(height * 0.95 - 8);
} else {
setTop(position - 8);
}
}, [position]); But because of setState like that, it will be a bit sluggish when dragging the chart too fast. I think this is a pretty good approach. If possible, can you help me fix it? |
I have looked at your proposal and it seems very good, but my proposal is implemented through creatOverlay and is currently being implemented. I will send it out later |
Any progress on your idea? @StationSun |
I will first add registrant overlay (yourSelf) in Widget. ts; Then create Finally, call the business logic again const latestCandle = dataList[dataList.length - 1]; const priceLineValue = Number(latestCandle?. close); |
Hi~. man ! How did you handle this stuttering issue in the end? @tomheo11233aA |
My chart doesn't need to pull data back so I disabled scroll and zoom. I still can't find a solution to this problem @@ @StationSun |
I just can put transition: "top 0.5s", To make animation smoothy a little bit @@ |
版本
9.8.7
复现步骤
candle.candle.priceMark.last.text 配置中,想要自定义文本信息内容,如何像Trading View一样生效
当前效果
当前无法生效配置文本内容自定义
预期效果
期望效配置文本内容自定义
环境
补充说明
No response
The text was updated successfully, but these errors were encountered: