Creating And Plotting Graphs

Discussion in 'Java' started by morc, Feb 23, 2006.

  1. morc

    morc Guest

    Hey,
    Does anybody know of a tutrial or soemthing i can read that would teach
    me how to make a graph and to plot it as well? Simple charts will do
    for know but eventualy I need to make stock market related charts.

    And please don't refer me to JFreeChart i know its good but it doesn't
    help me. I would like to be able to make one on my own. So if anyone
    would like to teach me or point me to a tutorial it would be greatly
    appreciated.

    thanks
    -morc
     
    morc, Feb 23, 2006
    #1
    1. Advertising

  2. morc

    Rhino Guest

    "morc" <> wrote in message
    news:...
    > Hey,
    > Does anybody know of a tutrial or soemthing i can read that would teach
    > me how to make a graph and to plot it as well? Simple charts will do
    > for know but eventualy I need to make stock market related charts.
    >
    > And please don't refer me to JFreeChart i know its good but it doesn't
    > help me. I would like to be able to make one on my own. So if anyone
    > would like to teach me or point me to a tutorial it would be greatly
    > appreciated.
    >

    I think you'll find drawing graphs is pretty simple. A very basic example of
    a graph can be seen at
    http://java.sun.com/applets/jdk/1.4/demo/applets/SimpleGraph/example1.html.
    If you look at the source code (linked below the applet), you'll see that it
    is only a very small number of lines of code to draw this sine wave. If you
    want to add axes to the graph, that is basically a matter of drawing two
    more straight lines via the g.drawLine() method.

    If you want to put tick marks on the axes and label the marks, that's a bit
    more work but still no big deal: you simply compute the length of the axis
    and the range of values you want to show on the axis, then determine where
    the tick marks need to be to represent the desired values. For instance, if
    the X axis represents 100 units and is 8 cm long and you want tick marks for
    the values 25, 50, 75 and 100, you simply put them at 2 cm, 4 cm, 6 cm, and
    8 cm from the origin and label appropriately via drawString().

    Naturally, you can add as many bells and whistles as you like, such as the
    ability to zoom in or out on the graph, show multiple curves, etc. etc.

    I think you'll find everything you need in the Graphics and/or Graphics2D
    classes in the Java API. Assuming you are using Swing, simply paint the
    various lines, curves, and Strings on a JPanel and you should be off to the
    races.

    --
    Rhino
     
    Rhino, Feb 23, 2006
    #2
    1. Advertising

  3. morc

    IchBin Guest

    morc wrote:
    > Hey,
    > Does anybody know of a tutrial or soemthing i can read that would teach
    > me how to make a graph and to plot it as well? Simple charts will do
    > for know but eventualy I need to make stock market related charts.
    >
    > And please don't refer me to JFreeChart i know its good but it doesn't
    > help me. I would like to be able to make one on my own. So if anyone
    > would like to teach me or point me to a tutorial it would be greatly
    > appreciated.
    >
    > thanks
    > -morc
    >

    There is a demo under your JDK install at
    ...\Java\jdk1.5.0_06\demo\applets\SimpleGraph

    So
    http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html

    Examples can be found here in the "The Java Developers Almanac 1.4"

    http://www.google.com/custom?num=10...aphics&btnG=Search&sitesearch=javaalmanac.com

    Some more info:
    http://java.ittoolbox.com/topics/t.asp?t=440&p=440&h1=440

    Google is an amazing tool when used..

    --

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
     
    IchBin, Feb 23, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vivek

    plotting Graphs how to in C ?

    Vivek, Oct 16, 2006, in forum: C Programming
    Replies:
    2
    Views:
    960
  2. Replies:
    3
    Views:
    377
    Helmut Jarausch
    Jun 13, 2008
  3. Replies:
    8
    Views:
    1,015
  4. nk1

    Plotting graphs in python

    nk1, Oct 12, 2010, in forum: Python
    Replies:
    0
    Views:
    322
  5. Vicky Conlan

    Advice on module for plotting graphs

    Vicky Conlan, Sep 30, 2008, in forum: Perl Misc
    Replies:
    10
    Views:
    196
    A. Sinan Unur
    Oct 2, 2008
Loading...

Share This Page