Results 1 to 5 of 5
- 01-29-2012, 02:01 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0
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.
- 01-29-2012, 02:19 PM #2
Re: How to generate bar chart using java by reading the input from file.?
Sure. What have you tried, and where are you stuck?
Recommended reading: How to ask questions the smart way
dbWhy do they call it rush hour when nothing moves? - Robin Williams
-
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.
- 01-29-2012, 02:42 PM #4
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0
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.
-
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:
is telling you that the class jxl.Workbook doesn't have a static method createSheet that takes a String and an int as parameters.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); ^
And this error:
Is telling you that the jxl.Workbook class does not have a parameterless static Write method.Java Code:jxlmacro.java:17: cannot find symbol symbol : method Write() location: class jxl.Workbook jxl.Workbook.Write(); ^
This one is telling you that the jxl.Workbook method close() is not static and cannot be called on the Workbook class:
Probably it can be called on a Workbook instance.Java Code:jxlmacro.java:18: non-static method close() cannot be referenced from a static context jxl.Workbook.close(); ^
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
-
How to plot the graph,where the data from text file?
By Haryanti in forum New To JavaReplies: 2Last Post: 12-01-2011, 06:11 PM -
java graph plot taking file data
By niloR19 in forum AWT / SwingReplies: 3Last Post: 11-28-2011, 06:56 PM -
How to plot graph in java for given samples
By annesteve31 in forum New To JavaReplies: 27Last Post: 11-29-2009, 09:27 PM -
i want plot realtime graph in java
By santhosh_el in forum New To JavaReplies: 3Last Post: 02-26-2009, 08:32 AM -
Plot 2D graph in Java from RS-232 data
By spratana in forum Java 2DReplies: 4Last Post: 02-11-2009, 06:49 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks