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.");
             }
        }
}









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 in JSP - JSP-Servlet
Bar Chart in JSP  Hi I am creating Bar chart using Jfree charts in JSP. Please advise me how to customize it. Like controlling the colors, width for each bar, showing values above the bar .  hi friend, Use
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
JFree 3D Bar Chart not displaying in JSP - Java3D
JFree 3D Bar Chart not displaying in JSP  Hi I am trying to run JFree 3D bar chart written in your site under link: http://www.roseindia.net/chartgraphs/3Dbarchart-in-jsppage.shtml This is not working. PNG file
JFreechart Stacked Bar Chart
JFreechart Stacked Bar Chart JFreechart provides a way to create various... Bar Chart. This chart actually displays the result of multiple queries stacks... = ChartFactory.createStackedBarChart( "Stacked Bar Chart", "Games
create bar chart in jsp using msaccess database
create bar chart in jsp using msaccess database  thanks for reply...,true, true, false); ChartFrame frame1=new ChartFrame("Bar Chart",chart...;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...\work\Catalina\localhost\chetana\org\apache\jsp\bar_jsp.java:57: cannot find symbol
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
Create Bar Chart with database values
Create Bar Chart with database values In this section, you will learn how to create a bar chart by retrieving the values from the database. For this purpose... createBarChart3D() of the class ChartFactory creates a vertical 3D bar chart. Now
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...(): This method is used to create stacked bar chart for given values. It takes
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
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
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...\Tomcat 5.0\work\Catalina\localhost\chetana\org\apache\jsp\bar_jsp.java:61: cannot
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
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
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... createBarChart3D() creates a vertical 3D bar chart. The class PlotOrientation is used.../jsp/bar.jsp to the address bar and hit enter. The image of chart is displayed
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
PHP GD random bar chart on image
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
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
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
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 
Chart & Graphs Tutorials in Java
.    Bar Chart Example In this section we are providing you an example to create a Bar Chart.   3D Bar Chart Example In this section we are providing you an example to create a 3D Bar Chart.  
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
();  Above method is used to get the object of the Plot for Bar Chart.  ... chart.   ChartFrame frame1=new ChartFrame("Bar Chart",chart); After this we... 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'
display combination of a stacked area chart and line chart in one iframe using jfree - JSP-Servlet
display combination of a stacked area chart and line chart in one iframe using jfree  hello i have a problem related to jfree chart, i want to display combination of a stacked area chart and line chart in one iframe
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
chart tutorial - Java3D
chart tutorial  Hi I need a JFree Chart class library in order to design a chart with java  Hi friend, For JFree Chart class library... information,Tutorials and Examples on JFree Chart visit to : http://www.roseindia.net
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
surface chart - Java3D
surface chart  i have to make a surface chart of a piece of land with data given for each point in the xy plane....the chart should be such that the areas with different data range should show up in different colour. seriously

Ads