Results 1 to 4 of 4

Thread: Automatically input data into Datasets

  1. #1
    Join Date
    Nov 2008
    Posts
    20

    Automatically input data into Datasets

    Hi,
    I am using JFreechart in java to create a graph of some data that i have produced using a program i have written(in java). The problem that i have is that i have to manually input the data into the dataset to create the graph. Is it possible to generate the data that will go into the dataset without having to manually input the data? if yes can someone please explain to me how i might go about it? Thank you for your help.
    Last edited by Yogesh; 27-04-2009 at 08:17 AM. Reason: Title edited suitably. Always give proper title that best describes your thread.

  2. #2
    Join Date
    May 2008
    Posts
    3,971

    Re: Datasets

    You can definitely do that. I will provide you a simple sample code for that. Here it is:

    Code:
    /**
        * Create pie chart representing percentage of employees in each department
        * that has at least one employee.
        * 
        * @return Pie chart; null if no image created.
        */
       public JFreeChart createNumberEmpsPerDeptPieChart()
       {
          JFreeChart pieChart = null;
    
          final String QUERY_NUMBER_EMPLOYEES_PER_DEPARTMENT =
             "SELECT departments.department_name, count(*) AS num_employees " +
               "FROM departments, employees " +
              "WHERE employees.department_id = departments.department_id " +
           "GROUP BY departments.department_name";
    
          final String TITLE_EMPS_PER_DEPT = “Employees Per Department”;
    
          try
          {
             PieDataset pieDataset =
                new JDBCPieDataset( databaseAccess.getOracleDbConnection(),
                                    QUERY_NUMBER_EMPLOYEES_PER_DEPARTMENT );
    
             pieChart =
                ChartFactory.createPieChart( TITLE_EMPS_PER_DEPT, // chart title
                                             pieDataset,
                                             true,      // legend displayed
                                             true,      // tooltips displayed
                                             false );   // no URLs
    
          }
          catch (SQLException sqlEx)    // checked exception
          {
             System.err.println("Error trying to acquire JDBCPieDataset.");
             System.err.println("Error Code: " + sqlEx.getErrorCode());
             System.err.println("SQLSTATE:   " + sqlEx.getSQLState());
             sqlEx.printStackTrace();
          }
    
          return pieChart;
       }

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Datasets

    Though I am not much into Java but in .net, I think it is not possible to make such thing that will automatically input data into your datasets. As it is, manually inputting of data is better for proper functioning.

  4. #4
    Pragmatic Guest

    Re: Automatically input data into Datasets

    Yes, it is definitely possible. I think you would have tried the suggestion of switchblade327.

Similar Threads

  1. Does chrome detects the input language automatically?
    By Ketaki in forum Technology & Internet
    Replies: 6
    Last Post: 24-05-2011, 11:12 AM
  2. HID Non-User Input Data Filter (KB 911895)
    By akny84b in forum Windows Update
    Replies: 10
    Last Post: 01-07-2010, 10:07 PM
  3. HID Non-User Input Data Filter Error
    By Martin in forum Windows Update
    Replies: 8
    Last Post: 07-06-2010, 06:39 AM
  4. HID Non-User Input Data Filter
    By shivendra in forum Vista Setup and Install
    Replies: 3
    Last Post: 31-05-2009, 05:17 AM
  5. HID Non-User Input Data Filter
    By DrJoel in forum Windows Update
    Replies: 2
    Last Post: 13-10-2008, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,105,517.49208 seconds with 16 queries