JFreeChart in Anylogic: JAVA code to add chart on webpage

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jiura
Posts: 1
Joined: Sun Jul 05, 2015 9:21 pm
antibot: No, of course not.

JFreeChart in Anylogic: JAVA code to add chart on webpage

Post by jiura » Sun Jul 05, 2015 9:26 pm

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:
Image

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:

Code: Select all

  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:
Image


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

Code: Select all

  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);
getPresentation().getFrame().add(new ChartPanel(chart));
The Result is:
Image

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!

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: JFreeChart in Anylogic: JAVA code to add chart on webpag

Post by paradoxoff » Tue Jul 07, 2015 9:12 pm

An anylogic forum might be a better place to ask.

Locked