Help creating a simple line graph

Hi
Im very new to the Java language, yet have some background knowledge of C and C++.
i have a problem with an application i am developing for a university assignment, the program is to simply simulate a water pressured nuclear reaction. the main JFrame holds various JLabels that show the current core temperature, electricity produced etc. But i want to add a very simplistic line graph to the same window, it is to purely show a line that updates (no axis or labels). The graph is to illustrate how much electricity was produced on the current cycle of the reactor, the user can initiate each cycle by pressing a JButton.
i have found some info on drawing, but cannot find anything that helps.
Any info on how to do this (its only meant to be a samllish part of the main window), any code examples or sites that have a very relevant tutorial would be appreciated.
Sorry for the length of this, and if anyone needs any more info on this then let me know.
thanks

Cross posted,
http://forum.java.sun.com/thread.jsp?forum=54&thread=394494&tstart=0&trange=15

Similar Messages

  • Help me with a simple line-graph, plzzzzzzzz.

    hi!
    can anyone give me the basic java code to create a simple line graph for my java program output.
    thanks a lot in advance.
    cheers!

    Have a look at the Graphics.drawPolyline() method.
    kind regards,
    Jos

  • Simple line graph problem

    Hi there,
    I want to create a very simple line graph, containing 1 line. Therefore i create a Graph.LINE_VERT_ABS type Graph and add the data using myGraph.setLocalRelationalData(al ArrayList). This arraylist contains values in the form of
    setname jan 12.2
    setname feb 14.5
    setname march 8.1
    etc
    When i do this, I get the errormessage: "The data has an insufficient number of columns. This graph type requires at least 2 columns of data. The data provided has one column.".
    When i add another dummy value to the arraylist:
    dummy dummya 1
    dummy dummyb 2
    the graph displays correctly, but only with a additional line for the dummy values, also in the Legend.
    What am i doing wrong. Surely it is possible to display just one line in the Graph??
    Any help is appreciated.
    Linda

    In the arraylist, setname identifies a column. By default, columns are plotted as groups, or different points along the horizontal axis. In order to have a line or area graph, you need two groups. The data that you are passing has 1 group and 3 series. You should pass it as follows:
    jan setname 12.2
    feb setname 14.5
    march setname 8.1
    etc.
    Passing data like this will give you three groups (jan, feb, march) and one series (setname).
    By the way, what version of BI Beans are you using and how did find out about setLocalRelationalData? That API was never publicly released. It was replaced by setTabularData (same method renamed) and exposed in 9.0.3.
    BI Beans Product Management

  • Help needed in plotting Line Graph!!!!!!!!!Pls help!!

    Hi, i need help in plotting a simple line graph showing the x&y axis and has to plot 3 different lines in the same graph.I have written a program and i need to implement this graph in it.Is there any tutorial for plotting line graphs,i mean steps included.
    Please help!

    You describe your need, but not where it originates from.
    Is it a programming assignment? If so, I hope this is not your chosen major, as you will fail because you are a non-resourceful plagarist.
    Do you need to simply graph some data? Use an existing package. There are free ones somewhere.
    What do you mean "i have written a program and i need to implement this graph in it"? If you wrote the program, wouldn't you be done?
    Enjoy programming

  • Help needed in plotting line graph!

    Hi i need help in plotting a line graph complete with both axes shown,plus the legend on the side shown.
    Pls help!!!!
    rgds

    Here's a simple line graph applet I did some time backimport java.awt.*;
    public class LineGraff extends java.applet.Applet{
       double []toGraff = {6.0, -14.0, -164.0, -210.0, 108.0, 770.0,
                                1354.0, 896.0, -572.0, -1348.0, -780.0, -108.0};
       double []numsFromFile = {6.0, -14.0, -164.0, -210.0, 108.0, 770.0,
                                1354.0, 896.0, -572.0, -1348.0, -780.0, -108.0};
       int max, min, size, Hscale;
       double Vscale;
       public void init(){
          size = numsFromFile.length-1;
          java.util.Arrays.sort(numsFromFile);
          max = (int) numsFromFile[size];
          min = (int) numsFromFile[0];
          Vscale = max-min;
          Vscale = 200/Vscale;
         Hscale = Math.round(300/size);
       public void paint(Graphics g) {
          g.setFont(new Font("Arial",0,14));
          g.drawString("Example app: drawing a graph from a double array",25,18);
          g.setFont(new Font("Arial",0,10));
          g.setColor(Color.blue);
          g.fillRect(10,20,365,230);
          g.setColor(Color.cyan);
          g.drawLine(25,25,25,225);
          g.drawLine(25,140,330,140);
          g.setColor(Color.white);
          int intA = 30, intB = 0, intC = 0;
          int intD = (int) (Math.round(140 - (Vscale * toGraff[0])));
             for(int i=1; i <= size; i++) {
               intC = intA + Hscale;
               intB = intD;
               intD = (int) (Math.round(140 - (Vscale * toGraff[ i ])));
               g.drawLine(intA, intB, intC, intD);
                  if(toGraff[ i ] > 0)
                     g.drawString(Double.toString(toGraff[ i-1 ]), intA+6, intB-3);
                  else
                     g.drawString(Double.toString(toGraff[ i-1 ]), intA+6, intB+8);
               intA += Hscale;
          g.drawString(Double.toString(toGraff[size]), intA+6, intD-3);    
    }

  • Creating a 3 line graph report

    Need help with creating a 3 line graph  - need to be able to plot 3rd line of data  without displaying a legend and use a dynamic tag label for the line. Thanks

    You can create two graphs with the same horizontal (and if necessary vertical) scale, and make them occupy the same space on the report, one under another.
    On one report, put your 3rd graph line, and remove any visible text, gridlines etc, so you basically just have the axes lines and the graph line.
    On the top report, make the background transparent, so both graphs are visible (Chart Expert->Options->Transparent Background).

  • Creating a Double Line Graph

    Hello,
    I'm trying to create a graph from the information seen in the table below. I need to plot on the X- Axis, the T0,T1,T2 values. There will be two data sets for the line graph, Subject A and Subject B, the value from which will be plotted on the Y-Axis. I've spent about an hour now, trying to order the values to create the graph I need.
         Another way of saying this, is that I'm plotting the differences in Subject A versus Subject B over a period of Time (T0, T1, T2).
    It should look something like this:
    Help Please!
    -KB

    Hi KBaines,
    Please don't worry about wasting anyone's time. Many users in this forum look upon Numbers problems as a challenge. If you solved your own problem, please post your solution to help others.
    Regards,
    Ian.

  • Help creating a simple function testing conditions in 2 columns

    I want to create a simple function which tests if a value is found in one of two columns:
    If MyValue is in columnA or ColumnB then True ELSE False
    Any ideas?

    Ok, This is the deal. This has been kicking my butt all day. So here is the exact table names and view names and all the columns involved.
    The table I am inserting into only after I determine that the concatenated string is not there either "forward" or "backwards."
    RPT_DS1_ALOC_ZLOC_REVERSE_VW:
    ALOC VARCHAR2(8)                 Data looks like 'AFD32GD2'
    ZLOC VARCHAR2(8)                 Data looks like 'AFD55GDF'
    MASTER_ROUTE_NAME VARCHAR(17)      Data looks like 'AFD32GD2-AFD55GDF'
    REVERSED       VARCHAR(17)      Data looks like 'AFD55GDF-AFD32GD2'
    This view is built off another table that has only the ALOC and ZLOCsSELECT * FROM RPT_DS1_ALOC_ZLOC_REVERSE_VW WHERE ROWNUM <=5;
    MASTER_ROUTE_NAME     REVERSED          ALOC          ZLOC
    ABDLFLXA-ABDLFLXA     ABDLFLXA-ABDLFLXA     ABDLFLXA     ABDLFLXA
    AGSTGAAU-AGSTGAAU     AGSTGAAU-AGSTGAAU     AGSTGAAU     AGSTGAAU
    AGSTGAFL-AGSTGAFL     AGSTGAFL-AGSTGAFL     AGSTGAFL     AGSTGAFL
    AGSTGAMT-AGSTGAAU     AGSTGAAU-AGSTGAMT     AGSTGAMT     AGSTGAAU
    AGSTGAMT-AGSTGAFL     AGSTGAFL-AGSTGAMT     AGSTGAMT     AGSTGAFL
    RATE_MASTER_ROUTE:
    MASTER_ROUTE_NAME VARCHAR2(17)   Data looks like 'AFD32GDS-AFD55GDF' or 'AFD55GDF-AFD32GDS'
    ALOC VARCHAR2(8)                 Data looks like 'AFD32GD2'
    ZLOC VARCHAR2(8)                 Data looks like 'AFD55GDF'SELECT * FROM RATE_MASTER_ROUTE WHERE ROWNUM <=5;
    MASTER_ROUTE_NAME     ALOC          ZLOC
    ABDLFLXA-ABDLFLXA     ABDLFLXA     ABDLFLXA
    AGSTGAAU-AGSTGAAU     AGSTGAAU     AGSTGAAU
    AGSTGAFL-AGSTGAFL     AGSTGAFL     AGSTGAFL
    AGSTGAMT-AGSTGAAU     AGSTGAMT     AGSTGAAU
    AGSTGAMT-AGSTGAFL     AGSTGAMT     AGSTGAFThe idea is to insert a record into RATE_MASTER_ROUTE ONLY if it is not in there already. So since the view takes care of the reversing, all I am doing is passing in the MASTER_ROUTE_NAME and the REVERSED to see if either of them are in RATE_MASTER_ROUTE. If not, then I am INSERTING both the ALOC and ZLOC and the MASTER_ROUTE_NAME into RATE_MASTER_ROUTE. I appreciate the help so far, but I am still missing something. I have tried a number of variations. I added a dummy record to the first table that I knew was not in the second. I tried selecting it according to a similar query that was made above. But I am not communicating something correctly so this is the detail. I hope somebody can help me over this brain freeze.

  • Need help creating a simple form in Dreamweaver CS3!!

    I'm trying to create a form in Dreamweaver CS3, and while I have the form built I'm confused as to how to make it actually function.  What I'm trying to do is create a form that when the visitor clicks submit, the data is emailed to me.  Can someone help me figure out how to accomplish this?
    Thanks so much!

    Ute's answer is spot on - you need a FormMail script to process the form.  Check with your host (or via the control panel) and see if they supply such a form for free.
    If not, google for "formail script' and you'll find quite a few available - all free to use.
    You just need to add a couple of lines to your html code, change a few things in the formmail script and the form will process.  Sounds complicated but most scripts come with a help file to help you get off the ground.
    Nadia
    Adobe® Community Expert : Dreamweaver
    http://www.perrelink.com.au
    Unique CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    http://csstemplates.com.au/
    http://twitter.com/nadiap

  • Hi, In need of help creating a simple effect to image.

    Attached is an image which shows more or less the effect I am needing to achieve.
    http://i303.photobucket.com/albums/nn149/Jaybeedubya/FotoliaComp_635945_xs3N3VFLwPNTIOm1.j pg
    I created the image above by desaturating the colour image of the man and then adding a new purple layer and selecting 'vivid light' from the layer palette drop down box. In doing this the man became purple but the white area surrounding him stayed white...I then adjusted the layers on the first layer so that the white part became purple - the final result is what you see in the attached image.
    The problem is this - I need to create this effect for 15 or so images all with a specific purple pantone colour, I need to create these for print ready artwork. All the pictures (ie the man) I will be using, need to look the same kind of shade. The way I was creating these before was to adjust the bottom layer so its grey rather than white so that the white area becomes purple.
    Confusing huh, If you dont understand my question (and I dont blame you!) then all I need is to create a set of 15 images that look like the attached image (using a specific pantone) but I have no idea how the best way to do it is.
    How would you guys achieve that? Any help greatly appreciated.

    So its gonna be a two-color-job?
    Because with the extreme depths adding Black at least might be beneficial.
    You could make a Selection of a black&white-version-of-the-photographs luminance, inverse it and, in the Channels-Panels PopUp-menu, choose Add New Spot Channel for the Foreground color and select the Pantone color.
    Then Add New Spot Channel for the background-color and fill that solid black and hide the layers that contain the composite of the photograph.
    This should leave You with blank composite channels and the two Spot Channels visible.
    Indesign can handle either psd- or DCS2-files containing Spot Channels.
    The problem I perceive here is that depending on the print-process and the background color selected it might proof necessary to knock out the foreground elements if the company is very strict on their CI colors. Unfortunately simply inversing the foreground selection would probably not work as this might leave the mixed-color-areas greyish.
    Are the prints gonna be offset or silkscreen?

  • Help creating a simple browser

    I've created an e-commerce application using servlets, now I'm trying to build a simple browser to view these servlets. I've made a very simple one that works for the most part, except when comes to buttons (submit type inputs) within the html, like the one below:
    out.println("<TD><FORM ACTION=\"" +Orders+ "\">\n" +
    "<INPUT TYPE=\"HIDDEN\" NAME=\"ItemId\"VALUE=\"" +temp.getItemId( + "\">\n" +
    "<P>\n<CENTER>\n" +
    "<INPUT TYPE=\"SUBMIT\" NAME=\"Operation\"VALUE=\"Delete\">\n" +
    "</CENTER>\n<P>\n</FORM></TD></TR>");clicking on the button simply does nothing, what do I have to do to make the browser use these buttons correctly. Here's the code for my browser so far:
    package project;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Browser extends JFrame
         public JEditorPane viewer;
         public JButton browse, search, view, checkout;
         public Browser()
         {     //create the components that make up the browser
              super("Project Browser");
              browse = new JButton("Browse stock");
              search = new JButton("Search");
              view = new JButton("View basket");
              checkout = new JButton("Proceed to checkout");
              JToolBar bar = new JToolBar();
              bar.add(browse);
              bar.add(search);
              bar.add(view);
              bar.add(checkout);
              viewer = new JEditorPane();
              viewer.setEditable(false);
              //get a container and place the components on it
              Container c = getContentPane();
              c.setLayout(new BorderLayout());
              c.add(bar, BorderLayout.NORTH);
              c.add(new JScrollPane(viewer), BorderLayout.CENTER);
              viewer.addHyperlinkListener(new LinkListener(  ));
              setSize(800, 600);
              setVisible(true);
              String s = "http://localhost:8080/tomcat-docs/Selector.html";
             open(s);
           public void open(String url)
             try     {
                    URL page = new URL(url);
                    viewer.setPage(page);
             catch (Exception e) {
                    System.out.println("Couldn't open " +url+ ":" + e);
           class LinkListener implements HyperlinkListener
           {     public void hyperlinkUpdate(HyperlinkEvent he)
                {     HyperlinkEvent.EventType type = he.getEventType(  );
                    if (type == HyperlinkEvent.EventType.ENTERED)
                      viewer.setCursor(
                     Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                    else if (type == HyperlinkEvent.EventType.EXITED)
                      viewer.setCursor(Cursor.getDefaultCursor(  ));
                    else if (type == HyperlinkEvent.EventType.ACTIVATED)
                      open(he.getURL().toExternalForm(  ));
         public static void main(String[] args)
             new Browser();
    }

    Nothings wrong with them, its just part of a project. Just to clarify, I don't mean the buttons on the JToolBar, I know they do nothing. I mean buttons/forms within the html that the browser displays. It handles hyperlinks ok, but submit type forms don't seem to work.

  • Creating a Line Graph in a JSP...

    ive got to create a simple line graph (ability to have a title, xaxis, yaxis labels, plus label the data on hte x and y axis). right now the yaxis date is stored in an array of doubles and the xaxis just increment by 1. im having problems finding such a thing on the internet that doesnt depend on other classes or beans besides teh ones built into the jdk. i can have no other 3rd party software, is there anything like this out there? any java functions? thanks.
    Adam.

    Hi
    Keep in touch with the following thread, which is going in parallel, which is same as yours.
    http://forums.java.sun.com/thread.jsp?forum=45&thread=286179
    Thanks
    Swaraj

  • Create a line graph on EP 7.0

    We are trying to create a complex line graph in the portal which will pull data from SAP ISU. What is the best approach to developing this graph? Is SAP Chart Design suitable for creating a complex graph from scratch?
    Any help would be appreciate.

    U can open any one of this as per ur like and edit.
    Well, you cannot edit the standard delivered themes. You will need to make a copy of the standard one and edit that custom copy.
    Besides the theme editor in the portal, there is a tool called Eclipse theme editor which can come in handy to create/modify a theme. You can download this tool and the corresponding guide at the following location:
    http://www.sdn.sap.com/irj/scn/downloads?rid=/library/uuid/136dd890-0201-0010-1b9d-bd09a0d3b1d8
    Thanks,
    Shanti

  • Numbers Line Graph is more annoying than Miley Cyrus

    Hello and thanks for taking time to read and answer my question.  So I have a science fair project coming up and numbers is being very annoying.  My experiment is testing the affect of temperature on the effectiveness of magnets.  My table looks like this: 
    Magnet 1
    Magnet 2
    Magnet 3
    Magnet 4
    Magnet 5
    Average
    74 Degrees
    40g
    42g
    50g
    27g
    38g
    39.4
    200 Degrees
    28g
    25g
    35g
    46g
    38g
    34.4
    250 Degrees
    62g
    39g
    10g
    53g
    29g
    38.6
    300 Degrees
    34g
    19g
    36g
    23g
    41g
    30.6
    350 Degrees
    26g
    21g
    17g
    36g
    37g
    27.4
    All I want to do is make a simple line graph that will show the correlation (or lack of one) However, when I try to make it into a graph, I keep either getting no lines at all or only the line for the average.  Why is this?  What am I doing wrong?  Help is greatly appreciated.
    Thanks so much,
    Colton
    I'm using numbers 3.1 by the way.

    Hi Colton,
    "I keep either getting no lines at all or only the line for the average.  Why is this? "
    It's because the column labeled Average is the only one containing numbers. Appending the g or " Degrees" forces Numbers to regard the values in the other columns as Text, which has no numerical value, and can't be graphed.
    With the text stripped from those numerical values you can produce either of these two graphs. See the notes below regrding the major differences.
    Scatter chart with connected points
    Line chart
    Cosmetically, the line graph appears with thicker lines connecting the data points, and with all symbols set to open circles. I thickened the connecting lines on the scatter chart to make them more visible, and made the Average line about 40% thicker than the others. No changes were made to the lines on the line chart.
    The legend for both (Magnet 1, Magnet 2, etc.) appears as a horizontal line (or lines) of text. Selecting the box, then dragging either handle toward the other forces the labels into a vertical stack, which can then be moved to a visually better position.
    The main functional difference between the two types is in the purpose of the X axis.
    In the scatter chart, both X and Y axes are Value axes—the position of each data point is determined vertically by its Y value and horizontally by its X value.
    The Line chart is a Category chart. Category charts have one Value axis (here the Y axis) and one Category axis (here the X axis). Categories are equally spaced along the Category axis, and the data points' vertical position(in this example) is determined by the Y value of the point.
    In your case, the difference can be seen in the (horizontal) distance between the first two samples in each series compared to the (horizontal) distance between other ajacent pairs in the same series. In the Line chart, these distances are all the same. In the Scatter chart the first pair (74° and 200°) are more widely separated than the others (each 50° higher than the temperature before it).
    In cases where you are trying to show a relationship (or lack of relationship) between two sets of values (speed vs braking distance, temperature vs volume, etc.) a scatter chart usually gives a better representation.
    Practical note: Values must be placed in non-Header rows and columns. Labels, including Category labels, must be placed in Header Rows or Header columns to be picked up by the chart. The formatting of the pasted data in your initial post indicates the temperatures are in a Header column. The column labels are (and should be) in a Header row.
    Good luck with your project!
    Regards,
    Barry
    PS: You might want to check the meanings of "affect" and "effect" before commiting yourself to either on your display and in your report.
    PPS to Yellowbox: HI Ian. Looks like you got started earlier and/or wrote faster thn I did! Something odd happened in the example in your first post. The category labels have been offset one cata set to the right, and there's no 350.
    B

  • Engage 2008: Line Graph, can't start 2nd series @ different X value

    Using Xcelsius Engage 2008
    Created line chart w/ 2 series
    2nd series does not start at the same X value as series 1.
    How do I generate the second series so the initial part of my 2nd series line does not show all 0s?
    Thank you
    Nancy Griffin

    Hi Tammy.
    I'm using Xcelsius version: 5.0.0.99 and Build number 12,0,0,121.   I am not sure if S1 is already installed.  If not, where can I get it?
    This is what I'm trying to do:
    1) created a basic line graph with two series
    Series 1 Data has 2 columns
    Series 1 Column 1 includes dates. THis will be the labels for the X axis:
    1/1/07
    1/6/07
    1/12/07
    1/1/08
    1/6/08
    Column 2 includes the line graph data for series 1
    30
    50
    10
    90
    120, etc
    Series 2 column 1 - THis is the same as series 1 since it includes the same labels for the X axis
    Series 2 column 2  includes the data for the 2nd line graph
    HERE's WHERE IT IS DIFFERENT
    I have no data for dates 1/1, 1/6,  1/12/07.   My data starts in
    2008. I don't want the graph to show 0s for the first 3 dates and then jump up to the 2008 data.   Is there a way to make the 2nd line chart start on 1/1/08?
    thank you. Really appreciate your help.

Maybe you are looking for

  • Problems using a variable with a tag of a webapp

    I have a webapp where I've built a field in the database for the item is active or not, depending if my client chooses if it's free or not. The name of the tag that I want to use as a variable is { tag_estado } and has two values: Gratis Pago When in

  • Consolidating songs into one album using iTunes 12

    In earlier versions of iTunes I was able to dump songs into one album, but with the new iTunes 12.0.1.26 I cannot seem to get the songs into one album.  Anyone have any ideas. Thanks for your time.

  • Exit Transaction F-28

    Hello Forum, Wanted to know if some of you has used some user-exit for the F-28 transaction, or if they have the extension in where they are exit for this transaction.   Thank you very much to all. Maria

  • What exactly does the folder "Album Artwork" contain/do?

    In the iTunes Library folder is a sub-folder called "Album Artwork". I am wondering what this folder is actually for? Does it save the actual artwork? It only contains itc files, so how would this work? If this is true, why are artworks not embedded

  • I need to upgrade higer than Mac OS X 10.5.8.

    Does anyone know how? I just got the iphone 5 and I cant use the cloud and sync my stuff because the version of mac os x I have is too old. Help!