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..

View Answers

December 14, 2012 at 4:54 PM

Here is a code that retrieves the data from the database and create a bar chart from the values.

import java.io.*;
import java.sql.*;
import org.jfree.data.*;
import org.jfree.data.category.*;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.plot.PlotOrientation;

public class Chart{
        public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
        Statement st=conn.createStatement();
        ResultSet rs=st.executeQuery("SELECT * from result");
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                while(rs.next()){
                  dataset.setValue(rs.getInt("result"), "Marks", rs.getString("name"));
                }
                JFreeChart chart =ChartFactory.createBarChart3D("Test", "Name", "Marks",
                dataset, PlotOrientation.VERTICAL, true, true, false);
                try{
                ChartUtilities.saveChartAsJPEG(new File("C:/chart.jpg"),
                chart,400, 300);
               }
               catch (IOException e){
               System.out.println("Problem in creating chart.");
             }
        }
}

Ads









Related Tutorials/Questions & Answers:
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
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
Advertisements
Bar chart implementation in PHP
Bar chart implementation in PHP  How to implements reports in bar graphs by using PHP
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
Bar Chart
Bar Chart       In this section we are providing you an example to create a Bar Chart. Description of Program  For creating a Bar chart we use the object
Bar chart with J table
Bar chart with J table  Hi I'm new in Java and I have a application... 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 using JSP and tooltip to be implemented
Bar Chart using JSP and tooltip to be implemented  Hi Deepak, I have generated a bar chart in JSP using JFreeCharts but I could not get the tool tip for that. Please any one suggest me how to do that or provide some code. Help
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 opinion poll.I want to show how many votes are came for excellent,good,average
Bar Chart
Bar Chart       This section illustrates you how to create bar chart using html in jsp. To draw a bar chart, we have used html tags. In this, firstly
3D Bar Chart
3D Bar Chart       In this section we are providing you an example to create a 3D Bar Chart. Description of Program  For creating a 3D Bar chart we use the object
create bar chart in jsp using msaccess database
create bar chart in jsp using msaccess database  thanks for reply... ChartFrame("Bar Chart",chart); frame1.setVisible(true); frame1.setSize(350,450); %>...;jspService(bar_jsp.java:80) org.apache.jasper.runtime.HttpJspBase.service
create bar chart in jsp using msaccess database
create bar chart in jsp using msaccess database  type Exception report message description The server encountered an internal error... Foundation\Tomcat 5.0\work\Catalina\localhost\chetana\org\apache\jsp\bar_jsp.java:57
Stacked Bar Chart Example using JFreeChart
Stacked Bar Chart Example using JFreeChart... a Stacked bar chart using JFreeChart. Bar chart will represent scores of two team... to create stacked bar chart for given values. It  takes title, domain axis
Bar Chart in Java
Bar Chart in Java      ... to draw simple bar chart in Java. A bar chart (bar graph) is a way of comparing two... chart in Java. To draw a bar chart, the variables minvalue, maxvalue of double type
Stacked Bar Chart using JFreeChart
Stacked Bar Chart using JFreeChart   ... bar chart using JFreeChart. In the code given below we have extended class.... createStackedBarChart(): This method is used to create stacked bar chart for given values
Stacked 3d Bar Chart Example using JFreeChart
Stacked 3d Bar Chart Example using JFreeChart... a Stacked 3d bar chart using JFreeChart. Bar chart will represent the score... is used to create stacked bar chart for given values. It takes title, domain
Java program that inputs a document and then outputs a bar-chart pit
Java program that inputs a document and then outputs a bar-chart pit  Hello, I am new to Java and would like to see a Java Program that inputs a document and then outputs a bar-chart plot relative to the frequencies of each
how to create a bar chart in jsp by fetching value from oracle databse?
how to create a bar chart in jsp by fetching value from oracle databse?  i want to show the population of various states in a bar chart in my jsp page by fetching the data from my oracle table. i am using my eclipse as my IDE
Create a bar chart in JSP page using JFreeChart
Create a bar chart in JSP page using JFreeChart... to create a bar chart in JSP page using JFreeChart. Code given below creates a bar chart...(): This method is used to save chart in to png format. jspbarchart.jsp
how to create bar chart in jsp using msaccess database
how to create bar chart in jsp using msaccess database  type Exception report message description The server encountered an internal error... Foundation\Tomcat 5.0\work\Catalina\localhost\chetana\org\apache\jsp\bar_jsp.java
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
how to fetch data from mysql database table and draw a bar chart on that data using in jsp  how to create bar chart fetch data from mysql database using in jsp.please give me a right code. yhanks in advance
Horizontal Bar Chart Example using JFreeChart
Horizontal Bar Chart Example using JFreeChart... a Horizontal bar chart using JFreeChart. This example showing you match.... createBarChart():  This method is used to create bar chart for given values
Create a 3D bar chart in JSP page using JFreeChart
Create a 3D bar chart in JSP page using JFreeChart... to create a 3D bar chart in jsp page using JFreeChart. Code given below creates a bar chart of scores of two teams in matches. In the code given below
Bar graph
Bar graph  How to include a bar chart in iPhone sdk
Draw Statistical chart in jsp
chart in jsp by getting values from database.. To draw a bar chart, we have... a vertical 3D bar chart. The class PlotOrientation is used to indicate... Draw Statistical chart in jsp   
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)  I have created a servlet.In this,i have retrieved a record from MS Access database in an arraylist i.e. my arraylist
draw chart in web application
draw chart in web application  how to draw bar chat from the record store in database? i.e. draw the bar chart according to selected record
Bar charts and jsp
Bar charts and jsp  Hi, How to generate Dynamic Bar Chart Images using jsp with placing any image location in weebroots? Thanks in advance
java bar charts and jsp
java bar charts and jsp  Hi, Can any one help me out in how to create java bar charts using jsp with the help of data base table values? thanks.../jsp/draw-statistical-chart-jsp.shtml
jfree chart
jfree chart  i need donut chart using jfree
pie chart
pie chart  how to create pie chart using struts2
JFree chart package error
the jcommon jar file and jfree jar file for the bar chart code. but now its giving...JFree chart package error  hi, I had asked u abt the jfree chart package and done what u have said. Its working but its giving me error that some
Pie chart
Pie chart  hi................. In my project i want to create a pie-chart by taking values at run time. As want to display it in pie chart form....   Java Swing PIE Chart
Bar Chart Example using JFreeChart
Bar Chart Example using JFreeChart   ... chart using JFreeChart. Code given below creates a bar chart of scores of two teams...():  This method is used to create bar chart for given values. It 
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
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
Area Chart
the object of the Plot for Bar Chart.     p.setForegroundAlpha(0.4f...=new ChartFrame("Bar Chart",chart); After this we create the object of ChartFrame... Area Chart      
ModuleNotFoundError: No module named 'chart'
ModuleNotFoundError: No module named 'chart'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'chart' How to remove the ModuleNotFoundError: No module named 'chart'
Version of be.ceau>chart dependency
List of Version of be.ceau>chart dependency
Version of com.intersult>chart dependency
List of Version of com.intersult>chart dependency
Clickable chart with Tool Tip
Clickable chart with Tool Tip  Can we generate the charts with tooltip and onclick events using jfreechart in jsps and servlets
ModuleNotFoundError: No module named 'bar'
ModuleNotFoundError: No module named 'bar'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'bar' How to remove the ModuleNotFoundError: No module named 'bar' error
java with jsp and dynamic database retrival for bar charts
java with jsp and dynamic database retrival for bar charts  Hi, I am having a table name tablelogin,it consists of columns userid,logintime,sessionid,ip_address,logout. so,can any one help me out how to get the bar chart
Removing the Title Bar of a JFrame
Removing the Title Bar of a JFrame  How to remove the Title Bar of a JFrame in Swing Application?   Please check the tutorial Removing the Title Bar of a Frame for the source code and example description. Thanks
line chart from database in jsp
line chart from database in jsp  how can i create line chart from database in jsp code
custom navigation bar in iphone
custom navigation bar in iphone  How can i create a custom navigation bar in iPhone application? I wanted to add UIBarButton items as well as Search bar on the UINavigation controller ... please tell me if i need to create
UINavigationController hide navigation bar
UINavigationController hide navigation bar  HI, How to hide the navigation bar of UINavigationController? I have to hide navigation bar... code for hiding UINavigationController's navigation bar
Pie chart on jsp
Pie chart on jsp  how can i create a pie chart on a jsp page using... that creates a pie chart using JFreechart api and takes the value from..."); dataset.executeQuery(query); JFreeChart chart = ChartFactory.createPieChart
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
How to draw pie chart in J2ME
How to draw pie chart in J2ME  Hi, I'm developing a program using J2ME and I want to draw a pie chart but it seems J2ME language hasn't available chart component like JFreeChart in Java! could any one help me how can I draw a pie

Ads