View Single Post
Join Date: May 2007
Posts: 4,483
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 515
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Plot Chart from a Txt file

 
0
  #8
Nov 21st, 2008
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
  1. private CategoryDataset createDataset() throws Exception {
  2.  
  3. DefaultCategoryDataset dataset = new DefaultCategoryDataset();
  4. dataset.addValue(255, "Errors", "error1");
  5. dataset.addValue(34, "Errors", "error2");
  6. dataset.addValue(111, "Errors", "error5");
  7. dataset.addValue(23, "Errors", "error3");
  8.  
  9. return dataset;
  10. }
  11.  
  12. private JFreeChart createChart(CategoryDataset dataset) {
  13. // create the chart...
  14. JFreeChart chart = ChartFactory.createLineChart(
  15. "Medida", // chart title
  16. "Error Code", // x axis label
  17. "Count", // y axis label
  18. dataset, // data
  19. PlotOrientation.VERTICAL,
  20. true, // include legend
  21. true, // tooltips
  22. false // urls
  23. );
  24.  
  25. return chart;
  26. }
All you have to do is build that category dataset with the first and second elements of your spilt() on the text file line.
Reply With Quote