Java如何调用数据库中的数据画图
发布网友
发布时间:2022-04-22 11:32
我来回答
共3个回答
热心网友
时间:2023-09-06 18:10
你需要下载导入JFREECHART的jar包
然后下面是一个例子
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class XYSeriesDemo extends ApplicationFrame {
/**
* A demonstration application showing an XY series containing a null value.
*
* @param title the frame title.
*/
public XYSeriesDemo(final String title) {
super(title);
final XYSeries series = new XYSeries("Random Data");
series.add(1.0, 500.2);
series.add(5.0, 694.1);
series.add(4.0, 100.0);
series.add(12.5, 734.4);
series.add(17.3, 453.2);
series.add(21.2, 500.2);
series.add(21.9, null);
series.add(25.6, 734.4);
series.add(30.0, 453.2);
final XYSeriesCollection data = new XYSeriesCollection(series);
final JFreeChart chart = ChartFactory.createXYLineChart(
"XY Series Demo",
"X",
"Y",
data,
PlotOrientation.VERTICAL,
true,
true,
false
);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
}
public static void main(final String[] args) {
final XYSeriesDemo demo = new XYSeriesDemo("XY Series Demo");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
series.add(1.0, 500.2);1.0,500.2分别是横坐标和纵坐标数值 它会自动产生横竖坐标的
热心网友
时间:2023-09-06 18:11
用jfreechart或eclipse的birt
热心网友
时间:2023-09-06 18:11
jfreechart ,看这个开源的API,而且有狠多例子