java - XYTextAnnotation in DynamicTimeSeriesCollection -


i'm trying implement xytextannotation in dynamictimeseriescollection. have no idea how find x value of series in dynamictimeseriescollection. code far:

dynamictimeseriescollection dataset = new dynamictimeseriescollection(1, 60, new minute()); final jfreechart result = chartfactory.createtimeserieschart(title, "a", "b", dataset, true, true, false); float[] series1small = new float[10]; dataset.settimebase(new minute(1, 1, 1, 1, 2013)); dataset.addseries(series1small,0,"1"); jfreechart result = chartfactory.createtimeserieschart(title, "Время", "Платежи", dataset, true, true, false); final xyplot plot = result.getxyplot(); -----------------------------------------------------------below line doesn't work.   timeseriesdataitem item1 = series1.getdataitem(series1.getitemcount() - 1); createannotation(item1,plot); 

this function used work annotation timeseriescollection.

 public static void createannotation(timeseriesdataitem item,xyplot plot) {    double xannotation = item.getperiod().getfirstmillisecond();    double yannotation = item.getvalue().doublevalue();    xytextannotation annotation = new xytextannotation(item.getvalue().tostring(), xannotation, yannotation);    annotation.setfont(new font("arial",font.bold,11));    plot.addannotation(annotation); } 

starting form example, added following lines in createchart() obtain image below:

double x = dataset.getxvalue(0, count - 1); double y = dataset.getyvalue(0, count - 1); string s = dataset.gety(0, count - 1).tostring(); xytextannotation = new xytextannotation(s, x, y); a.setfont(a.getfont().derivefont(24f)); plot.addannotation(a); 

text annotation image


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -