r 跪求jfreechart图在JSF里折线图,排列图如何应用的啊,谁能发个例子给我看看 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你个折线例子,执行一下看看是不是你要的效果:import java.awt.Color;import java.awt.Dimension;import javax.swing.JPanel;import org.jfree.chart.*;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.plot.PlotOrientation;import org.jfree.chart.plot.XYPlot;import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;import org.jfree.data.xy.*;import org.jfree.ui.*;public class LineChartDemo2 extends ApplicationFrame{ public LineChartDemo2(String s) { super(s); XYDataset xydataset = createDataset(); JFreeChart jfreechart = createChart(xydataset); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartpanel); } private static XYDataset createDataset() { XYSeries xyseries = new XYSeries("First"); xyseries.add(1.0D, 1.0D); xyseries.add(2D, 4D); xyseries.add(3D, 3D); xyseries.add(4D, 5D); xyseries.add(5D, 5D); xyseries.add(6D, 7D); xyseries.add(7D, 7D); xyseries.add(8D, 8D); XYSeries xyseries1 = new XYSeries("Second"); xyseries1.add(1.0D, 5D); xyseries1.add(2D, 7D); xyseries1.add(3D, 6D); xyseries1.add(4D, 8D); xyseries1.add(5D, 4D); xyseries1.add(6D, 4D); xyseries1.add(7D, 2D); xyseries1.add(8D, 1.0D); XYSeries xyseries2 = new XYSeries("Third"); xyseries2.add(3D, 4D); xyseries2.add(4D, 3D); xyseries2.add(5D, 2D); xyseries2.add(6D, 3D); xyseries2.add(7D, 6D); xyseries2.add(8D, 3D); xyseries2.add(9D, 4D); xyseries2.add(10D, 3D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); xyseriescollection.addSeries(xyseries1); xyseriescollection.addSeries(xyseries2); return xyseriescollection; } private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Line Chart Demo 2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot)jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)xyplot.getRenderer(); xylineandshaperenderer.setShapesVisible(true); xylineandshaperenderer.setShapesFilled(true); NumberAxis numberaxis = (NumberAxis)xyplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; } public static JPanel createDemoPanel() { JFreeChart jfreechart = createChart(createDataset()); return new ChartPanel(jfreechart); } public static void main(String args[]) { LineChartDemo2 linechartdemo2 = new LineChartDemo2("Line Chart Demo 2"); linechartdemo2.pack(); RefineryUtilities.centerFrameOnScreen(linechartdemo2); linechartdemo2.setVisible(true); }} 求助:nested exception is org.hibernate.MappingException GBK转UTF-8乱码 大家来帮我看看Struts2的这个问题 一个JSP页面实现增删改查页面排版 超弱问题:JAVA能执行select into sql语句嘛? 求助:POI操作Excel的一个小问题。。。。。(在线等) 初学者请教问题之二:数据库查询问题 求助!使用CURL模拟POST,DWR报failed to read input 没分了,哥们帮帮忙? 又是一个送分的问题 byte[]数组的问题 急求答案! 关于hibernate事务隔离度的问题
import java.awt.Dimension;
import javax.swing.JPanel;
import org.jfree.chart.*;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.*;
import org.jfree.ui.*;public class LineChartDemo2 extends ApplicationFrame
{
public LineChartDemo2(String s)
{
super(s);
XYDataset xydataset = createDataset();
JFreeChart jfreechart = createChart(xydataset);
ChartPanel chartpanel = new ChartPanel(jfreechart);
chartpanel.setPreferredSize(new Dimension(500, 270));
setContentPane(chartpanel);
} private static XYDataset createDataset()
{
XYSeries xyseries = new XYSeries("First");
xyseries.add(1.0D, 1.0D);
xyseries.add(2D, 4D);
xyseries.add(3D, 3D);
xyseries.add(4D, 5D);
xyseries.add(5D, 5D);
xyseries.add(6D, 7D);
xyseries.add(7D, 7D);
xyseries.add(8D, 8D);
XYSeries xyseries1 = new XYSeries("Second");
xyseries1.add(1.0D, 5D);
xyseries1.add(2D, 7D);
xyseries1.add(3D, 6D);
xyseries1.add(4D, 8D);
xyseries1.add(5D, 4D);
xyseries1.add(6D, 4D);
xyseries1.add(7D, 2D);
xyseries1.add(8D, 1.0D);
XYSeries xyseries2 = new XYSeries("Third");
xyseries2.add(3D, 4D);
xyseries2.add(4D, 3D);
xyseries2.add(5D, 2D);
xyseries2.add(6D, 3D);
xyseries2.add(7D, 6D);
xyseries2.add(8D, 3D);
xyseries2.add(9D, 4D);
xyseries2.add(10D, 3D);
XYSeriesCollection xyseriescollection = new XYSeriesCollection();
xyseriescollection.addSeries(xyseries);
xyseriescollection.addSeries(xyseries1);
xyseriescollection.addSeries(xyseries2);
return xyseriescollection;
} private static JFreeChart createChart(XYDataset xydataset)
{
JFreeChart jfreechart = ChartFactory.createXYLineChart("Line Chart Demo 2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false);
jfreechart.setBackgroundPaint(Color.white);
XYPlot xyplot = (XYPlot)jfreechart.getPlot();
xyplot.setBackgroundPaint(Color.lightGray);
xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
xyplot.setDomainGridlinePaint(Color.white);
xyplot.setRangeGridlinePaint(Color.white);
XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)xyplot.getRenderer();
xylineandshaperenderer.setShapesVisible(true);
xylineandshaperenderer.setShapesFilled(true);
NumberAxis numberaxis = (NumberAxis)xyplot.getRangeAxis();
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
return jfreechart;
} public static JPanel createDemoPanel()
{
JFreeChart jfreechart = createChart(createDataset());
return new ChartPanel(jfreechart);
} public static void main(String args[])
{
LineChartDemo2 linechartdemo2 = new LineChartDemo2("Line Chart Demo 2");
linechartdemo2.pack();
RefineryUtilities.centerFrameOnScreen(linechartdemo2);
linechartdemo2.setVisible(true);
}
}