Results 1 to 7 of 7
  1. #1
    rperalta is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Need help graphing

    I'm trying to graph two arrays of doubles.

    I was trying to use the Chart2D_1.9.6k.jar library, i added it in project preferences.

    But when i write:

    import info.monitorenter.gui.chart.Chart2D;

    or try to import any of the classes it says they do not exist.

    Is there an easier way to graph my data? Or what could i be doing wrong?

    Here's my code:

    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    import javax.swing.JOptionPane;
    import java.text.DecimalFormat;
    import info.monitorenter.gui.chart.Chart2D;
    import info.monitorenter.gui.chart.ITrace2D;
    import info.monitorenter.gui.chart.traces.Trace2DSimple;

    class Grafic
    {
    public static void main(String[] args) {
    Double a = new Double(JOptionPane.showInputDialog(null, "a"));
    Double b = new Double(JOptionPane.showInputDialog(null, "b"));
    Double incrementoX = (b-a)/20;
    DecimalFormat formato = new DecimalFormat("0.000");
    String tabla = "x\tsinc(x)\n";
    Chart2D chart = new Chart2D();
    ITrace2D trace = new Trace2DSimple();
    chart.addTrace(trace);
    Double x=a;
    while (x <= b) {
    Double sinc;
    sinc = MiMate.sinc(x);
    tabla+= x+"\t"+formato.format(sinc)+"\n";
    trace.addPoint(x, sinc);
    x+= incrementoX;
    }
    JOptionPane.showMessageDialog(null, new JTextArea(tabla), "Tabla de Sinc(x) con "+a+"<=x<="+b, JOptionPane.PLAIN_MESSAGE);
    JFrame frame = new JFrame("Gr·fico de Sinc(x) con "+a+"<=x<="+b);
    frame.getContentPane().add(chart);
    frame.setSize(400,300);
    frame.addWindowListener( new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    }
    }
    frame.setVisible(true);
    }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need help graphing

    Are you using an IDE? If so, which one? If so, how are you adding the charting jar to the project's build path?

  3. #3
    rperalta is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Re: Need help graphing

    I'm using Netbeans7.0.1. I added it through ProjectProperties>Add jar file.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need help graphing

    I don't use NetBeans so I can't help you with this. Hopefully someone else here does and can.

  5. #5
    rperalta is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Re: Need help graphing

    Then could you perhaps help with an easy way to graph a pairs of Double arrays?

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need help graphing

    I have downloaded NetBeans (though didn't need to) and Chart2D, and I think your problem may be that you didn't open the Chart2D_1.9.6k.jar file and extract the folder that it holds. Per the instructions, the Chart2D_1.9.6k.jar doesn't look like it's supposed to be used as a jar file but rather its contents are supposed to be extracted, and then you use the jar files and other resources that it holds.

  7. #7
    rperalta is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default Re: Need help graphing

    I tried to extract the contents but it didn't work... Is it like unzipping a .zip file?

    When i add it to my project it does recognize the .jar file and i can see all the classes and stuff, but when i try to import it, the IDE say it doesn't exist...

Similar Threads

  1. Graphing Temperatures Predictions
    By Fautoty in forum Java 2D
    Replies: 3
    Last Post: 04-22-2011, 04:42 AM
  2. Graphing GUI
    By spyroth in forum NetBeans
    Replies: 3
    Last Post: 02-12-2011, 02:52 AM
  3. Scientific Graphing
    By shruthi Nadiger in forum AWT / Swing
    Replies: 2
    Last Post: 03-14-2010, 11:37 PM
  4. Graphing in java
    By collin389 in forum New To Java
    Replies: 2
    Last Post: 01-18-2010, 01:54 AM
  5. Help with graphing problem
    By adlb1300 in forum New To Java
    Replies: 2
    Last Post: 11-26-2007, 02:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •