- /**
- * 配置字體
- * @param chart JFreeChart 對象
- */
- private void configFont(JFreeChart chart){
- // 配置字體
- Font xfont = new Font("宋體",Font.PLAIN,12) ;// X軸
- Font yfont = new Font("宋體",Font.PLAIN,12) ;// Y軸
- Font kfont = new Font("宋體",Font.PLAIN,12) ;// 底部
- Font titleFont = new Font("隸書", Font.BOLD , 25) ; // 圖片標題
- CategoryPlot plot = chart.getCategoryPlot();// 圖形的繪製結構對象
- // 圖片標題
- chart.setTitle(new TextTitle(chart.getTitle().getText(),titleFont));
- // 底部
- chart.getLegend().setItemFont(kfont);
- // X 軸
- CategoryAxis domainAxis = plot.getDomainAxis();
- domainAxis.setLabelFont(xfont);// 軸標題
- domainAxis.setTickLabelFont(xfont);// 軸數值
- domainAxis.setTickLabelPaint(Color.BLUE) ; // 字體顏色
- domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 橫軸上的label斜顯示
- // Y 軸
- ValueAxis rangeAxis = plot.getRangeAxis();
- rangeAxis.setLabelFont(yfont);
- rangeAxis.setLabelPaint(Color.BLUE) ; // 字體顏色
- rangeAxis.setTickLabelFont(yfont);
- }
JfreeChart字體設置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.