java - JFreeChart: how to get coordinates of an XYItemEntity? -


i've been stuck problem quite time. need coordinates of points belong xyitementity. i'm drawing candlestick charts, , want know coordinates of open, close, high, low prices of item. enter image description here

is there way achieve that?

edit: question similar one: https://stackoverflow.com/questions/30801444/jfreecharthow-to-get-coordinates-of-a-chartentity-and-snap-mouse-cursor-to-the since changed approach. want achieve following: i'm drawing candelistick chart. mentioned above want user able "snap" mouse 1 of 4 values of candle: high, low, open, close. in order implement feature figured build collection of points on chartpanel correspond values of candles being displayed. then, adding chartmouselistener chartpanel, in chartmousemoved method check if cursor in close proximity of points. here add mousechartlistener chartpanel:

chartpanel.addchartmouselistener(new mychartmouselistener()); 

in method want check if cursor near of candles:

@override     public void chartmouseclicked(chartmouseevent chartmouseevent) {         int x = chartmouseevent.gettrigger().getx();         int y = chartmouseevent.gettrigger().gety();         getcandleclosetocursor(x,y);     } 

how should getcandleclosetocursor method like?

private point getcandleclosetocursor(int x, int y) {         //return point belongs candle near x,y position;         //either high, low, close, open position         return null;     } 

hopefully it's little bit more clear now.

a candlestickrenderer collects chartentity information in implementation of drawitem(), lacks resolution want. required geometry calculated on fly each item , never stored explicitly. absent entirely new renderer, 1 approach update adjacent jtable relevant data taken ohlcdataset. give tablemodel access chartmouselistener, obtain reference ohlcdataset dataset, , use accessor methods fulfill tablemodel contract, shown here. exact details depend on requirements, may able leverage jtable filtering.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -