英文:
xchart java swing not drawing data correctly when using updateOHLCSeries
问题
嗨,我在使用Java Swing中的xChat库(org.knowm.xchart)时遇到了一个奇怪的问题。
我能够在第一次添加数据时创建一个图表(蜡烛图),但是当我在大约5秒后添加数据时,它不会绘制蜡烛。
1. 在初始化中,我使用了以下代码:`chart.addSeries("Candle", xData, openData, highData, lowData, closeData, volumeData);`
2. 在定时器中,在大约5秒后执行以下代码(通过WebSocket或其他方式接收消息后的5秒):`chart.updateOHLCSeries("Candle", xData, openData, highData, lowData, closeData, volumeData);`
结果:
[![enter image description here][1]][1]
我不明白为什么第一次可以绘制,但第二次不行,我怀疑与`chart.updateOHLCSeries`有关,但找不到解决方法。
在上面的图片中,前5个蜡烛是使用`chart.addSeries`绘制的,最后2个蜡烛是使用`chart.updateOHLCSeries`添加的。
[1]: https://i.stack.imgur.com/9f7oN.png
英文:
Hi I have a weird issue with xChat lib(org.knowm.xchart) in java swing.
I am able to create a chart(Candle) when I first time add data to it, but when I add data to it say 5 sec after it is not drawing the candles.
- In Init i used
chart.addSeries("Candle", xData, openData, highData, lowData, closeData, volumeData);
- In Timer 5 sec after(done by using WSS onmessages i.e. the message is recieving after few seconds)
chart.updateOHLCSeries("Candle", xData, openData, highData, lowData, closeData, volumeData);
I am not able to understand why it wors first time and not 2nd time, i suspect it has something to do with the chart.updateOHLCSeries but cannot find a solution for it.
In the image above, the first 5 candles are drawn using the chart.addSeries and last 2 are being addedd in using chart.updateOHLCSeries
专注分享java语言的经验与见解,让所有开发者获益!
评论