stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
The graph shows just fine for me.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
No of course not. I don't have that file and you have it commented out. You said the graphic was not plotting.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
I don't think you want an XYSeries for that. If you want it to be a line chart (bar chart seems more appropriate to me, but you seem to want the line chart), try this instead
private CategoryDataset createDataset() throws Exception {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(255, "Errors", "error1");
dataset.addValue(34, "Errors", "error2");
dataset.addValue(111, "Errors", "error5");
dataset.addValue(23, "Errors", "error3");
return dataset;
}
private JFreeChart createChart(CategoryDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createLineChart(
"Medida", // chart title
"Error Code", // x axis label
"Count", // y axis label
dataset, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
return chart;
}
All you have to do is build that category dataset with the first and second elements of your spilt() on the text file line.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
There is a bar chart demo file in the source\org\jfree\chart\demo directory of JFreeChart.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
You already have the basic part of that in place. Read each line of the file, use split() to separate the elements, then add that pair of values to your series for the chart.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
please tell me steps to draw bar graph from a file values using java and also code....
you want to use Java AND code? now, that 'll be a tough one I bet.
I'll give you the first couple of steps though:
1. try yourself
2. when you get in trouble, start a NEW thread, show us your efforts so we can see where you're going wrong
3. but hey, just read the thread you're replying to, everything you need can be derived from it
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433