new to jfree

A discussion forum for the JCommon class library.

new to jfree

Postby raghav » Fri Aug 03, 2007 7:12 am

help me..... how to execute jfree...... i'm new to jfree

Code: Select all
package org.jfree.chart.demo;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPosition;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.CategoryLabelWidthType;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.text.TextBlockAnchor;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RectangleAnchor;
import org.jfree.ui.RefineryUtilities;
import org.jfree.ui.TextAnchor;
import org.jfree.util.Log;
import org.jfree.util.PrintStreamLogTarget;

/**
* A simple demonstration application showing how to create a horizontal 3D bar chart using data
* from a {@link CategoryDataset}.
*
*/
public class BarChart3DDemo2 extends ApplicationFrame {

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    *
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************
   
    /**
     * Creates a new demo.
     *
     * @param title  the frame title.
     */
    public BarChart3DDemo2(final String title) {

        super(title);
       
        // create the chart...
        final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(23.0, "Series 1", "London");
        dataset.addValue(14.0, "Series 1", "New York");
        dataset.addValue(14.0, "Series 1", "Istanbul");
        dataset.addValue(14.0, "Series 1", "Cairo");
        dataset.addValue(13.0, "Series 2", "London");
        dataset.addValue(19.0, "Series 2", "New York");
        dataset.addValue(19.0, "Series 2", "Istanbul");
        dataset.addValue(19.0, "Series 2", "Cairo");
        dataset.addValue(7.0, "Series 3", "London");
        dataset.addValue(9.0, "Series 3", "New York");
        dataset.addValue(9.0, "Series 3", "Istanbul");
        dataset.addValue(9.0, "Series 3", "Cairo");
       
        final JFreeChart chart = createChart(dataset);
       
        // add the chart to a panel...
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);

    }

    /**
     * Creates a chart.
     *
     * @param dataset  the dataset.
     *
     * @return The chart.
     */
    private JFreeChart createChart(final CategoryDataset dataset) {
       
        final JFreeChart chart = ChartFactory.createBarChart3D(
            "3D Bar Chart Demo 2",       // chart title
            "Category",                  // domain axis label
            "Value",                     // range axis label
            dataset,                     // data
            PlotOrientation.HORIZONTAL,  // orientation
            true,                        // include legend
            true,                        // tooltips
            false                        // urls
        );

        final CategoryPlot plot = chart.getCategoryPlot();
        plot.setForegroundAlpha(1.0f);

        // left align the category labels...
        final CategoryAxis axis = plot.getDomainAxis();
        final CategoryLabelPositions p = axis.getCategoryLabelPositions();
       
        final CategoryLabelPosition left = new CategoryLabelPosition(
            RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
            TextAnchor.CENTER_LEFT, 0.0,
            CategoryLabelWidthType.RANGE, 0.30f
        );
        axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left));
       
        return chart;       
   
    }
   
    /**
     * Starting point for the demonstration application.
     *
     * @param args  ignored.
     */
    public static void main(final String[] args) {

        Log.getInstance().addTarget(new PrintStreamLogTarget());
        final BarChart3DDemo2 demo = new BarChart3DDemo2("3D Bar Chart Demo 2");
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);

    }

}


here's the errror message

E:\raghav>javac BarChart3DDemo2.java
BarChart3DDemo2.java:3: cannot find symbol
symbol : class ChartFactory
location: package org.jfree.chart
import org.jfree.chart.ChartFactory;
^
BarChart3DDemo2.java:4: cannot find symbol
symbol : class ChartPanel
location: package org.jfree.chart
import org.jfree.chart.ChartPanel;
^
BarChart3DDemo2.java:5: cannot find symbol
symbol : class JFreeChart
location: package org.jfree.chart
import org.jfree.chart.JFreeChart;
^
BarChart3DDemo2.java:6: package org.jfree.chart.axis does not exist
import org.jfree.chart.axis.CategoryAxis;
^
BarChart3DDemo2.java:7: package org.jfree.chart.axis does not exist
import org.jfree.chart.axis.CategoryLabelPosition;
^
BarChart3DDemo2.java:8: package org.jfree.chart.axis does not exist
import org.jfree.chart.axis.CategoryLabelPositions;
^
BarChart3DDemo2.java:9: package org.jfree.chart.axis does not exist
import org.jfree.chart.axis.CategoryLabelWidthType;
^
BarChart3DDemo2.java:10: package org.jfree.chart.plot does not exist
import org.jfree.chart.plot.CategoryPlot;
^
BarChart3DDemo2.java:11: package org.jfree.chart.plot does not exist
import org.jfree.chart.plot.PlotOrientation;
^
BarChart3DDemo2.java:12: package org.jfree.data.category does not exist
import org.jfree.data.category.CategoryDataset;
^
BarChart3DDemo2.java:13: package org.jfree.data.category does not exist
import org.jfree.data.category.DefaultCategoryDataset;
^
BarChart3DDemo2.java:14: package org.jfree.text does not exist
import org.jfree.text.TextBlockAnchor;
^
BarChart3DDemo2.java:15: package org.jfree.ui does not exist
import org.jfree.ui.ApplicationFrame;
^
BarChart3DDemo2.java:16: package org.jfree.ui does not exist
import org.jfree.ui.RectangleAnchor;
^
BarChart3DDemo2.java:17: package org.jfree.ui does not exist
import org.jfree.ui.RefineryUtilities;
^
BarChart3DDemo2.java:18: package org.jfree.ui does not exist
import org.jfree.ui.TextAnchor;
^
BarChart3DDemo2.java:19: package org.jfree.util does not exist
import org.jfree.util.Log;
^
BarChart3DDemo2.java:20: package org.jfree.util does not exist
import org.jfree.util.PrintStreamLogTarget;
^
BarChart3DDemo2.java:27: cannot find symbol
symbol: class ApplicationFrame
public class BarChart3DDemo2 extends ApplicationFrame {
^
BarChart3DDemo2.java:80: cannot find symbol
symbol : class CategoryDataset
location: class org.jfree.chart.demo.BarChart3DDemo2
private JFreeChart createChart(final CategoryDataset dataset) {
^
BarChart3DDemo2.java:80: cannot find symbol
symbol : class JFreeChart
location: class org.jfree.chart.demo.BarChart3DDemo2
private JFreeChart createChart(final CategoryDataset dataset) {
^
BarChart3DDemo2.java:50: cannot find symbol
symbol : class DefaultCategoryDataset
location: class org.jfree.chart.demo.BarChart3DDemo2
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
^
BarChart3DDemo2.java:50: cannot find symbol
symbol : class DefaultCategoryDataset
location: class org.jfree.chart.demo.BarChart3DDemo2
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
^
BarChart3DDemo2.java:64: cannot find symbol
symbol : class JFreeChart
location: class org.jfree.chart.demo.BarChart3DDemo2
final JFreeChart chart = createChart(dataset);
^
BarChart3DDemo2.java:67: cannot find symbol
symbol : class ChartPanel
location: class org.jfree.chart.demo.BarChart3DDemo2
final ChartPanel chartPanel = new ChartPanel(chart);
^
BarChart3DDemo2.java:67: cannot find symbol
symbol : class ChartPanel
location: class org.jfree.chart.demo.BarChart3DDemo2
final ChartPanel chartPanel = new ChartPanel(chart);
^
BarChart3DDemo2.java:82: cannot find symbol
symbol : class JFreeChart
location: class org.jfree.chart.demo.BarChart3DDemo2
final JFreeChart chart = ChartFactory.createBarChart3D(
^
BarChart3DDemo2.java:87: cannot find symbol
symbol : variable PlotOrientation
location: class org.jfree.chart.demo.BarChart3DDemo2
PlotOrientation.HORIZONTAL, // orientation
^
BarChart3DDemo2.java:82: cannot find symbol
symbol : variable ChartFactory
location: class org.jfree.chart.demo.BarChart3DDemo2
final JFreeChart chart = ChartFactory.createBarChart3D(
^
BarChart3DDemo2.java:93: cannot find symbol
symbol : class CategoryPlot
location: class org.jfree.chart.demo.BarChart3DDemo2
final CategoryPlot plot = chart.getCategoryPlot();
^
BarChart3DDemo2.java:97: cannot find symbol
symbol : class CategoryAxis
location: class org.jfree.chart.demo.BarChart3DDemo2
final CategoryAxis axis = plot.getDomainAxis();
^
BarChart3DDemo2.java:98: cannot find symbol
symbol : class CategoryLabelPositions
location: class org.jfree.chart.demo.BarChart3DDemo2
final CategoryLabelPositions p = axis.getCategoryLabelPositions();
^
BarChart3DDemo2.java:100: cannot find symbol
symbol : class CategoryLabelPosition
location: class org.jfree.chart.demo.BarChart3DDemo2
final CategoryLabelPosition left = new CategoryLabelPosition(
^
BarChart3DDemo2.java:100: cannot find symbol
symbol : class CategoryLabelPosition
location: class org.jfree.chart.demo.BarChart3DDemo2
final CategoryLabelPosition left = new CategoryLabelPosition(
^
BarChart3DDemo2.java:101: cannot find symbol
symbol : variable RectangleAnchor
location: class org.jfree.chart.demo.BarChart3DDemo2
RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
^
BarChart3DDemo2.java:101: cannot find symbol
symbol : variable TextBlockAnchor
location: class org.jfree.chart.demo.BarChart3DDemo2
RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
^
BarChart3DDemo2.java:102: cannot find symbol
symbol : variable TextAnchor
location: class org.jfree.chart.demo.BarChart3DDemo2
TextAnchor.CENTER_LEFT, 0.0,
^
BarChart3DDemo2.java:103: cannot find symbol
symbol : variable CategoryLabelWidthType
location: class org.jfree.chart.demo.BarChart3DDemo2
CategoryLabelWidthType.RANGE, 0.30f
^
BarChart3DDemo2.java:105: cannot find symbol
symbol : variable CategoryLabelPositions
location: class org.jfree.chart.demo.BarChart3DDemo2
axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left));
^
BarChart3DDemo2.java:118: cannot find symbol
symbol : class PrintStreamLogTarget
location: class org.jfree.chart.demo.BarChart3DDemo2
Log.getInstance().addTarget(new PrintStreamLogTarget());
^
BarChart3DDemo2.java:118: cannot find symbol
symbol : variable Log
location: class org.jfree.chart.demo.BarChart3DDemo2
Log.getInstance().addTarget(new PrintStreamLogTarget());
^
BarChart3DDemo2.java:120: cannot find symbol
symbol : method pack()
location: class org.jfree.chart.demo.BarChart3DDemo2
demo.pack();
^
BarChart3DDemo2.java:121: cannot find symbol
symbol : variable RefineryUtilities
location: class org.jfree.chart.demo.BarChart3DDemo2
RefineryUtilities.centerFrameOnScreen(demo);
^
BarChart3DDemo2.java:122: cannot find symbol
symbol : method setVisible(boolean)
location: class org.jfree.chart.demo.BarChart3DDemo2
demo.setVisible(true);
^
44 errors
raghav
 
Posts: 1
Joined: Fri Aug 03, 2007 7:07 am

Postby jeyanthan_kr » Wed Jul 02, 2008 7:42 pm

HI ,

You have to set ur classpath with jcommon and jfreechart jar files antd then try to run it.
jeyanthan_kr
 
Posts: 1
Joined: Wed Jul 02, 2008 7:41 pm


Return to JCommon

Who is online

Users browsing this forum: No registered users and 2 guests