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

Similar Messages

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

  • Help please, I need a line graph from a chart with existing data.

    I am trying to put together a form for tracking my weaight loss. I have decided on a format that I like, but I can't figure out how to create a line graph to represent the chart that collects the data. The graph will need to begin with the "start weight" and track all chages throught the 42 cells until the final "net loss."
    Does anyone know how to set this up as a line graph? Your help would be much appreciated, thank you in advance.

    Skipping ahead and assuming I picked the correct direction then i have a possible solution:
    You need to get the weight loss numbers into a single column. If the table of 42 cells is called Table 1 and the table with the start weight is Table 2 and we call our new table Table 5:
    Cell B2 of Table 5 = Table 2::A2
    Cell B3 of Table 5 =B2+OFFSET(Table 1 :: $B$2,MOD(ROW()-3,7),QUOTIENT(ROW()-3,7))
    Fill down with that formula

  • Need help please with a recent line repair

    to cut a very long story i lost my phone line completely 8 days ago i reported it to my ISP and after 5 days i got it back... now they had to replace the cable running from the telegraph pole to my house for some reason thats where the fault was i thought great well done... couldnt wait to get home and get back on the net .... but to my horror it was so slow taking about 1-2 mins for a page to open and its still pritty poor now takes about 30 secs to 1 minute for a web page to open...been intouch with my ISP im having no joy telling me its all fine nothing wrong i done tests and this and that with them and they seem happy with my connection and speed ...but im telling them that before the repair i was getting between 2.8 and 3.2 MB now im lucky to be getting 1 MB ...one guy even said he couldnt understand why im not happy with the service ...now there telling my its my profile through the line has been changed and ill have to wait for 10 days and checking and testing and doing things over and over again and segesting its my computer and set up ect ...
    i have been at this for a week now what can i do ??? please someone help is it the new line or is it my ISP ??
    but i keep telling them it was all fine before and theres nothing wrong with my set up or my computer because the lap top is the same with the Ethernet cable plugged in so they both cant be the problem ..i have had them both checked at a cost of £65 with a computer tech guy at the shop he said they are clean and healthy systems ! 

    Hi Tony,
    There is a peice of equipment within the exchange which 'optimises' the speed of the broadband based on what the line is capable of. When you have had the recent fault on the line it is likely this equipment picked up the fact that the line wasnt capable of the speeds you were getting and has 'restricted' the speed to give you a stable connection.
    The equipment is there to try and offer you a stable connection for your Broadband (better to have a slowwer speed all the time than a super fast speed for 5 minutes of the day).
    Unfortunalty this can be 'confused' when you have a fault on the line and reduce your speed to compensate for the bad line. It should automatically 'optomise' the speed over a 10 day period and the problem should sort it self out.
    You can request your ISP to check this and make sure your line is set up corrcetly after the recent fault, but to be honest it can easier to wait the 10 days (as it is likely the people you speak to are not fully aware of this part of the line/Broadband or willing to help)
    It is also possible that the repair has had a negative affect on what the line can suppport (this can happen but unlikely to decrease your speed by something which you would notice) and the only soultion for this is to speak to your isp (if they are happy with the speed you are now getting you might not have much luck).
    It sounds like your ISP aren'y very helpful and have 'fobbed you off' for the ten days with out just telling you why, if it was me at this point I would consider an alternative ISP.
    Hope that atleast explains why they told you to wait ten days. :-)

  • Help me with a simple CMR - please!!

    Hi!
    Please Im pretty new to CMR and appreciate if you could help me answer a simple question.
    Database model:
    WriterTbl
    ID___ Name
    1____RodJohnson
    2____PankajKumar
    BookTbl
    FK___Name
    1____J2EE-DesignAndDevelopment
    1____ProfessionalJSP
    2____J2EESecurity
    Question:
    I ve two CMP entities: WriterBean and BookBean
    I ve set the relations between Writer and Books, and it works as far as a writer only has one book.
    That because I set the FK also as a PK to the BookBean. And when I try to create next book for a writer it fails with duplicate-exception, logicaly.
    Can I solve this without any need of specifing a primary key for books at all?
    How is CMP handling no-pk entity and is relations working without any pk?
    Do EJB vendors manage no pk ejbs? what about ejb restrictions.
    I ve read that there must be a primary key, but not necessery a database field - HOW? could you please explain!
    Please this is very urgent and I Thank you very much!!

    Hi!
    Please Im pretty new to CMR and appreciate if you
    could help me answer a simple question.
    Database model:
    WriterTbl
    ID___ Name
    1____RodJohnson
    2____PankajKumar
    BookTbl
    FK___Name
    1____J2EE-DesignAndDevelopment
    1____ProfessionalJSP
    2____J2EESecurity
    Question:
    I ve two CMP entities: WriterBean and BookBean
    I ve set the relations between Writer and Books, and
    it works as far as a writer only has one book.
    That because I set the FK also as a PK to the
    BookBean. And when I try to create next book for a
    writer it fails with duplicate-exception, logicaly.
    Can I solve this without any need of specifing a
    primary key for books at all?I dont see how. In your AS you would have had to specify either a primary key or primary class or unknown Object as primary key.
    How is CMP handling no-pk entity and is relations
    working without any pk?Using s1as l have found out that l if you do not specify a primary key on creation of entity bean, the ejbCreate returns null as the primary key which causes an EJBException.
    Why? Cos I think a primary key has to be returned at the same time as the handle to the entity bean is stored in the Context. Why it would not insert the data first then request a primary key l dont know. I must say that this happens when you try to use autoincrement in the primary key column.
    Do EJB vendors manage no pk ejbs? what about ejb
    restrictions.
    Reading the specification literature gives the impression that they do, but practice is another thing entirely.
    I ve read that there must be a primary key, but not
    necessery a database field - HOW? could you please
    explain!
    That the theory. When you find the answer to HOW(?), please let us know.
    Derrick
    Please this is very urgent and I Thank you very much!!

  • Help me with JWSDP simple sample

    I've tried the "simple" sample in JWSDP, and I'm sure I have finished
    the needed setup like what was expressed in JavaWSTutorial.pdf.
    But I meet this error message:
    after input "asant run-sample" , it finally displayed:
    deploy-sjsas:
    [echo] Deploying war for simple to sjsas
    [appserv-deploy] Attribute password is deprecated. Please use passwordfile inst
    ead.
    [appserv-deploy] Attribute sunonehome is deprecated. Please use asinstalldir in
    stead.
    [appserv-deploy] Executing: deploy user admin password 62285432 --force=tru
    e enabled=true name securesimple verify=false precompilejsp=false --uplo
    ad=true "C:\tool\jwsdp-1.6\xws-security\samples\simple\dist\securesimple.war"
    [appserv-deploy] WARNING: The --password option is insecure and should not be us
    ed since it can compromise your password. Please use either the command prompt
    or the --passwordfile option.
    [appserv-deploy] 2005-7-30 0:09:20 com.sun.appserv.management.client.ProxyFactor
    y getInstance
    [appserv-deploy] ����: ProxyFactory.getInstance: Failure trying to create a new
    ProxyFactory: java.io.IOException: Invalid user or password
    BUILD FAILED
    C:\tool\jwsdp-1.6\xws-security\samples\simple\build.xml:179: An exception occurr
    ed while running the command. The exception message is: CLI171 Command deploy f
    ailed : Deployment of application failed - java.io.IOException: Invalid user or
    password; requested operation cannot be completed.
    What should I do on earth ???? Help me please
    (sorry for my bad English)

    Hi!
    Please Im pretty new to CMR and appreciate if you
    could help me answer a simple question.
    Database model:
    WriterTbl
    ID___ Name
    1____RodJohnson
    2____PankajKumar
    BookTbl
    FK___Name
    1____J2EE-DesignAndDevelopment
    1____ProfessionalJSP
    2____J2EESecurity
    Question:
    I ve two CMP entities: WriterBean and BookBean
    I ve set the relations between Writer and Books, and
    it works as far as a writer only has one book.
    That because I set the FK also as a PK to the
    BookBean. And when I try to create next book for a
    writer it fails with duplicate-exception, logicaly.
    Can I solve this without any need of specifing a
    primary key for books at all?I dont see how. In your AS you would have had to specify either a primary key or primary class or unknown Object as primary key.
    How is CMP handling no-pk entity and is relations
    working without any pk?Using s1as l have found out that l if you do not specify a primary key on creation of entity bean, the ejbCreate returns null as the primary key which causes an EJBException.
    Why? Cos I think a primary key has to be returned at the same time as the handle to the entity bean is stored in the Context. Why it would not insert the data first then request a primary key l dont know. I must say that this happens when you try to use autoincrement in the primary key column.
    Do EJB vendors manage no pk ejbs? what about ejb
    restrictions.
    Reading the specification literature gives the impression that they do, but practice is another thing entirely.
    I ve read that there must be a primary key, but not
    necessery a database field - HOW? could you please
    explain!
    That the theory. When you find the answer to HOW(?), please let us know.
    Derrick
    Please this is very urgent and I Thank you very much!!

  • Help needed with a simple CompareTo sorting method

    This code is supposed to sort through a list of random numbers, dates, and strings to find the largest. The problem is that with the strings it just sets the first string in the array to the largest, and I'm really not sure why it's doing it...Any help would be appreciated. I am aware that this is a very simple problem..No need to tell me. ^_^;
    import java.util.Date;
    public class CompareToSort {
      public static void main(String[] args) {
    String[] strings = {"CS", "Math", "Biol", "Chem", "Phys", "Buss", "Law", "Educ", "Elec Engr", "Mech Engr"} ;
    Integer[] list = new Integer[10] ;
    Date[] dates = new Date[10] ;
    for (int i = 0; i < list.length; i++)
          list[i] = new Integer((int)(Math.random() * 100));
    for (int i = 0; i < list.length; i++)
          dates[i] = new Date();
    System.out.println("Max string is " + max(strings));
    System.out.println("Max integer is " + max(list));
    System.out.println("Max date is " + max(dates));
    public static Object max (Object[] a)
      Object currentMax = null;
      int currentMaxIndex;
      for(int i = a.length - 1; i>=0; i--)
         currentMax = a;
    currentMaxIndex = i;
    for (int j = i - 1; j >=0; j--)
    if (((Comparable)currentMax).compareTo(a[j]) < 0)
    currentMax = a[j];
    currentMaxIndex = j;
    return currentMax;

    I think your ten Dates are all same.
    import java.util.Date;
    public class CompareToSort {
      public static void main(String[] args) {
        String[] strings
         = {"CS", "Math", "Biol", "Chem", "Phys", "Buss", "Law", "Educ",
            "Elec Engr", "Mech Engr"} ;
        Integer[] list = new Integer[10] ;
        Date[] dates = new Date[10] ;
        for (int i = 0; i < list.length; i++){
          list[i] = new Integer((int)(Math.random() * 100));
        for (int i = 0; i < list.length; i++){
          dates[i] = new Date();
        System.out.println("Max string is " + max(strings));
        System.out.println("Max integer is " + max(list));
        System.out.println("Max date is " + max(dates));
      public static <T extends Comparable<T>> T max (T[] a){
        T currentMax = a[0];
        for(int i = 1; i < a.length; ++i){
          if (a.compareTo(currentMax) > 0){
    currentMax = a[i];
    return currentMax;

  • Can anyone help me with a simple java programm in linux?

    i just started learning how to write java code in high school and we had an assignment which required us to write a program that would calculate the amount of kilometers u traveled into miles and vis-versa but we had to give the user a chance to pick which one they had to do and our teacher told us to give them the option using 1 to calculate from kilometers to miles and 2 to calculate miles to kilometers .....
    and i got confused so please help

    Encephalopathic wrote:
    First figure out an algorithm: how would you solve this problem just using pencil and paper. Once you know your equations and steps to take, then translate to Java. Why not give it a try first? You can't break your computer by doing this. Then come back with your code if you are still stuck.
    Good luck.galaxyboy25,
    This is very good advice. Getting into the habit of working out problems on paper/whiteboard first will save you many a headache later on. I'm relatively new to programming as well (only about 2 years professional experience) but this technique has helped me immensely in my work. In my mind, writing code is easy--figuring out what to write is where the real challenge is.
    One other thing. In addition to sketching your problem on paper, it always helps to break a problem into very small, simple, and easily solvable pieces. Then put them together. In doing this you will find that not only will this make your task of problem solving much easier but you also end up writing cleaner and more flexible code.
    -Thok

  • Help Me With A Simple  Photo Merge in CS4 And Is It Easier With CS6?

    I've had CS4 for few years and used in only for basic photo adjustment. I have worked with it many, many times trying to figure out how to do the following task, to no avail:
    I want to move my face from a family photo to a dollar bill I scanned in to use as a joke. It sounds very simple but is very, very complicated to figure out. Whats is the easiest way to do this? It does not have to be perfect.
    Also, will this task be easier to perform in CS6 or is it performed the same exact way?

    Maybe you should check out the tutorials mentioned here:
    http://feedback.photoshop.com/photoshop_family/topics/removing_background_from_image
    For this task I would estimate that Photoshop CS6 offers no relevant advantages over Photoshop CS4.

  • Please help me with somewhat simple problems

    Hi,
    I'm being asked to produce a 90 second "movie/commercial" that will be put on youtube.  I've used Motion 4 to create using just text and jpg pictures.  I've imported these various scenes into Final Cut Pro and have added transitions and edited.  When I'm not playing the movie from the timeline, the text and pictures are crystal clear.  After rendering, when I play the timeline, all the pictures and text are fuzzy.  I thought that once I exported the video, it would look clear...but it doesn't.  Can somebody give me some direction on what I need to do so that everything looks clear?  It doesn't have to be HD quality...just clear.  I don't have a lot of experience with Final Cut as I have been using Adobe Premiere Elements for the last 5 years.  Its getting very frustrating.
    Thanks
    Greg

    The white background you are selecting is only a tool to help view the image in the canvas. It does not actually place a background in your sequence. To have a white background, click on the Generator Button ( lower right corner of the Viewer window with an "A" on it) and from the drop down menu, choose Matte > Color. This will load a solid color into the viewer. Click on the Controls tab in the viewer and adjust it to the color you want - in this case white.
    Next, on your sequence, if you don't already have an available Video track above your edited clips, then add one by control-clicking on the space above V1 and select Add Track:
    This will add another track:
    Select your video clips on V1, and move them directly up to V2 by selecting them, then clicking down and dragging the selected clips up to V2 so that V1 becomes empty:
    And then edit the color you have in the viewer to V1:
    Now you will have a White background behind what ever is on the higher Video Tracks. If you have a long edit, you may need to edit the white color a couple times to make it run the length of the edit.
    MtD

  • Please help me with a simple flash game problem

    I am trying to learn how to make flash games with Adobe flash 5.5. I am doing a tutorial from a book and am stuck.
    The game is called concentration and you are suppose to match 2 tiles of the same shape. there are 10 shape tiles
    and 1 question mark tile. These tiles are held in an array. 20 tiles are suppose to be displayed 5 to a row with 4 rows
    and the question mark is suppose to be up on all 20. My problem is I get a blank screen when I test the movie. I
    think the code is good but I beleive I have not uploaded the tiles right. I did upload the 11 tiles to the library and have
    those 11 tiles and tile_movieclip in the library. Here is the code:
    package {
    // importing classes
    import flash.display.Sprite;
    // end of importing classes
    public class Main extends Sprite {
    public function Main() {
    // variables and constants
    const NUMBER_OF_TILES:uint=20;
    const TILES_PER_ROW:uint=5;
    var tiles:Array=new Array();
    var tile:tile_movieclip;
    // end of variables and constants
    // tiles creation loop
    for (var i:uint=0; i<NUMBER_OF_TILES; i++) {
    tiles.push(Math.floor(i/2));
    trace("My tiles: "+tiles);
    // end of tiles creation loop
    // shuffling loop
    var swap,tmp:uint;
    for (i=NUMBER_OF_TILES-1; i>0; i--) {
    swap=Math.floor(Math.random()*i);
    tmp=tiles[i];
    tiles[i]=tiles[swap];
    tiles[swap]=tmp;
    trace("My shuffled tiles: "+tiles);
    // end of shuffling loop
    // tile placing loop
    for (i=0; i<NUMBER_OF_TILES; i++) {
    tile=new tile_movieclip();
    addChild(tile);
    tile.cardType=tiles[i];
    tile.x=5+(tile.width+5)*(i%TILES_PER_ROW);
    tile.y=5+(tile.height+5)*(Math.floor(i/TILES_PER_ROW));
    tile.gotoAndStop(NUMBER_OF_TILES/2+1);
    // end of tile placing loop
    Can someone please explain to me what I am suppose to do to make the this work? I beleive the problem is it doesnt know where the tiles are.
    Thanks.

    To create the tiles, draw 10 distinct shapes in the first 10 frames of your symbol, and
    the back of the tile in the 11th frame. You are free to draw them as you want, but I suggest you make them as 90 pixels squares with registration point (starting x and y position) at 0, because these are the properties of the tiles used in this chapter's
    examples. At least, they should all be the same size.
    It didnt say put in a library. It is saying to draw them in frames of symbol but it didnt walk me through that. Can you guide me through this? I also was looking at how to add the link identifier but it said I need a popup window but I cant see one. I thought that was done
    when I went to insert new symbol. It said something about actionscript linkage. I am familliar with perl, java and c++ so I can follow the code so far but I dont have much understanding of the flash interface. I made the 10 shape tiles and the 1 question mark tile
    in paint. They are .jpeg images.

  • Can someone help me with a simple duration calculation?

    I created a simple workbook for calculating hours worked. I am entering the start time, end time, and using the DUR2HOURS formula to calculate the duration. For some reason the calculation is wrong. I am sure it is somethign simple, but I could not find an answer and it has been bothering me for a couple of days now. Here is an example of what is happening:
    Start Time     |     End Time     |     Duration
    7:15 AM               5:30 PM               10.25  (formula: =DUR2HOURS(ENDTIME - STARTTIME)
    The duration in this example should be 10.15?
    Thanks,
    Nate

    Hi NorthrailDrive,
    DUR2HOURS gives the value in decimal hours, not hours:minutes.
    Your answer (in decimal hours) is correct (10.25, or ten and a quarter hours).
    Cell C2 contains the formula you need to calculate a duration:
    =B2-A2
    C2 is formatted as Duration h (hours) m (minutes). You can change the display to show 10:15
    Regards,
    Ian.

  • Help me with this simple problem

    class Sample
         static String m(float i)
              return "float";
         static String m(double i)
              return "double";
         public static void main (String[] args)
              int a1 = 1; long b1 = 2;
              System.out.print(m(a1)+","+ m(b1));
    }On running the above program, it responds with float,float .
    Can anyone tell why ???
    Regards,
    Pradhip

    there are specific rules for finding the right type, i think it might be under "conversions" in the JLS? You can find the JLS here:
    http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html

  • Can you please help me with this simple (not for me:) issue

    Why this doesnt work?
    public void spl ()
         String a=("moon.sun");
    String [] f=a.split(".");
    System.out.println(f[0]);
    }

    The second expression to split() is a regular expression. A period in a regular expression matches all characters, and you're wanting it to just match a period.
    To match just the period for your split, you'll need to escape it:String[] f = a.split("\\.");

Maybe you are looking for