Add an AxisRenderer for date and time values
Although the currently available LineRenderer2D can be used with a DateFormat to render an axis containing date values, it is hardly possible to get useful ticks.
When the ticks are automatically generated, the axis labels contain a reasonable amount of ticks, but the ticks are drawn at an arbitrary point of time (e.g. 2013-12-13 18:58). A separate AxisRenderer for date and time values should be added that creates ticks at a certain level of granularity (e.g. one tick every full 2 hours).
Imported from trac ticket #73, created by mseifert on 12-13-2013 at 19:00, last modified: 01-20-2014 at 16:15
Is this problem related to the following code showing an empty graph?
`import java.awt.Color; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date;
import javax.swing.JFrame;
import de.erichseifert.gral.data.DataTable; import de.erichseifert.gral.plots.XYPlot; import de.erichseifert.gral.plots.lines.DefaultLineRenderer2D; import de.erichseifert.gral.plots.lines.LineRenderer; import de.erichseifert.gral.ui.InteractivePanel;
public class DatePlotTest extends JFrame { public DatePlotTest() throws ParseException { setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(600, 400);
DateFormat parse = new SimpleDateFormat("yyyyMMddHH");
DataTable data = new DataTable(Date.class, Double.class);
data.add(parse.parse("2017012800"), 1d);
data.add(parse.parse("2017012801"), 2d);
data.add(parse.parse("2017012802"), 3d);
data.add(parse.parse("2017012803"), 4d);
data.add(parse.parse("2017012804"), 5d);
XYPlot plot = new XYPlot(data);
getContentPane().add(new InteractivePanel(plot));
LineRenderer lines = new DefaultLineRenderer2D();
plot.setLineRenderers(data, lines);
Color color = new Color(0.0f, 0.3f, 1.0f);
plot.getPointRenderers(data).get(0).setColor(color);
plot.getLineRenderers(data).get(0).setColor(color);
}
public static void main(String[] args) throws ParseException {
DatePlotTest frame = new DatePlotTest();
frame.setVisible(true);
}
}`