欢迎来到天天文库
浏览记录
ID:38158018
大小:35.97 KB
页数:5页
时间:2019-06-06
《java堆积柱状图》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//如何画堆积柱状图importjava.awt.BasicStroke;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Dimension;importjava.awt.EventQueue;importjava.awt.Font;importjavax.swing.JFrame;importjavax.swing.JPanel;importjavax.swing.border.EmptyBorder;importjavax.swing.JScrollPane;importorg.jfree.chart.Ch
2、artFactory;importorg.jfree.chart.ChartPanel;importorg.jfree.chart.JFreeChart;importorg.jfree.chart.axis.CategoryAxis;importorg.jfree.chart.axis.CategoryLabelPositions;importorg.jfree.chart.axis.ValueAxis;importorg.jfree.chart.labels.StandardCategoryItemLabelGenerator;importorg.jfree.chart.plot.Cat
3、egoryPlot;importorg.jfree.chart.plot.PlotOrientation;importorg.jfree.chart.renderer.category.AbstractCategoryItemRenderer;importorg.jfree.chart.renderer.category.StackedBarRenderer;importorg.jfree.chart.renderer.category.StandardBarPainter;importorg.jfree.chart.title.TextTitle;importorg.jfree.data
4、.category.CategoryDataset;importorg.jfree.data.category.DefaultCategoryDataset;importorg.jfree.ui.RectangleEdge;importcom.orsoncharts.renderer.category.StackedBarRenderer3D;publicclassYUYUextendsJFrame{privateJPanelcontentPane;/***Launchtheapplication.*/publicstaticvoidmain(String[]args){EventQueu
5、e.invokeLater(newRunnable(){publicvoidrun(){try{YUYUframe=newYUYU();frame.setVisible(true);}catch(Exceptione){e.printStackTrace();}}});}/***Createtheframe.*/publicYUYU(){setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100,100,450,300);contentPane=newJPanel();contentPane.setBorder(newEmpty
6、Border(5,5,5,5));contentPane.setLayout(newBorderLayout(0,0));setContentPane(contentPane);JPanelpanel=newJPanel();contentPane.add(panel,BorderLayout.CENTER);panel.setLayout(newBorderLayout(0,0));JScrollPanescrollPane=newJScrollPane();panel.add(scrollPane);CategoryDatasetcategoryDataset=createDatase
7、t();JFreeChartjfreechart=createChart(categoryDataset);ChartPanelchartPanel=createPanel();//设置容器的初始大小(Dimension是用来设置尺寸的)chartPanel.setPreferredSize(newDimension(180,60));//尤其注意的是panel的高度会严重影响柱体的宽度scrollPane.setVie
此文档下载收益归作者所有