how to setRenderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
knopper

how to setRenderer

Post by knopper » Wed Mar 23, 2005 4:21 pm

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

timw
Posts: 20
Joined: Fri Mar 18, 2005 12:36 pm
Location: London

Post by timw » Wed Mar 23, 2005 4:24 pm

have u tried 0 instead of 1 when setting the renderer?

Locked