Results 1 to 3 of 3
  1. #1
    neeraj.singh is offline Member
    Join Date
    Feb 2009
    Location
    Delhi
    Posts
    63
    Rep Power
    0

    Default Getting ExceptionInInitializer exception when i am trying to code a time series chart

    I am coding a timeSeriesChart using JFreeChart API,

    below is the code

    Java Code:
    import java.awt.Color;
    import java.text.DateFormat;
    
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.axis.DateAxis;
    import org.jfree.chart.labels.CategoryToolTipGenerator;
    import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
    import org.jfree.chart.plot.CategoryPlot;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.chart.renderer.category.CategoryItemRenderer;
    import org.jfree.chart.renderer.category.LineAndShapeRenderer;
    import org.jfree.data.category.DefaultCategoryDataset;
    import org.jfree.data.time.Day;
    import org.jfree.date.SerialDate;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;
    
    public class TimeSeriesChart extends ApplicationFrame {
    
        public TimeSeriesChart(final String title) {
    
            super(title);
    
            // create a dataset...
            final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    
            // initialise the data...
            final Day d1 = new Day(12, SerialDate.JUNE, 2002);
            final Day d2 = new Day(14, SerialDate.JUNE, 2002);
            final Day d3 = new Day(15, SerialDate.JUNE, 2002);
            final Day d4 = new Day(10, SerialDate.JULY, 2002);
            final Day d5 = new Day(20, SerialDate.JULY, 2002);
            final Day d6 = new Day(22, SerialDate.AUGUST, 2002);
    
            dataset.setValue(new Long(d1.getMiddleMillisecond()), "Series 1", "Requirement 1");
            dataset.setValue(new Long(d1.getMiddleMillisecond()), "Series 1", "Requirement 2");
            dataset.setValue(new Long(d2.getMiddleMillisecond()), "Series 1", "Requirement 3");
            dataset.setValue(new Long(d3.getMiddleMillisecond()), "Series 2", "Requirement 1");
            dataset.setValue(new Long(d4.getMiddleMillisecond()), "Series 2", "Requirement 3");
            dataset.setValue(new Long(d5.getMiddleMillisecond()), "Series 3", "Requirement 2");
            dataset.setValue(new Long(d6.getMiddleMillisecond()), "Series 1", "Requirement 4");
    
            // create the chart...
            final JFreeChart chart = ChartFactory.createBarChart(
                "Event Frequency Demo",      // title
                "Category",                  // domain axis label
                "Value",                     // range axis label
                dataset,                     // dataset
                PlotOrientation.HORIZONTAL,  // orientation
                true,                        // include legend
                true,                        // tooltips
                false                        // URLs
            );
    
            // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    
            // set the background color for the chart...
            chart.setBackgroundPaint(new Color(0xFF, 0xFF, 0xCC));
    
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
      //      legend.setDisplaySeriesShapes(true);
    
            // get a reference to the plot for further customisation...
            final CategoryPlot plot = chart.getCategoryPlot();
        //    plot.getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f);
            plot.setRangeAxis(new DateAxis("Date"));
            final CategoryToolTipGenerator toolTipGenerator = new StandardCategoryToolTipGenerator(
                "", DateFormat.getDateInstance()
            );
    //        final CategoryItemRenderer renderer = new LineAndShapeRenderer(LineAndShapeRenderer.SHAPES);
      //      renderer.setToolTipGenerator(toolTipGenerator);
        //    plot.setRenderer(renderer);
    
            
    
            // add the chart to a panel...
            final ChartPanel chartPanel = new ChartPanel(chart);
            chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
            setContentPane(chartPanel);
    
        }
    
        public static void main(final String[] args) {
    
            final TimeSeriesChart demo = new TimeSeriesChart("Event Frequency Demo");
            demo.pack();
            RefineryUtilities.centerFrameOnScreen(demo);
            demo.setVisible(true);
    
        }
    
    }


    The Error is below:
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at TimeSeriesChart.<init>(TimeSeriesChart.java:30)
    at TimeSeriesChart.main(TimeSeriesChart.java:87)
    Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class MonthConstants
    at org.jfree.data.time.RegularTimePeriod.<clinit>(Reg ularTimePeriod.java:69)
    ... 2 more


    Please any one help me,

    Thanks..
    /\/eeraj

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    Exception in thread "main" java.lang.ExceptionInInitializerError
    at TimeSeriesChart.<init>(TimeSeriesChart.java:30)
    at TimeSeriesChart.main(TimeSeriesChart.java:87)
    Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find symbol
    symbol: class MonthConstants

    at org.jfree.data.time.RegularTimePeriod.<clinit>(Reg ularTimePeriod.java:69)
    ... 2 more
    Just read through the exceptions. You have a class MonthConstants that is not imported.

  3. #3
    neeraj.singh is offline Member
    Join Date
    Feb 2009
    Location
    Delhi
    Posts
    63
    Rep Power
    0

    Default

    oh...
    how silly i'm,
    thanks
    i will update you by fixing the code...
    thanks again

Similar Threads

  1. printing two smallest numbers from a series of numbers
    By trofyscarz in forum New To Java
    Replies: 2
    Last Post: 10-14-2008, 11:46 PM
  2. SWT 2D Chart: Flowchart
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 06-28-2008, 09:20 PM
  3. Demo bar chart and pie chart
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 11:22 PM
  4. java.io.Exception: Server returned HTTP response code: 403
    By navishkumarb in forum Advanced Java
    Replies: 1
    Last Post: 01-05-2008, 01:33 PM
  5. No Fluff Just Stuff Software Symposium Series 2007,
    By orchid in forum Reviews / Advertising
    Replies: 0
    Last Post: 04-08-2007, 08:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •