Results 1 to 2 of 2
  1. #1
    jiura is offline Member
    Join Date
    Jul 2015
    Posts
    1
    Rep Power
    0

    Default JAVA code to add new chart on the webpage (in Anylogic that used JAVA)

    Hello, dear Java users!
    I’m using a program which is based on JAVA. This program is called Anylogic 7. As Anylogic has a poor functionality charts components, I add JFreeChart. My problem, is that I cannot understand, how I can put it on my application window.
    I want it to be displayed as this one:


    1 If I write such JAVA code, and it adds chart to the New window (but I need to add it to my Main window behind)
    Java Code:
      DefaultCategoryDataset dataset = new DefaultCategoryDataset();
      String series1 = "Java";
      dataset.addValue(5.0, series1, "2005");
      dataset.addValue(8.0, series1, "2006");
      dataset.addValue(11.0, series1, "2007");
       dataset.addValue(15.0, series1, "2008");
    //
    JFreeChart chart = ChartFactory.createLineChart("A", "B", "C", dataset);
    //
    JFrame frame = new JFrame("MinimalStaticChart");
    frame.add(new ChartPanel(chart));
    frame.setSize(400, 300);
    frame.show();
    The Result is:


    2 Then I try to add it to Jframe of my Main window. As you can see on the image, new diagram is add, but it add to the “back” of my presentation window, and it occupies the entire area of the window!!
    Java Code:
      DefaultCategoryDataset dataset = new DefaultCategoryDataset();
      String series1 = "Java";
      dataset.addValue(5.0, series1, "2005");
      dataset.addValue(8.0, series1, "2006");
      dataset.addValue(11.0, series1, "2007");
       dataset.addValue(15.0, series1, "2008");
    //
    JFreeChart chart = ChartFactory.createLineChart("A", "B", "C", dataset);
    getPresentatio
    n().getFrame().add(new ChartPanel(chart));
    The Result is:


    As I understand this task should be similar to the simple addition of new chart in a certain place of the web page.
    How can I add it correctly??? What JAVA code I need to write?
    Thanks!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: JAVA code to add new chart on the webpage (in Anylogic that used JAVA)

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. code to refresh and check the code of a webpage..
    By vaggelis in forum New To Java
    Replies: 5
    Last Post: 02-07-2012, 02:21 PM
  2. AnyLogic Java HELP
    By hello_hello in forum New To Java
    Replies: 3
    Last Post: 12-24-2011, 01:49 AM
  3. [ASK]Java Flow Chart to source code
    By potatosaladz in forum New To Java
    Replies: 0
    Last Post: 12-28-2010, 06:11 AM
  4. uinx output to webpage using java
    By new_bea in forum Java Applets
    Replies: 0
    Last Post: 11-23-2010, 03:59 PM
  5. chart in java
    By rantravee in forum Java 2D
    Replies: 1
    Last Post: 03-05-2009, 09:42 PM

Posting Permissions

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