JFREECHART我试了好像不行吧,好像能用于JSP,但我需要在JPANEL里画个柱状图,要六个柱子,两个一组要相互比较高度,要画出X和Y轴,Y轴时时间,X轴是三组个名称,三个STRING就行,我自己添
解决方案 »
- 100分求助,按完OneMoreTime钮按后,再用键盘改变方向就不好使了
- jar包的打不开
- 关于的位移运算的问题。
- java applet再IE中调用失败
- 怎么应用正则表达式判断字符串中有中文?
- 判断字符串1a2b3c4d5e6f格式是否正确,其中abcdef顺序可能互换,但只要是这六个字符就行
- 请问一下java.lang.Compiler.CompileClasses()方法怎么用?
- jijijijii
- 执行TOMCAT时的报错。。
- 静态变量向前引用问题
- 如何改变菜单栏的大小和里面JMenuItem的大小?
- Java执行exe(C++)时,exe端取得参数乱码(英文OS),急!!!!!!!!(解决后另外送分)
楼主【lsjlovebm】截止到2008-06-23 12:29:51的历史汇总数据(不包括此帖):
发帖数:7 发帖分:85
结贴数:7 结贴分:85
未结数:0 未结分:0
结贴率:100.00% 结分率:100.00%
敬礼!
去看demo, 没有源代码就用 dj 反编译看!
super(s);
setContentPane(createDemoBar());
} // 生成显示图表的面板
public static JPanel createDemoBar() {
JFreeChart jfreechart = createChart(createDataset());
return new ChartPanel(jfreechart);
} // 生成图表主对象JFreeChart
public static JFreeChart createChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart3D("水果销量统计图", //建立3D柱状图
"水果",//横轴名称
"销量",//纵轴名称
dataset,//数据集
PlotOrientation.VERTICAL,//纵向显示
true,//显示每个颜色柱子的柱名
false, false);
CategoryPlot plot = chart.getCategoryPlot();//设置图的高级属性
BarRenderer3D renderer = new BarRenderer3D();//3D属性修改
renderer.setBaseOutlinePaint(Color.BLACK);//设置边框颜色为black
renderer.setWallPaint(Color.gray); //设置wall的颜色为gray
renderer
.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());//设置柱顶数据,API中居然没有StandardCategoryItemLabelGenerator这个类
//renderer.setItemLabelFont(new Font("黑体",Font.PLAIN,12));//设置柱顶数据字体
renderer.setItemLabelsVisible(true);//打开ItemLabel开关
plot.setRenderer(renderer);//将修改后的属性值保存到图中
plot.setForegroundAlpha(0.6f);//柱的透明度 return chart;
} // 生成数据
public static CategoryDataset createDataset() { double[][] data = new double[][] { { 672, 766, 223, 540, 126 },
{ 325, 521, 210, 340, 106 }, { 332, 256, 523, 240, 526 } };// 设置数据
String[] rowKeys = { "苹果", "梨子", "葡萄" };// 行标志
String[] columnKeys = { "北京", "上海", "广州", "成都", "深圳" };// 列标志
CategoryDataset linedataset = DatasetUtilities.createCategoryDataset(
rowKeys, columnKeys, data); // 建立数据集 return linedataset;
} public static void main(String[] args) {
BarCharts fjc = new BarCharts("柱状图");
fjc.pack();
RefineryUtilities.centerFrameOnScreen(fjc);
fjc.setVisible(true); } }
super(s);
setContentPane(createDemoBar());
} // 生成显示图表的面板
public static JPanel createDemoBar() {
JFreeChart jfreechart = createChart(createDataset());
return new ChartPanel(jfreechart);
} // 生成图表主对象JFreeChart
public static JFreeChart createChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart3D("水果销量统计图", //建立3D柱状图
"水果",//横轴名称
"销量",//纵轴名称
dataset,//数据集
PlotOrientation.VERTICAL,//纵向显示
true,//显示每个颜色柱子的柱名
false, false);
CategoryPlot plot = chart.getCategoryPlot();//设置图的高级属性
BarRenderer3D renderer = new BarRenderer3D();//3D属性修改
renderer.setBaseOutlinePaint(Color.BLACK);//设置边框颜色为black
renderer.setWallPaint(Color.gray); //设置wall的颜色为gray
renderer
.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());//设置柱顶数据,API中居然没有StandardCategoryItemLabelGenerator这个类
//renderer.setItemLabelFont(new Font("黑体",Font.PLAIN,12));//设置柱顶数据字体
renderer.setItemLabelsVisible(true);//打开ItemLabel开关
plot.setRenderer(renderer);//将修改后的属性值保存到图中
plot.setForegroundAlpha(0.6f);//柱的透明度 return chart;
} // 生成数据
public static CategoryDataset createDataset() { double[][] data = new double[][] { { 672, 766, 223, 540, 126 },
{ 325, 521, 210, 340, 106 }, { 332, 256, 523, 240, 526 } };// 设置数据
String[] rowKeys = { "苹果", "梨子", "葡萄" };// 行标志
String[] columnKeys = { "北京", "上海", "广州", "成都", "深圳" };// 列标志
CategoryDataset linedataset = DatasetUtilities.createCategoryDataset(
rowKeys, columnKeys, data); // 建立数据集 return linedataset;
} public static void main(String[] args) {
BarCharts fjc = new BarCharts("柱状图");
fjc.pack();
RefineryUtilities.centerFrameOnScreen(fjc);
fjc.setVisible(true); } }
什么意思?