Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners To display the bar graph
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Prajakta S
To display the bar graph
1 Answer(s)      2 years and 11 months ago
Posted in : Java Beginners


hi........

I am able to get the output of bar graph. but now i want that to be displayed on my own form. The code which i am having in that the output is displayed in another form, its creating new form but i want to display it in my form only. Means i want it to be displayed on my form that i have created. Can u tell me how to do this???????

Plz help........

I tried to display in label or scroll pane but its giving me error cannot find the method i think its not compatible with this components. Can u plz help????????????


Advertisement
View Answers

December 29, 2011 at 12:43 PM


import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import org.jfree.data.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.data.category.*;
import org.jfree.chart.renderer.category.*;

public class BarChartExample{
public static void main(String arg[]){
    JButton b=new JButton("Show Graph");
    JFrame f=new JFrame();
    f.setLayout(null);
    b.setBounds(10,10,120,20);
    final JLabel l=new JLabel();
    l.setBounds(10,40,400,300);
    f.add(l);
    f.add(b);
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.setValue(72, "Marks", "A");
        dataset.setValue(75, "Marks", "B");
        dataset.setValue(48, "Marks", "C");
        dataset.setValue(98, "Marks", "D");
        dataset.setValue(67, "Marks", "E");
        JFreeChart chart = ChartFactory.createBarChart("BarChart using JFreeChart","Student", "Marks", dataset, 
        PlotOrientation.VERTICAL, false,true, false);
        try{
          File f=new File("C:/chart.jpg");
          ChartUtilities.saveChartAsJPEG(f, chart, 400, 300);
          ImageIcon icon=new ImageIcon(f.getPath());
          l.setIcon(icon);
        }
        catch (IOException ex){
          System.out.println("Problem in creating chart.");
        }
      }
    });
    f.setSize(500,450);
    f.setVisible(true);
  }
}


Related Tutorials/Questions & Answers:
To display the bar graph
To display the bar graph  hi........ I am able to get the output of bar graph. but now i want that to be displayed on my own form. The code which i... but i want to display it in my form only. Means i want it to be displayed on my
Bar graph
Bar graph  How to include a bar chart in iPhone sdk
Advertisements
Create Bar graph
Create Bar graph  hi............. In my project i want to create a BAR GRAPH to display the result. I HAVE certain values that want to show in graph form. Can u help me plzzzzzzz i require a very simple code in java swings were
datewise/monthwise bar graph
datewise/monthwise bar graph  How to make a datewise/monthwise bar graph using the values from the ms access database? please help its urgent
Read Excel file and generate bar graph
Read Excel file and generate bar graph In this tutorial, you will learn how to read an excel file and generate bar graph. Here is an example that reads... the data of excel file, we have generated a bar chart. The given code uses Apache
Create Bar Graph from reading excel sheet in Java
Create Bar Graph from reading excel sheet in Java  I'm New to Java... and plot a bar graph between browser and test case pass/fail based on the data in the different excel sheets (data can change and based on that graph should also get
Graph
Graph  What is the code to generate the following graphs? 1.Simple Bar diagram 2.Sub-divided Bar diagram 3.Pie chart Please Help!!!!   Please visit the following link: Java charts and graphs
Fetching data from excel file on other website and display in interactive graph form
Fetching data from excel file on other website and display in interactive graph form  Hello, I am making a website using HTML and CSS, I am done with the layout, I have to generate ineractive graphs like stock market's, Can you
PHP GD line graph
,'Line Graph by: Roseindia Technologies',$red); imagepng($im); ?> After
Graph in JAVA SWING
, Please visit the following link: Bar Graph in Java Swing Thanks...Graph in JAVA SWING  Hi, How to draw a simple GRAPH in JAVA SWING ?  
Bar Chart
Bar Chart  hi...... Thanks 4 ur help for the bar graph creation i have got what i wanted. But now want to ask that in that bar graph i want multiple bar on one value means I want to create a graph where on my x-axis i have
to show graph
to show graph  by clicking on submit button how to show the graph by fetching data in mysql?   Please visit the following link: JSP graph by fetching data in mysql
line graph
line graph  I have developed an application and in that i have to compare 2 reports using line graph from the data taken from ms access database?please help
about graph - Applet
about graph  How to draw a graph in applet and that should be display in web browser? How to make a running applet in our browser? for example ticker
Applet Graph
columns-names by using check box and click on graph button, 3..then i have to get a graph between those columns in a applet plz send me the code thank u
Autoupdating graph
Autoupdating graph  Hey Anyone who might help me making a XY graph, that autoupdates lets say every 5th minute. All the datasets comes from an mySQL database, and the dataset in the database, comes from a txt file and are being
Create Progress Bar in SWT
Create Progress Bar in SWT   ... Bar. SWT allows to create a Progress bar by providing the class ProgressBar of package org.eclipse.swt.widgets. With the use of this class, you can display
bar chart
bar chart  how to create a bar chart from values of the database and the string value should be the entities of the database??plzz help..needed badly
plot a graph in Java
plot a graph in Java   I need to plot a graph in Java but the samples are not known in advance. The samples keep on coming through callback and I... and the final graph may be quite congested. So please guide me on this. Thanks
Stacked Bar Chart
Stacked Bar Chart  How to display a stacked bar chart using java from the values stored in the ms access database?Plzz help..its urgent
progress bar
progress bar  Hi guys, I'm doing a file upload in spring MVC technology. For file upload i did validation in client side.While uploading how to use an ajax function to show the progress bar
Progress Bar
Progress Bar  Hi friend, I'm interested in knowing how to progress bar in oracle forms 9i for the trigger when-button-pressed.Thankyou. Thanks and Regards, M.SHANKAR
Changing 2D graph using slider.
Changing 2D graph using slider.  Code for changing a 2d graph with help of slider
plotting a graph - Java Beginners
plotting a graph  pls help me out regarding plotting a graph. I have done that through LiveGraph API. but now i required the graph to be displayed on the gui- window. and whatever inputs i will pass it must change the graph
hybrid graph (jfree chart) - Swing AWT
hybrid graph (jfree chart)  hello i have a problem related to jfree chart.I want to display hybrid graph (Stacked Area and Line ).combination.... Thanks.   Hi, Plz what the requirement of hybrid graph
Bar chart with J table
tell me how can I make a bar graph that will display the data from my table.I tried using the code from your page (http://www.roseindia.net/chartgraphs/bar...Bar chart with J table  Hi I'm new in Java and I have a application
statistical graph in jsp - JSP-Servlet
statistical graph in jsp  how to create a statistical graph to show the highest mark and the lowest mark of a table named test which consist of two... by a graph without hard coding the id's and the scores
How to create bar chart using database values
How to create bar chart using database values  How to create bar chart using database values i.e excellent,good,average fields using jsp?It is like... in a graph format
radar graph in java
radar graph in java  Hi All I am developing a java application. In this application i need to show a radar grap.when some body assigne rating then each rating should show on x y z axis. please suggest me some good way to do
JFreechart Stacked Bar Chart
. In the following example, each bar of the stacked bar graph is divided into two...JFreechart Stacked Bar Chart JFreechart provides a way to create various charts by just using the methods of different classes. You are well aware of bar
Advertisements
 

 

 

DMCA.com