How to Draw a line Graph using x,y Cordinates in Java ?

Hi,
what r the easiest way to draw a line Graph using Java Code either applet.
can u give me code sample. or any package where we can pass some parameter so that accoring to the paramter as i know jfreeChart.function() like some method is there from toold jChart.
Is it possible.
Regards,
Prabhat

There's a number of sample applications in one of the packages of freechart, one of which should do the trick.
If you're doing applets I suggest you look at genjar from the sourceforge site. What that does is bundle classes from a set of library jars into one jar, selecting only classes that are referenced. That should simplify the transfer problem.
To draw graphs, typically, you create a DefaultXYDataset object, add data points and then use the appropriate ChartFactory.createXXX methods to build a chart object. Then you wrap that in a ChartPanel to display.

Similar Messages

  • How to draw multiple line graph using bi graph in  JHeastart?

    hello,
    i have a problem when displaying a multiple graph in JHeadstart.i had created a graph that represent the report of medical testing.my x-axis is "report date",my y-axis is "observation value" then my series attributes is depend on "item description" .
    One patient has many "item description",each "item description" has one "observation value" and each "item description" has many "report date".
    when the graph was displayed,it only show me in 1 line,then it is depend on the id patient but not like what i set in the graph wizard.actually,it should be display fews line accroding to the "item description".
    then,the "observation value" and "item description" are get from defferent entity object.
    i dun know what was happen.any hits are welcome.
    thanks

    yes,finally i found how to draw it.Actually the series attributes is depend on VO's primary key .
    thanks to who was view my problem.

  • How to Draw a line graph showing memmory usage like TaskManager in W2K2

    Hi
    Anybody help me how to draw a realtime graph using java which shows the memmory usage just like the windows 2000 server task manager.
    I tried jconsole but too big to accomodate in my gui.
    thanks
    jossy v jose

    http://www.jfree.org/jfreechart/index.php

  • How to draw cumulative line graph over the stacked bar chart?(SSRS)

    Hello, 
    I need your help to draw a cumulative line graph over this bar chart. 
    I need your help to draw a cumulative line graph over this bar chart in SSRS.
    The dimension (Category Group) is "Hour" in this case. and expression is sum of two distinct values like 'Y' and 'N' in Activity column(Series Groups). The sum(Activity=Y) in green color and sum(Activity='N') in Red color.
    I require to draw a cumulative line graph in this same chart, that should give the result of cumulative Sum(Activity) for each hour?? I mean sum of (Y+N) for each hour and that should be cumulative over the hour.
    I mean sum of (Y+N) for each hour and that should be cumulative over the hour.
    SSRS Version details:
    Microsoft SQL Server Reporting Services Designers 
    Version 10.50.1600.1
    --Siva

    Hi Siva,
    It seems that you need to verify your email address to post images, etc
    Besides,  Microsoft® SQL Server™ 2008 Reporting Services: Step by Step is a good choice to you. With STEP BY STEP, you work at your own pace through hands-on, learn-by-doing exercises. A companion CD includes data sets and sample code. You can download
    it from this link http://my.safaribooksonline.com/9780735626041 Click the Extras, you can get the samples and database from Supplemental Content.
    And there are vast of valuable articles and SQL Server Reporting Services Books Online in MSDN ,you can click these link to begin your learning journey, SQL Server Reporting Services 2008 Books Online:
    http://msdn.microsoft.com/en-us/library/ms159106(v=SQL.100).aspx 
    Besides these, there are still many valuable videos in Microsoft Webcast, click this link
    https://msevents.microsoft.com/cui/SearchDisplay.aspx?culture=en-US#culture=en-US;eventType=0;sortKey=;sortOrder=;pageEvent=false;hdnInitialCount=;searchcontrol=yes;kwdAny=Reporting%20service to register with a windows live ID, then download the ones you
    want.
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to draw a line using JSP?

    Does anyone know how to draw a line using a JSP? Any help is much appreciated.
    Regards,
    Navin Pathuru.

    Graphics classes are useless in JSP files; you can only output HTML tags to the client browser.
    You should be able to give just about any presentation look that you need with HTML and CSS. Have you played with styles? Here's a simple example that works in IE 5+ and Netscape 4.7:
    <HTML>
    <HEAD>
    <STYLE>
    .box {
    border-style:solid;
    border-color:black;
    border-right-width: 1px;
    border-top-width: 1px;
    border-left-width: 1px;
    border-bottom-width: 1px;
    .line {
    border-right-width: 1px;
    border-top-width: 0px;
    border-left-width: 0px;
    border-bottom-width: 0px;
    border-style: solid;
    border-color: red;
    width:1pt;
    height:100%;
    </STYLE>
    </HEAD>
    <BODY>
    <TABLE CELLPADDING=1 CELLSPACING=0 WIDTH=100>
    <TR><TD ALIGN=CENTER><SPAN CLASS="box">Field One</SPAN></TD></TR>
    <TR HEIGHT=50><TD ALIGN=CENTER><SPAN CLASS="line">�</SPAN></TD></TR>
    <TR><TD ALIGN=CENTER><SPAN CLASS="box">Field Two</SPAN></TD></TR>
    <TR HEIGHT=50><TD ALIGN=CENTER WIDTH=50%><SPAN CLASS="line">�</SPAN></TD></TR>
    <TR><TD ALIGN=CENTER><SPAN CLASS="box">Field Three</SPAN></TD></TR>
    </TABLE>
    </BODY>
    </HTML>
    Have fun!

  • How to draw a line(shortest distance)  between two ellipse using SWING

    how to draw a line(should be shortest distance) between two ellipse using SWING
    any help will be appreciated
    regards

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class ELine extends JPanel {
        Ellipse2D.Double red = new Ellipse2D.Double(150,110,75,165);
        Ellipse2D.Double blue = new Ellipse2D.Double(150,50,100,50);
        Line2D.Double line = new Line2D.Double();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.green.darker());
            g2.draw(line);
            g2.setPaint(Color.blue);
            g2.draw(blue);
            g2.setPaint(Color.red);
            g2.draw(red);
        private void connect() {
            double flatness = 0.01;
            PathIterator pit = blue.getPathIterator(null, flatness);
            double[] coords = new double[2];
            double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
            double min = Double.MAX_VALUE;
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                    case PathIterator.SEG_LINETO:
                        Point2D.Double p = getClosestPoint(coords[0], coords[1]);
                        double dist = p.distance(coords[0], coords[1]);
                        if(dist < min) {
                            min = dist;
                            x1 = coords[0];
                            y1 = coords[1];
                            x2 = p.x;
                            y2 = p.y;
                        break;
                    case PathIterator.SEG_CLOSE:
                        break;
                    default:
                        System.out.println("blue type: " + type);
                pit.next();
            line.setLine(x1, y1, x2, y2);
        private Point2D.Double getClosestPoint(double x, double y) {
            double flatness = 0.01;
            PathIterator pit = red.getPathIterator(null, flatness);
            double[] coords = new double[2];
            Point2D.Double p = new Point2D.Double();
            double min = Double.MAX_VALUE;
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                    case PathIterator.SEG_LINETO:
                        double dist = Point2D.distance(x, y, coords[0], coords[1]);
                        if(dist < min) {
                            min = dist;
                            p.setLocation(coords[0], coords[1]);
                        break;
                    case PathIterator.SEG_CLOSE:
                        break;
                    default:
                        System.out.println("red type: " + type);
                pit.next();
            return p;
        public static void main(String[] args) {
            final ELine test = new ELine();
            test.addMouseListener(test.mia);
            test.addMouseMotionListener(test.mia);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    Graphics g = test.getGraphics();
                    g.drawString("drag me", 175, 80);
                    g.dispose();
        private MouseInputAdapter mia = new MouseInputAdapter() {
            Point2D.Double offset = new Point2D.Double();
            boolean dragging = false;
            public void mousePressed(MouseEvent e) {
                Point p = e.getPoint();
                if(blue.contains(p)) {
                    offset.x = p.x - blue.x;
                    offset.y = p.y - blue.y;
                    dragging = true;
            public void mouseReleased(MouseEvent e) {
                dragging = false;
            public void mouseDragged(MouseEvent e) {
                if(dragging) {
                    double x = e.getX() - offset.x;
                    double y = e.getY() - offset.y;
                    blue.setFrame(x, y, blue.width, blue.height);
                    connect();
                    repaint();
    }

  • How to draw horizontal line in smartform after end of the all line items

    Hi Friends,
    I am working on the smartform. I have created TABLE node in Main window.
    i want to draw a horizontal line after end of the main window table node. i mean after printing all the line items of the table, I need to print one horizontal line.
    Could you please help me how to resolve this issue.
    FYI: I tried with the below two options. But no use.
    1. desinged footer area in the table node of the main window.
    2. tried with uline and system symbols.
    please correct me if i am wrong. please explain in detail how to draw horizontal line after end of the main window table.
    this is very urgent.
    Thanks in advance
    Regards
    Raghu

    Hello Valter Oliveira,
    Thanks for your answer. But I need some more detail about blank line text. i.e thrid point.
    Could you please tell me how to insert blank line text.
    1 - in your table, create a line type with only one column, with the same width of the table
    2 - in table painter, create a line under the line type
    3 - insert a blank line text in the footer section with the line type you have created.

  • Line graph using draw2d

    Hi,
    Could anyone plz provide me with an application to draw line graph using draw2d?or maybe useful links if such a code is freely available..thnx in advance

    Here is a rough example
    http://forum.java.sun.com/thread.jsp?forum=20&thread=543227
    Bamkin

  • How to draw a line???

    I am a long time Photoshop user, but new to "Elements". I cannot figure out how to draw a line??? The Help says "To draw a line or arrow...... 1. In the Editor, select the Line tool." Ummm.....WHERE??? HOW??? If I knew how to select the Line tool I wouldn't have gone to the Help file.
    Where is the "Editor"?? All I see at the top in the "Rectangular Marquee Tool" and the "Elliptical Marquee Tool" .....I see no Line tool on the left (where it used to be in PhotoShop) or on the top.
    Jeff

    Jeff,
    I use PEv.3. The line tool is accessed via the shape selection tool.
    Click U. Hold the shift key as you drag and you will have a straight line.
    Editor refers to the component of Elements utilized for enhancement and manipulation. Organizer in the Win version deals with storage and structured organization, as well as special projects.
    Ken

  • How to draw a line on chart

    Hi all,
    I am working on a chart in Design studio on BI platform. The following screen
    shot will depict the current state of my chart-
    Now
    I need to draw lines of different lengths and colors with certain distance from
    X-axis, as shown below. (I drew those lines on a screen shot of my chart with
    the help of MS paint
    but
    I need to do this with the help of design studio) . Basically I need help to
    get the following output in design studio. So, question is HOW TO DRAW A LINE
    IN DESIGN STUDIO?
    Kindly,
    help with this.
    Please suggest me to get the output.
    Thanks and Regards.
    Rakesh.

    Hi Tammy,
    Thanks for ur reply.
    I'm using DS 1.3. and no need of dynamic changes of line on chart.
    I just now gone through with CSS, but i didnt get the solution. i think somewhere im getting stuck with CSS.
    Can u please suggest me the step by step procedure to draw a line using CSS.
    Kindly help on this.
    Thanks and Regards,
    Rakesh

  • How to draw horizontal line at the end of table for multiple line items

    Dear Experts,
                       Pls can anyone help me how to draw horizontal line at the end of table for multiple line items . kindly help me regarding this
    Thanks
    Ramesh Manoharan

    Hi
       I tried as per your logic but it is not solving my problem .  when i am gone to table painter it is showing line type 1 and line type 2
      is below format.. if u see here line type 1 bottom line and line type 2 top line both are same..  so how to avoid this ?
                              line type 1
                             line type 2

  • How to add new line item using BAPI BAPI_CONTRACT_CHANGE for contract-ME32K

    HI Experts,
    how to add new line item using BAPI: BAPI_CONTRACT_CHANGE for existing contract.
    Requirement:
    Already the contract having two line items using ME31K.
    Custom program has to add new line items in existing contract.
    Thanks,
    Sendil

    I got the solution:
    We can do like this:
    1. Get all details using details, BAPI_CONTRACT_GETDETAIL.
    2. After getting results, append new line item. Then use your BAPI.
    Check this posting program.. where this bapi is used, use the same coding technique.
    IDOC_INPUT_PURCONTRACT_CHANGE

  • How to draw a line of sin x and its area under the line?

    Hi,
    I know how to draw a line from two points. However, I do not know how to draw a line of function sin(x) and its area under the line. Anyone know where to read or how can I draw it, please help me. Thanks !!
    Calvin

    use Graphics2D:: draw(Shape)
    create a class that implements Shape, and specifically the getPathIterator methods, in these methods you should return a path iterator that follows the sin/cos curve.
    All fairly simple to do.
    rob,

  • How to draw multiple lines on same panel??

    hiya
    i would like to know how can I draw multiple lines on the same panel ?? I have already use repaint(); but it just come out the lastest line (say line 3) i draw .......those previous lines(say line 1 and 2) are disappear ........
    Thanks for your help mate

    http://www.java2s.com/ExampleCode/2D-Graphics/Line.htm

  • How to draw vertical lines in SMART FORMS

    Hi Guys,
    Can anyone please let me know how to draw vertical and horizontal lines in smart forms, i have to do this in the secondary window.
    thanks,
    Ramesh

    Hi Ramesh,
    In the window output options you have option of check box to get lines.
    Then you need to give the spacing for vertical and horizontal.
    Another option is putting a template on window and getting the boxes, but it is quite little bit complex.
    Put the cursor on the WINDOW in which the lines you want.
    Right click on it>create>complex section.
    In that select the TEMPLATE radio button.
    Goto TAB TEMPLATE.
    Name: give some name of line.
    From: From coloumn.
    To: To coloumn
    Height: specify the height of the line.
    Next give the coloumn widths.
    Like this you can draw the vertical and horzontal lines.
    If the above option doesnot workout then u can try the below option also
    any how you can draw vertical and horizontal lines using Template and Table.
    for Template First define the Line and divide that into coloumns and goto select patterns and select the required pattern to get the vertical and horizontal lines.
    For table, you have to divide the total width of the table into required no.of columns and assign the select pattern to get the vertical and horizontal lines.
    if this helps, reward with points.
    Regards,
    Naveen

Maybe you are looking for