Dynamic Stacked Area Chart
The following is a link to a web page with a demo of a
stacked area chart:
http://www.java2s.com/Code/Java/Chart/J ... rtDemo.htm
The code is provided, but it's for a static CategoryDataset, created
using DatasetUtilities.createCategoryDataset(...).
It's a great example, but I need to be able to change the graph
dynamically. The CategoryDataset doesn't let you change anything.
Is there any way to make this dynamic?
If there's no way to change the dataset, is there any way to make
a call that replaces the dataset entirely in the chart?
Thanks,
John
Dynamic Stacked Area Chart
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Dynamic Stacked Area Chart
One of my favorite things about JFreeChart is linksource="yes" in build.xml, but I digress. Internally, DatasetUtilities.createCategoryDataset() constructs a DefaultCategoryDataset, which is eminently mutable. I'd say cast the return value or construct your own.
Re: Dynamic Stacked Area Chart
Hi,
I have the same problem, and I don't find any solution.
Have you find a solution for dynamic stacked area chart ?
Thank's
I have the same problem, and I don't find any solution.
Have you find a solution for dynamic stacked area chart ?
Thank's
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Dynamic Stacked Area Chart
I started from the example cited and cast the dataset as suggested:
I added a suitable Action:
I see a result similar to this image:
Code: Select all
DefaultCategoryDataset dataset = (DefaultCategoryDataset) createDataset();
Code: Select all
add(chartPanel);
add(new JButton(new AbstractAction("Add") {
@Override
public void actionPerformed(ActionEvent e) {
dataset.addValue(Math.random() * 42, "Row", "Added");
}
}), BorderLayout.PAGE_END);