我想把x轴的标题字体(单元成绩)放在X轴的右侧,请问如何设置,本人网上查了许多资料,都没有找到,在此请教!
代码:
JFreeChart jfreechart = ChartFactory.createLineChart(title,sname ,domain ,createDataset,PlotOrientation.VERTICAL, true, true,false);
Font titleFont = new Font("宋体", Font.PLAIN , 25);
jfreechart.getTitle().setFont(titleFont);
jfreechart.setBackgroundPaint(Color.white);
CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
categoryplot.setBackgroundPaint(Color.white);
categoryplot.setDomainGridlinePaint(Color.gray);
categoryplot.setDomainGridlinesVisible(true);
categoryplot.setRangeGridlinePaint(Color.gray);
NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
numberaxis.setAutoRangeIncludesZero(false);//设置Y轴的数据自动范围,不从0开始
LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer)categoryplot.getRenderer();
(CategoryLabelPositions.createUpRotationLabelPositions(1.57));//设置字体倾斜角度的
lineandshaperenderer.setSeriesShapesVisible(0,true); //设置第一根曲线图的交叉点显示
jfreechart.setBackgroundPaint(Color.white);//设置曲线图背景色
CategoryPlot plot = (CategoryPlot) jfreechart.getPlot();
LineAndShapeRenderer xylineandshaperenderer = (LineAndShapeRenderer)plot.getRenderer();
plot.setBackgroundPaint(Color.white);//设置网格背景颜色
plot.setDomainGridlinePaint(Color.pink);//设置网格竖线颜色
plot.setRangeGridlinePaint(Color.pink);//设置网格横线颜色
plot.setAxisOffset(new RectangleInsets(0D, 0D, 0D, 10D));//设置曲线图与xy轴的距离
xylineandshaperenderer.setBaseShapesVisible(true);//设置曲线是否显示数据点
Font xlabelfont = new Font("宋体",Font.BOLD,15) ;// x轴标题字体
Font xtickfont = new Font("宋体",Font.BOLD,15) ;// x轴刻度字体
Font ylabelfont = new Font("宋体",Font.BOLD,15) ;// Y轴标题字体
Font ytickfont = new Font("宋体",Font.BOLD,15) ;// Y轴刻度字体
Font itemfont = new Font("宋体",Font.BOLD,15) ;// 图示字体
plot.getDomainAxis().setLabelFont(xlabelfont); //x轴标题字体
plot.getDomainAxis().setTickLabelFont(xtickfont); //x轴刻度字体
plot.getRangeAxis().setLabelFont(ylabelfont); //y轴外围字体
plot.getRangeAxis().setTickLabelFont(ytickfont); //y轴标题字体
jfreechart.getLegend().setItemFont(itemfont); //设置最底下方框内的字体(图示Legend)
jfreechart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.white));
String path = req.getSession().getServletContext().getRealPath("");
filename = path+"/pic/"+1 +".jpg";
new File(filename);
ChartUtilities.saveChartAsJPEG(new File(filename), 1.0f, jfreechart, 800, 400);//宽1000,高600