Code: Select all
private static JFreeChart createChart(TimeSeriesCollection dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
null,
null,
"Bandwidth (B/s)",
dataset,
true,
true,
false
);
XYPlot plot = chart.getXYPlot();
ValueAxis axis = plot.getDomainAxis();
plot.setRenderer(1, new DefaultXYItemRenderer()); // ?????????
axis.setAutoRange(true);
axis.setNegativeArrowVisible(false);
axis.setFixedAutoRange(60000.0); // 60 seconds
axis = plot.getRangeAxis();
ChartPanel chartPanel = new ChartPanel(chart);
return chart;
}
I want to set renderer , but still get this error :
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Index 'index' out of bounds.
at org.jfree.chart.plot.XYPlot.getDomainAxisForDataset(XYPlot.java:2536)
at org.jfree.chart.plot.XYPlot.drawDomainMarkers(XYPlot.java:2741)
at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:2024)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:974)
at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1132)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
hava any one the ideas ?
thanks