Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java DynamicMiseriesCollection中的XYTextAnnotation_Java_Jfreechart - Fatal编程技术网

Java DynamicMiseriesCollection中的XYTextAnnotation

Java DynamicMiseriesCollection中的XYTextAnnotation,java,jfreechart,Java,Jfreechart,我正在尝试在DynamicMiseriesCollection中实现XYTextAnnotation。 我不知道如何在DynamicMiseriesCollection中找到级数的X值。到目前为止,我的代码是: DynamicTimeSeriesCollection dataset = new DynamicTimeSeriesCollection(1, 60, new Minute()); final JFreeChart result = ChartFactory.createTimeSer

我正在尝试在DynamicMiseriesCollection中实现XYTextAnnotation。 我不知道如何在DynamicMiseriesCollection中找到级数的X值。到目前为止,我的代码是:

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);
这是一个用于使用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);
}
从这里开始,我在createChart中添加了以下几行,以获得下图:

double x = dataset.getXValue(0, COUNT - 1);
double y = dataset.getYValue(0, COUNT - 1);
String s = dataset.getY(0, COUNT - 1).toString();
XYTextAnnotation a = new XYTextAnnotation(s, x, y);
a.setFont(a.getFont().deriveFont(24f));
plot.addAnnotation(a);
从这里开始,我在createChart中添加了以下几行,以获得下图:

double x = dataset.getXValue(0, COUNT - 1);
double y = dataset.getYValue(0, COUNT - 1);
String s = dataset.getY(0, COUNT - 1).toString();
XYTextAnnotation a = new XYTextAnnotation(s, x, y);
a.setFont(a.getFont().deriveFont(24f));
plot.addAnnotation(a);

到底是什么不起作用?series1变量在哪里?它到底起什么作用?series1变量在哪里?