}
// compile annotations to determine if we have any to graph
final List<Annotation> notes = new ArrayList<Annotation>();
for (int i = 0; i < nseries; i++) {
final DataPoints dp = datapoints.get(i);
final List<Annotation> series_notes = dp.getAnnotations();
if (series_notes != null && !series_notes.isEmpty()) {
notes.addAll(series_notes);
}
}
if (globals != null) {
notes.addAll(globals);
}
if (notes.size() > 0) {
Collections.sort(notes);
for(Annotation note : notes) {
String ts = Long.toString(note.getStartTime());
String value = new String(note.getDescription());
gp.append("set arrow from \"").append(ts).append("\", graph 0 to \"");
gp.append(ts).append("\", graph 1 nohead ls 3\n");
gp.append("set object rectangle at \"").append(ts);
gp.append("\", graph 0 size char (strlen(\"").append(value);
gp.append("\")), char 1 front fc rgbcolor \"white\"\n");
gp.append("set label \"").append(value).append("\" at \"");
gp.append(ts).append("\", graph 0 front center\n");
}
}
gp.write("plot ");
for (int i = 0; i < nseries; i++) {
final DataPoints dp = datapoints.get(i);
final String title = dp.metricName() + dp.getTags();
gp.append(" \"").append(datafiles[i]).append("\" using 1:2");
if (smooth != null) {
gp.append(" smooth ").append(smooth);
}
// TODO(tsuna): Escape double quotes in title.