BubblePlotDemo - how to include sample data inside?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

BubblePlotDemo - how to include sample data inside?

Post by luis_esru » Wed Sep 22, 2004 11:09 pm

David

I need to use BubblePlotDemo chart, but it's using SampleXYZDataset as a sample data source. How would I avoid that? (ie, how do I include a sample data in BubblePlotDemo?). See code below:

#############################################################
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.XYZDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

/**
* A bubble chart demo.
*
* @author David Gilbert
*/
public class BubblePlotDemo extends ApplicationFrame {

/**
* A demonstration application showing a bubble chart.
*
* @param title the frame title.
*/
public BubblePlotDemo(String title) {

super(title);

//size and location
setLocation(300,100);
setSize (400,300);

?????????????????????????????????????????
XYZDataset data = new SampleXYZDataset();
?????????????????????????????????????????

JFreeChart chart = createChart(data);

ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
chartPanel.setVerticalZoom(true);
chartPanel.setHorizontalZoom(true);
setContentPane(chartPanel);

}

/**
* Creates a chart.
*
* @param dataset the dataset.
*
* @return The chart.
*/
private JFreeChart createChart(XYZDataset dataset) {
JFreeChart chart = ChartFactory.createBubbleChart(
"Bubble Plot Demo",
"X",
"Y",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
XYPlot plot = chart.getXYPlot();
plot.setForegroundAlpha(0.65f);

// increase the margins to account for the fact that the auto-range doesn't take into
// account the bubble size...
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setLowerMargin(0.15);
domainAxis.setUpperMargin(0.15);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setLowerMargin(0.15);
rangeAxis.setUpperMargin(0.15);
return chart;
}
}
#############################################################

Thanks,
Luis.
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Sep 23, 2004 11:14 am

You need to create a class that implements the XYZDataset interface. There isn't a generic implementation in JFreeChart yet.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

luis_esru
Posts: 42
Joined: Tue Jan 20, 2004 6:40 pm
Location: Glasgow
Contact:

BubblePlotDemo chart

Post by luis_esru » Sun Sep 26, 2004 4:09 pm

David

How difficult would be to create a class that implements the XYZdataset interface? Are you thinking in implementing it any time soon?

Rgds,
Luis
University of Strathclyde in Glasgow
ESRU
luis@esru.strath.ac.uk

guest

BubbleChart

Post by guest » Mon Apr 11, 2005 3:31 pm

hi,
is it in the TODO list? I don't want to write 2 or more extra classes for the servlet.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: BubbleChart

Post by david.gilbert » Mon Apr 11, 2005 9:08 pm

guest wrote:is it in the TODO list? I don't want to write 2 or more extra classes for the servlet.
It is on my to-do list, but I doubt it will get done for a while...too many other things to do.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked