向高手请假 JFreeChart 设置x轴标题位置

lixiao1387 2009-09-28 10:49:46


我想把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
...全文
600 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
code_tung 2010-09-10
  • 打赏
  • 举报
回复
正在学习中
rushmaya 2010-07-05
  • 打赏
  • 举报
回复
看看学习
imasmallbird 2009-09-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lixiao1387 的回复:]
哎!我在csdn提了两问题,都没有回答啊~!而且我给的分还不少!世道~!
[/Quote]

呵呵,不是分多少的问题,没人懂也不能给你瞎写个答案呀~~
lixiao1387 2009-09-29
  • 打赏
  • 举报
回复
哎!我在csdn提了两问题,都没有回答啊~!而且我给的分还不少!世道~!
lixiao1387 2009-09-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lixiao1387 的回复:]
哎!我在csdn提了两问题,都没有回答啊~!而且我给的分还不少!世道~!
[/Quote]

现在的牛人是不是都不上csdn了啊,看来他们都归隐山林了!
imasmallbird 2009-09-28
  • 打赏
  • 举报
回复
找了一中午还是没有找到你说的API,下面是JFreeChart的API文档,你在自己找一找吧,我也挺想知道这个问题,但是现在暂时没有环境,无法测试,你对着这个API文档,把那些set开头的方法,挑一些试试~~
http://www.jfree.org/jfreechart/api/javadoc/index.html

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧