Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: How to generate bar chart using java by reading the input from file.?

  1. #1
    orlando.boomi is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Question How to generate bar chart using java by reading the input from file.?

    Hi, I need to generate bar chart using java by reading the input file. I am using fedora 14.

    for example,

    input.txt
    xaxis y axis
    12 17
    26 30
    40 40.

    Using that input.txt file I need to generate chart. Please help me.

    Thanks in advance.....
    Last edited by orlando.boomi; 01-29-2012 at 02:18 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,419
    Rep Power
    20

    Default Re: How to generate bar chart using java by reading the input from file.?

    Quote Originally Posted by orlando.boomi View Post
    Please help me.
    Sure. What have you tried, and where are you stuck?

    Recommended reading: How to ask questions the smart way

    db
    Fubarable likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How to generate bar chart using java by reading the input from file.?

    I second Darryl's question. Please understand that no one's going to do this for you, and since your question is so general and vague and doesn't tell us what you've tried or where specifically you're stuck, about all we can do is suggest that you read the Java tutorials. So for more "helpful" help, please provide the details of your problem. Darryl's link will outline just what information we need in order to be able to help you.

  4. #4
    orlando.boomi is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Re: How to generate bar chart using java by reading the input from file.?

    Hi Fubarable,
    Thanks, I used JfreeChart for my requirement. But I don't know how to use that JfreeChart. Currently I am using Jexcel package for writing java code. I need to write the data into the excel cells from the input file. First I am trying this code.

    jxlmacro.java

    import java.io.File;
    import java.util.*;
    import jxl.*;
    import jxl.write.*;

    public class jxlmacro
    {
    WritableWorkbook workbook = Workbook.createWorkbook(new File("output.xls"));
    public static void main(String args[])
    {
    WritableSheet sheet = Workbook.createSheet("First Sheet",0);
    Label label = new Label(0,2,"A label record");
    sheet.addCell(label);
    jxl.write.Number number = new jxl.write.Number(3,4,3.1459);
    sheet.addCell(number);
    jxl.Workbook.write();
    jxl.Workbook.close();
    }
    }

    If i compile this code, I am getting the below errors.

    ERROR:
    jxlmacro.java:12: cannot find symbol
    symbol : method createSheet(java.lang.String,int)
    location: class jxl.Workbook
    WritableSheet sheet = Workbook.createSheet("First Sheett",0);
    ^
    jxlmacro.java:17: cannot find symbol
    symbol : method Write()
    location: class jxl.Workbook
    jxl.Workbook.Write();
    ^
    jxlmacro.java:18: non-static method close() cannot be referenced from a static context
    jxl.Workbook.close();
    ^
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.

    Please give me a solution.
    Last edited by orlando.boomi; 01-29-2012 at 02:45 PM.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How to generate bar chart using java by reading the input from file.?

    I don't use JFreeChart and so can't give you specific help, but the error messages can be quite helpful; so let's look at them. For instance this one:

    Java Code:
    jxlmacro.java:12: cannot find symbol
    symbol  : method createSheet(java.lang.String,int)
    location: class jxl.Workbook
                    WritableSheet sheet = Workbook.createSheet("First Sheett",0);
                                                  ^
    is telling you that the class jxl.Workbook doesn't have a static method createSheet that takes a String and an int as parameters.


    And this error:
    Java Code:
    jxlmacro.java:17: cannot find symbol
    symbol  : method Write()
    location: class jxl.Workbook
                    jxl.Workbook.Write();
                                ^
    Is telling you that the jxl.Workbook class does not have a parameterless static Write method.


    This one is telling you that the jxl.Workbook method close() is not static and cannot be called on the Workbook class:
    Java Code:
    jxlmacro.java:18: non-static method close() cannot be referenced from a static context
                    jxl.Workbook.close();
                                ^
    Probably it can be called on a Workbook instance.


    Your best bet is to read over the JFreeChart API and other documentation to see just what classes and methods are available and only use those methods. Be careful not to try to use classes in a static way when you should in fact be creating instances of the classes and calling method on these instances. Be careful of your spelling and capitalization. For example, you're trying to call a method "W"rite, when I know that JFreeChart's code follows Java naming conventions and that all of its method names begin with a lower case letter.

    Luck!

Similar Threads

  1. How to plot the graph,where the data from text file?
    By Haryanti in forum New To Java
    Replies: 2
    Last Post: 12-01-2011, 06:11 PM
  2. java graph plot taking file data
    By niloR19 in forum AWT / Swing
    Replies: 3
    Last Post: 11-28-2011, 06:56 PM
  3. How to plot graph in java for given samples
    By annesteve31 in forum New To Java
    Replies: 27
    Last Post: 11-29-2009, 09:27 PM
  4. i want plot realtime graph in java
    By santhosh_el in forum New To Java
    Replies: 3
    Last Post: 02-26-2009, 08:32 AM
  5. Plot 2D graph in Java from RS-232 data
    By spratana in forum Java 2D
    Replies: 4
    Last Post: 02-11-2009, 06:49 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
  •