Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Embed JFreeChart chart in a JPanel

Posted on 2011-09-23
3
Medium Priority
?
826 Views
Last Modified: 2012-05-12
Please let me know how I can embed a JFreeChart in a JPanel. If possible, please provide some sample code.

Thanks!
0
Comment
Question by:dshrenik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 total points
ID: 36590405


You can use ChartPanel which extends JPanel, like that:

    ApplicationFrame af = new ApplicationFrame("Chart");
  JFreeChart chart = af.createChart(dataset);
         ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(600, 350));
       af. setContentPane(chartPanel);
     af.setVisible(true);

Open in new window


There are lots of examples there
on http://www.java2s.com/Code/Java/Chart/JFreeChartLineChartDemo6.htm
What kind of more code do you want?


0
 
LVL 47

Expert Comment

by:for_yan
ID: 36590419

Download JFreeChart
from here:


http://sourceforge.net/projects/jfreechart/files/1.%20JFreeChart/1.0.13/jfreechart-1.0.13.zip/download

JCommon from here:

http://sourceforge.net/projects/jfreechart/files/3.%20JCommon/1.0.16/jcommon-1.0.16.zip/download

Put them in the classpath of your project

Select the best example you like from that www.java2s.com
site and see how it works.

From that point in many cases it is easy to understand
how to modify it to get your stuff working
 
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36590446
And yes, there may be discrepancy - the examples may use a litytle bit older version is some unlucky cases,
but then wlooking at API and dealing with the particular case it is in most cases possible to figure out
how to change

Look ath the right side picttures in the examples and select something which
is most close to your task at hand
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question