View Single Post
Join Date: Apr 2008
Posts: 45
Reputation: jorgeflorencio is an unknown quantity at this point 
Solved Threads: 0
jorgeflorencio jorgeflorencio is offline Offline
Light Poster

Re: Plot Chart from a Txt file

 
0
  #9
Nov 21st, 2008
You are right... i want a bar chart... but as a newby i'm still trying to discover to potential of the javafreechart... reading trying reading trying... i'm too slowwww...

thank you for your lights...~

to change for a bar type what should i dooo??

Originally Posted by Ezzaral View Post
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