首页上一页 1 下一页尾页 5 条记录 1/1页
java web 开发实战1200例(第I卷) 源文件21\547
发表在JavaWeb图书答疑
2011-10-10
是否精华
是
否
版块置顶:
是
否
设置时间:
非永久
永久
起始时间:
结束时间:
是否扣分:
是
否
就是插入一张图片到Excel里,sheet.setRowView(0,400,false);//设置第一行的行高,
我再插入一张图片到Excel里,sheet.setRowView(1,400,false);//设置第二行的行高
第二行的行高不起作用?
我再插入一张图片到Excel里,sheet.setRowView(1,400,false);//设置第二行的行高
第二行的行高不起作用?
精彩评论 5
2011-10-11
板凳
谢谢!哪个问题我已经解决了,现在遇到这个问题,是java web 开发实战1200例(第II卷)第8章jfreechart问题,
我想实现的效果是单个主题,每个月的值用柱形图显示,我用的是3D立体的柱状图,可我怎么设置,每个柱子的颜色都一样,有什么办法让每个柱子颜色不一样?谢谢
/**
* 月报表合格率
* @return JFreeChart
*/
public static JFreeChart getJFreeChart() {
DefaultKeyedValues keyedValues = new DefaultKeyedValues();
//添加数据
keyedValues.addValue("1月", 0.91);
keyedValues.addValue("2月", 0.95);
keyedValues.addValue("3月", 0.94);
keyedValues.addValue("4月", 1.00);
keyedValues.addValue("5月", 0.98);
keyedValues.addValue("6月", 0.96);
//创建数据集合实例
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("检测结果", keyedValues);
JFreeChart chart = ChartFactory.createBarChart3D("2011年月报表合格率柱形图", // 图表标题
"月份", // x轴标签
"合格率(百分比)", // y轴标签
dataset, // 数据集
PlotOrientation.VERTICAL, // 图表方向:水平、垂直
true, // 是否显示图例(对于简单的柱状图必须是false)
false, // 是否生成工具
false // 是否生成URL链接
);
/******字体的设置******/
// 标题
TextTitle textTitle = chart.getTitle();
textTitle.setFont(new Font("宋体", Font.PLAIN, 20));
// 图表(柱形图)
CategoryPlot categoryPlot = chart.getCategoryPlot();
CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
BarRenderer3D customBarRenderer = (BarRenderer3D) categoryPlot.getRenderer();
//设定柱子上面的颜色
customBarRenderer.setSeriesPaint(0, Color.decode("#7979FF")); // 给series1 Bar
customBarRenderer.setSeriesPaint(1, Color.decode("#7979FF")); // 给series2 Bar
customBarRenderer.setSeriesPaint(2, Color.decode("#FF5555")); // 给series3 Bar
customBarRenderer.setSeriesPaint(3, Color.decode("#F8D661")); // 给series4 Bar
customBarRenderer.setSeriesPaint(4, Color.decode("#F284DC")); // 给series5 Bar
customBarRenderer.setSeriesPaint(5, Color.decode("#00CC33")); // 给series6 Bar
customBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(1,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(2,Color.BLACK); //边框为黑色
customBarRenderer.setSeriesOutlinePaint(3,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(4,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(5,Color.BLACK); //边框为黑色
// X轴字体
categoryAxis.setTickLabelFont(new Font("宋体", Font.PLAIN, 14));
// X轴标签字体
categoryAxis.setLabelFont(new Font("宋体", Font.PLAIN, 14));
ValueAxis valueAxis = categoryPlot.getRangeAxis();
// y轴字体
valueAxis.setTickLabelFont(new Font("宋体", Font.PLAIN, 14));
// y轴标签字体
valueAxis.setLabelFont(new Font("宋体", Font.PLAIN, 14));
// 图示
LegendTitle legendTitle = chart.getLegend();
legendTitle.setItemFont(new Font("宋体", Font.PLAIN, 12));
/*******描点的设置********/
//设置注解
CategoryTextAnnotation annotation = new CategoryTextAnnotation("0.91","1月",0.91);
CategoryTextAnnotation annotation1 = new CategoryTextAnnotation("0.95","2月",0.95);
CategoryTextAnnotation annotation2 = new CategoryTextAnnotation("0.94","3月",0.94);
CategoryTextAnnotation annotation3 = new CategoryTextAnnotation("1.00","4月",1.00);
CategoryTextAnnotation annotation4 = new CategoryTextAnnotation("0.98","5月",0.98);
CategoryTextAnnotation annotation5 = new CategoryTextAnnotation("0.96","6月",0.96);
//设置注解角度锚点
annotation.setRotationAngle(Math.PI*0.2);
annotation1.setRotationAngle(Math.PI*0.2);
annotation2.setRotationAngle(Math.PI*0.2);
annotation3.setRotationAngle(Math.PI*0.2);
annotation4.setRotationAngle(Math.PI*0.2);
annotation5.setRotationAngle(Math.PI*0.2);
//添加注解
categoryPlot.addAnnotation(annotation);
categoryPlot.addAnnotation(annotation1);
categoryPlot.addAnnotation(annotation2);
categoryPlot.addAnnotation(annotation3);
categoryPlot.addAnnotation(annotation4);
categoryPlot.addAnnotation(annotation5);
return chart;
}
我想实现的效果是单个主题,每个月的值用柱形图显示,我用的是3D立体的柱状图,可我怎么设置,每个柱子的颜色都一样,有什么办法让每个柱子颜色不一样?谢谢
/**
* 月报表合格率
* @return JFreeChart
*/
public static JFreeChart getJFreeChart() {
DefaultKeyedValues keyedValues = new DefaultKeyedValues();
//添加数据
keyedValues.addValue("1月", 0.91);
keyedValues.addValue("2月", 0.95);
keyedValues.addValue("3月", 0.94);
keyedValues.addValue("4月", 1.00);
keyedValues.addValue("5月", 0.98);
keyedValues.addValue("6月", 0.96);
//创建数据集合实例
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("检测结果", keyedValues);
JFreeChart chart = ChartFactory.createBarChart3D("2011年月报表合格率柱形图", // 图表标题
"月份", // x轴标签
"合格率(百分比)", // y轴标签
dataset, // 数据集
PlotOrientation.VERTICAL, // 图表方向:水平、垂直
true, // 是否显示图例(对于简单的柱状图必须是false)
false, // 是否生成工具
false // 是否生成URL链接
);
/******字体的设置******/
// 标题
TextTitle textTitle = chart.getTitle();
textTitle.setFont(new Font("宋体", Font.PLAIN, 20));
// 图表(柱形图)
CategoryPlot categoryPlot = chart.getCategoryPlot();
CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
BarRenderer3D customBarRenderer = (BarRenderer3D) categoryPlot.getRenderer();
//设定柱子上面的颜色
customBarRenderer.setSeriesPaint(0, Color.decode("#7979FF")); // 给series1 Bar
customBarRenderer.setSeriesPaint(1, Color.decode("#7979FF")); // 给series2 Bar
customBarRenderer.setSeriesPaint(2, Color.decode("#FF5555")); // 给series3 Bar
customBarRenderer.setSeriesPaint(3, Color.decode("#F8D661")); // 给series4 Bar
customBarRenderer.setSeriesPaint(4, Color.decode("#F284DC")); // 给series5 Bar
customBarRenderer.setSeriesPaint(5, Color.decode("#00CC33")); // 给series6 Bar
customBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(1,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(2,Color.BLACK); //边框为黑色
customBarRenderer.setSeriesOutlinePaint(3,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(4,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(5,Color.BLACK); //边框为黑色
// X轴字体
categoryAxis.setTickLabelFont(new Font("宋体", Font.PLAIN, 14));
// X轴标签字体
categoryAxis.setLabelFont(new Font("宋体", Font.PLAIN, 14));
ValueAxis valueAxis = categoryPlot.getRangeAxis();
// y轴字体
valueAxis.setTickLabelFont(new Font("宋体", Font.PLAIN, 14));
// y轴标签字体
valueAxis.setLabelFont(new Font("宋体", Font.PLAIN, 14));
// 图示
LegendTitle legendTitle = chart.getLegend();
legendTitle.setItemFont(new Font("宋体", Font.PLAIN, 12));
/*******描点的设置********/
//设置注解
CategoryTextAnnotation annotation = new CategoryTextAnnotation("0.91","1月",0.91);
CategoryTextAnnotation annotation1 = new CategoryTextAnnotation("0.95","2月",0.95);
CategoryTextAnnotation annotation2 = new CategoryTextAnnotation("0.94","3月",0.94);
CategoryTextAnnotation annotation3 = new CategoryTextAnnotation("1.00","4月",1.00);
CategoryTextAnnotation annotation4 = new CategoryTextAnnotation("0.98","5月",0.98);
CategoryTextAnnotation annotation5 = new CategoryTextAnnotation("0.96","6月",0.96);
//设置注解角度锚点
annotation.setRotationAngle(Math.PI*0.2);
annotation1.setRotationAngle(Math.PI*0.2);
annotation2.setRotationAngle(Math.PI*0.2);
annotation3.setRotationAngle(Math.PI*0.2);
annotation4.setRotationAngle(Math.PI*0.2);
annotation5.setRotationAngle(Math.PI*0.2);
//添加注解
categoryPlot.addAnnotation(annotation);
categoryPlot.addAnnotation(annotation1);
categoryPlot.addAnnotation(annotation2);
categoryPlot.addAnnotation(annotation3);
categoryPlot.addAnnotation(annotation4);
categoryPlot.addAnnotation(annotation5);
return chart;
}
2011-10-11
4L
[FIELDSET][LEGEND]引自:3楼[/LEGEND]
setSeriesPaint() 这个方法设置柱形图的颜色
[/FIELDSET]
回复://设定柱子上面的颜色
customBarRenderer.setSeriesPaint(0, Color.decode("#7979FF")); // 给series1 Bar
customBarRenderer.setSeriesPaint(1, Color.decode("#7979FF")); // 给series2 Bar
customBarRenderer.setSeriesPaint(2, Color.decode("#FF5555")); // 给series3 Bar
customBarRenderer.setSeriesPaint(3, Color.decode("#F8D661")); // 给series4 Bar
customBarRenderer.setSeriesPaint(4, Color.decode("#F284DC")); // 给series5 Bar
customBarRenderer.setSeriesPaint(5, Color.decode("#00CC33")); // 给series6 Bar
代码上我都设置了,还是同一种颜色,它是3D立体的,不信运行下代码看下,
都不看代码的?
急用啊!
setSeriesPaint() 这个方法设置柱形图的颜色
[/FIELDSET]
回复://设定柱子上面的颜色
customBarRenderer.setSeriesPaint(0, Color.decode("#7979FF")); // 给series1 Bar
customBarRenderer.setSeriesPaint(1, Color.decode("#7979FF")); // 给series2 Bar
customBarRenderer.setSeriesPaint(2, Color.decode("#FF5555")); // 给series3 Bar
customBarRenderer.setSeriesPaint(3, Color.decode("#F8D661")); // 给series4 Bar
customBarRenderer.setSeriesPaint(4, Color.decode("#F284DC")); // 给series5 Bar
customBarRenderer.setSeriesPaint(5, Color.decode("#00CC33")); // 给series6 Bar
代码上我都设置了,还是同一种颜色,它是3D立体的,不信运行下代码看下,
都不看代码的?
急用啊!