Hello,
I use this code to save chart screenshot
private void saveChartScreenShot(IChart chart, long time, double profit) {
try {
String dayMonth = new SimpleDateFormat("dd.MM.yyyy HHmmss").format(new Date(time));
Instrument instrument = chart.getInstrument();
String fileName = String.format("%s %s %.1f.png", dayMonth, instrument.name(), profit);
File outputfile = new File(fileName);
BufferedImage bufferedImage = chart.getImage();
ImageIO.write(bufferedImage, "png", outputfile);
print("%s screenshot saved as %s", instrument.toString(), outputfile.getAbsolutePath());
} catch (IOException e) {
console.getErr().println(e);
}
}
But sometimes screenshots shows things that are not on charts. They are "dirty" with some pieces that are just not there, look attached examples.
I try to add chart.repaint(); before call chart.getImage(); but no result.
example #1
example #2
example #3
example #4